I've got this NBuilder code:
var fakeReviews = Builder<Review>
.CreateListOfSize(100)
.Build()
.ToList()
.AsReadOnly();
Pretty dead simple.
But it's erroring here on this property on Review:
public bool WasWrittenByAdmin
{
get
{
if (User == null) throw new InvalidOperationException("Must load User.");
return User.UserSettings != null && User.UserSettings.IsAdmin;
}
}
Basically, i think NBuilder is trying to evaluate all the properties, including the getter, but that User property doesn't exist.
Even if i do this:
var fakeReviews = Builder<Review>
.CreateListOfSize(100)
.All().With(x => x.User = Builder<User>.CreateNew().Build())
.Build()
.ToList()
.AsReadOnly();
It still errors.
Is there any way i can tell NBuilder to intercept that getter, or how do i setup the User property before it tried to evaluate it? (and hence prevent the error).