Sometimes you might want to set up rules for sample items that will be generated later. One reason for this might be to stub out a method that creates different items with each call.


// Somewhere in startup

Fabricator.Setup<MyClass>()
          .For(x => x.Property).Use("Value");

// Elsewhere in code

Fabricator.Generate<MyClass>(10);

You can also hold a reference to the setup options if you don't want to go via the static accessor.

var myClassOptions = Fabricator.Setup<MyClass>()
                               .For(x => x.Property).Use("Value");


var sampleItems = myClassOptions.Generate(10);

Last edited Oct 24, 2010 at 10:27 AM by JRoughan, version 1

Comments

No comments yet.