I am working on a pretty nested model that has some circular links. It also uses the Entity Framework, therefore all listings ICollection<T>. To do this, I configure AutoFixture as follows:
_fixture = new Fixture().Customize(new MultipleCustomization());
_fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
When I try to create a type
_fixture.CreateAnonymous<Session>();
AutoFixture has a problem and throws the following error:
System.InvalidCastException: cannot throw an object of type "Ploeh.AutoFixture.Kernel.OmitSpecimen" to enter "The.Model.Language"
If I exclude a collection in a Sessiontype Language, AutoFixture throws the same exception for another type in the graph.
Is there a way to extract additional information from AutoFixture, such as the property that caused the error?
AutoFixture OmitSpecimen , ?
.
Update
.
public class Session
{
public Language Language { get; set; }
}
public class Language
{
public ICollection<Session> Sessions { get; set; }
}
_fixture.CreateAnonymous<Session>(); .