I use AutoFixture with AutoMoq. I try to create a fake instance of a class which has a property with a getter but without a setter. I expect AutoFixture to configure the mock so it will return the given value even there is no setter.
My code is something like that:
var data = new List<Data>() { new Data() };
var userManager = fixture.Build<IRepository>()
//.With(x => x.Data, data)
.CreateAnonymous();
Mock.Get(userManager).Setup(x => x.Data).Returns(data);
Unfortunately, the "With" method does not work in this case because auto fixture says that Data does not have any setter which why I have to set the value afterwards with a direct call to the mock.
Is there a way that auto fixture can do this by its own so I do not need the last line of code?
Edit: I made a mistake, the code example does not work. It should be
var data = new List<Data>() { new Data() };
var userManager = fixture.CreateAnonymous<IRepository>();
Mock.Get(userManager).Setup(x => x.Data).Returns(data)
Nevertheless, it would be good if there would be a with method for fake instance.