Search And Destroy

Look out honey, ’cause I’m using technology!

QuickGenerate 0.1 Released

Posted by kilfour on June 29, 2010

Go get it here.

So we went from QuickNet.Generators 0.6 to QuickGenerate 0.1 ;-)

I’m expecting to up the numbers rapidly though.

One of the more interesting new additions : The StringBuilderGenerator
F.i. :

string[] firstnames = new[] { "Latoya", "Jos", "Fred" };
string[] lastnames = new[] { "Jackson", "Bosmans", "Flintstone" };
string[] domains = new[] { "itfirm.be", "gov.eu", "hell.de" };

new StringBuilderGenerator()
    .Append(firstnames).Append(".")
    .Append(lastnames).Append("@")
    .Append(domains);

Could return :

Latoya.Bosmans@gov.eu

This one works really well together with the new WordGenerator which can load wordlists from file :

string colour = WordGenerator.FromFile("Colours.txt").GetRandomValue();

Both of them :

new StringBuilderGenerator()
    .Append(WordGenerator.FromFile("Colours.txt")).Append(" ")
    .Append(WordGenerator.FromFile("Adjectives.txt")).Append(" ")
    .Append(WordGenerator.FromFile("Nouns.txt")))

As I said : ‘I’m expecting to up the numbers rapidly’.

F.i. : Allready in the trunk, but not in 0.1

As I was using the StringBuilderGenerator in a scenario similar to this one :

new GeneratorRepository()
    .Random<Person>(
    gen =>
    gen
        .For(person => person.FirstName, () => firstnames)
        .For(person => person.LastName, () => lastnames)
        .For(person => person.Email,
             new StringBuilderGenerator()
                 .Append(firstnames).Append(".")
                 .Append(lastnames).Append("@")
                 .Append(domains)));

It gave me this result :
String FirstName = Fred;
String LastName = Jackson;
String Email = Jos.Bosmans@gov.eu;

The fact that Fred Jackson’s email is Jos.Bosmans annoyed me, so now the following is possible :
new GeneratorRepository()
    .Random<Person>(
    gen =>
    gen
        .For(person => person.FirstName, () => firstnames)
        .For(person => person.LastName, () => lastnames)
        .For(person => person.Email,
             person =>
             new StringBuilderGenerator()
                 .Append(person.FirstName).Append(".")
                 .Append(person.LastName).Append("@")
                 .Append(domains)));

Giving a better result :
String FirstName = Latoya;
String LastName = Flintstone;
String Email = Latoya.Flintstone@itfirm.be;

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.