How can I tell AutoFixture to always create TDerived when it instantiates a TBase?
问题 I have a deeply-nested object model, where some classes might look a bit like this: class TBase { ... } class TDerived : TBase { ... } class Container { ICollection<TBase> instances; ... } class TopLevel { Container container1; Container container2; ... } I'd like to create my top-level object as a test fixture, but I want all the TBase instances (such as in the instances collection above) to be instances of TDerived rather than TBase . I thought I could do this quite simply using something