The domain model I am working with has a lot of circular references. In fact it is possible to get to most objects from any point in the graph. Many of these circular references are also in collections. So a Booking
will have a collection of Students
which has a collection of Courses
which has a collection of Bookings
and so on. This is not the real model, just an example. The problem is caused by a combination of around thirty different classes.
To work with this model I am configuring and using AutoFixture like so
var fixture = new Fixture().Customize(new MultipleCustomization());
fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
fixture.Behaviors.Add(new OmitOnRecursionBehavior());
var booking = fixture.CreateAnonymous<Booking>();
This causes AutoFixture to run for about twenty minutes until it finally fails with an OutOfMemoryException.
Is this model asking AutoFixture to create an infinite graph which can never end? If so, is there any way I can configure it to limit the depth of the graph?