0

I need somehow specify my own value for public read-only property in the tested class

With Moq I can use something like

moq.SetupGet(m=>m.SomeReadOnlyProps).Returns(value)

then I can use it in the test.

With AutoFixture- I can't do this, since it said that it is read-only:

var sut = _fixture.Build<SomeClass>()
     .With(m=>m.SomeReadonlyProperty, value) // here I got exception 
     .Create();

Can somebody guide me to use the proper approach for setup read-only property with the usage AutoFixture?

Anton
  • 718
  • 6
  • 11
  • Yes.. it seems to it is the same. But in general, I in the post marked as an answer - I don't see the clear answer for the proper way... just an explanation of why Build API does not allow setup read-only props. – Anton Aug 16 '23 at 12:28
  • I think Fabio's post shows how to define a workaround. – Peter Csala Aug 17 '23 at 09:03

0 Answers0