vendredi 5 juin 2015

NBuilder - creating more Random types e.g. EmailAddress

Right now I am using NBuilder to generate Customers in my mock repository. Unfortunately the only option I have for random strings seems to be .Phrase()

var customers = Builder<Customer>.CreateListOfSize(10)
                               .All()
                               .WithConstructor(() => new Customer(
                r.Int().ToString(),
                r.Phrase(5),
                r.Phrase(15),
                r.Phrase(15), // EmailAddress
                r.Phrase(15),
                r.Phrase(15),
                r.DateTime()
                ))
                .Build();

I would love to be able to generate semi-sensible data, like an email address. Is there a way to customise NBuilder to do this, or should I be piecing together two .Phrase() calls with an @ symbol?

Aucun commentaire:

Enregistrer un commentaire