nbuilder
nbuilder copied to clipboard
Add Documentation for GetRandom :: why and how.
GetRandom is hella useful for creating fake data on the fly when using Builder<T>.
eg.
public static IList<User> CreateUsers(int numberOfUsers = 20)
{
return Builder<User>.CreateListOfSize(numberOfUsers)
.TheFirst(1)
.With(x => x.Id, "users/1")
.And(x => x.Name, "Han Solo")
.All()
.With(x => x.Name, $"{GetRandom.FirstName()} {GetRandom.LastName()}")
.With(x => x.Email, GetRandom.Email())
.Build();
}
Needs documentation added to dat wikiz.
I always found the GetRandom to be hidden away and not really felt like part of the API that makes NBuilder so special. Not really related to documenting the static helper but, what about an override of our builder functions where we can pass in an instance of a generator, e.g
With(x => x.Name, (generator) => generator.FirstName())
That's a great suggestion!