Using .With() with delayed execution values?

Apr 4, 2012 at 12:06 AM

Is there any way to use/extend .With()  with delayed execution values.

I'd like to be able to do something like:

var item = fixture.Build<Item>().With(s=>s.Number, randomNumberGenerator.Generate()).CreateMany(500);

so that for each built item the func is called to populate a different number.

I could place the logic in a SpecimenBuilder but the above would be much more succinct.

Are there any other ways to tackle this?

Apr 4, 2012 at 5:46 AM
Edited Apr 4, 2012 at 5:46 AM

Here's one way to do it:

Here's another: