By default, AutoFixture will not create an instance of Something
because the graph contains a circular reference.
What you can do is to add / remove the appropriate behaviors on the Fixture
instance:
fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
fixture.Behaviors.Add(new OmitOnRecursionBehavior());
You can now create an instance of Something
however the Things
property (circular reference) is now omitted.
That's why you get an empty list..
However, you can customize the creation algorithm even further:
var obj = fixture.Build<Something>()
.With(x => x.Id,
"something")
.With(x => x.Things,
fixture.CreateMany<Something>().ToList())
.Create();