asiftasleem / nbuilder

Automatically exported from code.google.com/p/nbuilder
0 stars 0 forks source link

Generate Random string #37

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
How do i generate a random string using nbuilder?

Original issue reported on code.google.com by nsriniva...@gmail.com on 26 Jan 2010 at 7:52

GoogleCodeExporter commented 8 years ago
You're able to do this using the GetRanom.Phrase method.  See example below:-

IEnumerable<Product> playlists = Builder<Product>.CreateListOfSize(5)
                .WhereAll()
                .Have(p => p.Name = GetRandom.Phrase(r.Next(20, 100)))
                .Build();

The name property would be filled with a string / phrase between 20 and 100 
chars long.

Original comment by peter.be...@googlemail.com on 14 Feb 2010 at 3:30

GoogleCodeExporter commented 8 years ago
As peter.beams stated above, you can generate a random string using the 
GetRandom class.

Here is an example of creating a single random string:

var myString = GetRandom.String(20);

Here is an example of how you might use this when creating a list:

IEnumerable<Product> playlists = Builder<Product>.CreateListOfSize(5)
                .WhereAll()
                .Have(p => p.Title = GetRandom.String(20))
                .Build();

Because this functionality already exists, I am rejecting this issue.

Original comment by joshuajr...@gmail.com on 10 Sep 2010 at 8:12