Search the web
Sign In
New User? Sign Up
altdotnet · Alt Dot.Net Discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Introducing NBuilder   Message List  
Reply | Forward Message #22169 of 23389 |
Hi everyone

I want to introduce you to an open source project I've been working on.

It's called NBuilder and allows you create test instances using a fluent
interface.

http://code.google.com/p/nbuilder/

The intended use is for unit, integration / functional tests, acceptance tests
and generating test data for manual testing. It could probably be used for
things like returning data from stubbed services as well.

The properties of the class will (by default) be named sequentially. This is
useful because the data is predictable. e.g.

var products = Builder<Product>.CreateListOfSize(5).Build();

will always give you

Product
Id Title Description
=============================
1 Title1 Description1
2 Title2 Description2
3 Title3 Description3
4 Title4 Description4
5 Title5 Description5


NBuilder will assign values (using either the sequential strategy or a random or
other custom one) to all the properties it is able to, but you can override any
properties with specific values.

For example:
==========================
Builder<Product>
.CreateListOfSize(20)
.WhereAll()
.AreConstructedWith("TestProduct")
.WhereTheFirst(5)
.Have(x => x.Created = On.July.The4th.At(09, 00))
.And(x => x.LastEdited = On.August.The21st)
.AndTheNext(5)
.Have(x => x.Title = "A different title")
.AndTheNext(10)
.Have(x => x.Price = 5000m)
.Build();
==========================

(I've just added the fluent date format to it, see this blog post:
http://shouldbeableto.wordpress.com/2009/06/06/fluent-dates-added-to-nbuilder/)

You can also set persistence up (using the BuilderSetup class) which then allows
you to do this:

Builder<Category>.CreateListOfSize(100).Persist();

It's most of the OOTB interface is implemented using extensions methods, so the
whole thing is very extendible.

There are loads more features, I won't bother to list all them all here because
they're available on the project's home page on google code:
http://code.google.com/p/nbuilder/

There are two people contributing now, if anyone else would like to get involved
they'd be more than welcome.

I've just posted a new version, 2.1.7 up which has bug fixes and some new
features.

Please get in touch with any comments, problems, suggestions or feature
requests.

Gareth






Sat Jun 6, 2009 12:26 pm

garethdown44
Offline Offline
Send Email Send Email

Forward
Message #22169 of 23389 |
Expand Messages Author Sort by Date

Hi everyone I want to introduce you to an open source project I've been working on. It's called NBuilder and allows you create test instances using a fluent...
garethdown44
Offline Send Email
Jun 6, 2009
12:27 pm

Very cool. We are replacing our hand rolled builders with NBuilder on my current project. Question. Is there a discussion group? I had an idea for an...
Tim Scott
timtas
Offline Send Email
Jun 24, 2009
2:14 pm

Hi Tim Thanks very much for the feedback. Great idea, I've just created a Google group for it and invited you to join: http://groups.google.com/group/nbuilder ...
Gareth Down
garethdown44
Offline Send Email
Jun 24, 2009
2:51 pm

hey, i've dream about it! Cool Project! Thanks!...
Tiago Soczek
tiagosoczek
Offline Send Email
Jun 24, 2009
2:56 pm

No problem! Since that post I've created a website for it http://www.nbuilder.org/, which has some documentation here: http://www.nbuilder.org/Documentation ...
Gareth Down
garethdown44
Offline Send Email
Jun 24, 2009
3:13 pm

Very cool. I was actually working on building something very similar before. You beat me to it. Love it. Good work!...
Jay Chapman
jchapman202
Offline Send Email
Jun 24, 2009
4:11 pm

added to my my little bag of lib that starts every new project. love it. thanks. ... -- "The explanation requiring the fewest assumptions is most likely to be ...
Bobby Johnson
notmyself74
Offline Send Email
Jun 25, 2009
4:22 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help