Reputation: 4478
I'm using NBuilder for mocking up test data for a object graph of owner and cars. So the relationship between a single owner and cars is unique.
Owner 1
- Car 2
- Car 3
Owner 2
- Car 4
- Car 5
So I have used the following code:
var owners = (List<Owner>)Builder<Owner>.CreateListOfSize(2)
.All()
.Do(d => d.Tranche = (List<Car>)Pick<Car>.UniqueRandomList(2).From(cars))
.Build();
However, what I get is that same car is being picked up for the multiple owners:
Owner 1
- Car 2
- Car 4
Owner 2
- Car 4
- Car 5
Is there anyway to handle this ? so that the relationship for the mock data is unique.
Upvotes: 2
Views: 475