I hope someone can give me some ideas.
I need to create a mocked object that satisfies the following:
- It implements the interface IEntity.
- It uses the base implementation I already have in EntityBase.
- The properties are auto generated with AutoFixture.
I have tried several alternatives and I ended with this code:
fixture.Customize(new AutoConfiguredMoqCustomization());
fixture.Customize<IEntity>(c => c.FromFactory(
() => fixture.Create<Mock<EntityBase>>().As<IEntity>().Object));
However, I obtain the following exception:
Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that. :(