Tuesday, October 25, 2011

NBuilder with Prototypes

I've created an extension method for NBuilder's SingleObjectBuilder. This allows setting property values based on a prototype. A typical usage would supply an anonymous object as the prototype...

            var prototypeStyle = Builder<Subject>
.CreateNew()
.Prototype(new
{
Id = 11,
Name = "prototypeStyle",
ParentName = "Dad"
})
.Build();



I like this style because the property name/value pairs are easier to see.

You can find an implementation at http://code.google.com/p/nbuilder/issues/detail?id=78

No comments: