A contrived example :
new GeneratorRepository()
.With<double>(mi => mi.Name.ToLower().Contains("price"), val
=> Math.Round(val, 2))
.With<double>(mi => mi.DeclaringType == typeof (Node), val =>
Math.Round(val, 1))
.With<double>(val => Math.Round(val, 5))
.With(new IntGenerator(42, 42))
.With(mi => mi.DeclaringType == typeof (Node), new
IntGenerator(43, 43))
.With<Item>()
.With(new NullGenerator<Item>())
.With<Node>(gen => gen.Ignore(t => t.YetAnotherLeaf))
.With<Node, DerivedNode>()
.Random<Root>(gen => gen.For(t => t.Leaf, new
ConstantGenerator<int>(5)));
Returns an instance of the Root class where :
- All doubles containing price in the memberinfo name are rounded to
2 decimals after seperator.
- All doubles declared in an instance of the Node class are rounded
to 1 decimal after seperator.
- All other doubles are rounded to 5 decimal after seperator.
- All ints are 42.... except ....
- All ints declared in an instance of the Node class are 43.
- All properties that are an instance of the Item class have a 50%
chance of being null.
- All properties that are an instance of the Node class have a 50%
chance of being an instance of the DerivedNode class.
- Node.YetAnotherLeaf property is ignored.
- Root.Leaf is always 5.
--
To unsubscribe, reply using "remove me" as the subject.