nbuilder icon indicating copy to clipboard operation
nbuilder copied to clipboard

Add Documentation for GetRandom :: why and how.

Open PureKrome opened this issue 9 years ago • 2 comments

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.

PureKrome avatar May 12 '16 04:05 PureKrome

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())

pjmagee avatar Aug 09 '17 10:08 pjmagee

That's a great suggestion!

PureKrome avatar Aug 09 '17 11:08 PureKrome