when set property "with" method, leave null propertys on nested objects same named.
(im using autofixture's latest version 3.0.8)
public class { public string id { get; set; } public ilist<something> things { get; set; } } var obj = fixture.build<something>().with(q => q.id, "something").createanonymous() in situation, obj.id == "something" equals true, obj.things[0].id == null equalsto true.
i think there bug or im mistaken; may help?
by default, autofixture not create instance of something because graph contains circular reference.
what can add / remove appropriate behaviors on fixture instance:
fixture.behaviors.remove(new throwingrecursionbehavior()); fixture.behaviors.add(new omitonrecursionbehavior()); you can create instance of something things property (circular reference) omitted.
that's why empty list..
however, can customize creation algorithm further:
var obj = fixture.build<something>() .with(x => x.id, "something") .with(x => x.things, fixture.createmany<something>().tolist()) .create();
Comments
Post a Comment