Search code examples
c#.net-4.0nbuilder

NBuilder - Issue Creating Nested Object


I'm trying to create some dummy objects which have a hierachy like this:

Post
 |
 ----User

Pretty simple.

Here's the code:

var user = Builder<User>.CreateNew().Build();
var posts  = Builder<Post>.CreateListOfSize(100)
                .All()
                .With(x => x.User == user)
                .Build();

But for each item, post.User is null.

Any ideas?


Solution

  • should it be?

    .With(x => x.User = user)