@@ -15,7 +15,9 @@ public class Parent
1515
1616 public class Child
1717 {
18- public int Value { get ; set ; }
18+ public int IntValue { get ; set ; }
19+
20+ public string StringValue { get ; set ; }
1921 }
2022
2123 [ TestMethod ]
@@ -24,10 +26,10 @@ public void RandomizerCreatesObjectsBasedOnPreviouseSetups()
2426 int givenValue = Randomizer < int > . Create ( ) ;
2527
2628 var childFiller = new Filler < Child > ( ) ;
27- var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . Value ) . Use ( givenValue ) . Result ;
29+ var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . IntValue ) . Use ( givenValue ) . Result ;
2830
2931 var child = Randomizer < Child > . Create ( childSetup ) ;
30- Assert . AreEqual ( givenValue , child . Value ) ;
32+ Assert . AreEqual ( givenValue , child . IntValue ) ;
3133 }
3234
3335 [ TestMethod ]
@@ -36,13 +38,13 @@ public void UseSetupsAgainForPropertyConfigurations()
3638 int givenValue = Randomizer < int > . Create ( ) ;
3739
3840 var childFiller = new Filler < Child > ( ) ;
39- var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . Value ) . Use ( givenValue ) . Result ;
41+ var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . IntValue ) . Use ( givenValue ) . Result ;
4042
4143 var parentFiller = new Filler < Parent > ( ) ;
4244 parentFiller . Setup ( ) . OnProperty ( x => x . Child ) . Use ( childSetup ) ;
4345
4446 var parent = parentFiller . Create ( ) ;
45- Assert . AreEqual ( givenValue , parent . Child . Value ) ;
47+ Assert . AreEqual ( givenValue , parent . Child . IntValue ) ;
4648 }
4749
4850 [ TestMethod ]
@@ -51,13 +53,13 @@ public void UseSetupsAgainForTypeConfigurations()
5153 int givenValue = Randomizer < int > . Create ( ) ;
5254
5355 var childFiller = new Filler < Child > ( ) ;
54- var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . Value ) . Use ( givenValue ) . Result ;
56+ var childSetup = childFiller . Setup ( ) . OnProperty ( x => x . IntValue ) . Use ( givenValue ) . Result ;
5557
5658 var parentFiller = new Filler < Parent > ( ) ;
5759 parentFiller . Setup ( ) . OnType < Child > ( ) . Use ( childSetup ) ;
5860
5961 var parent = parentFiller . Create ( ) ;
60- Assert . AreEqual ( givenValue , parent . Child . Value ) ;
62+ Assert . AreEqual ( givenValue , parent . Child . IntValue ) ;
6163 }
6264
6365 [ TestMethod ]
@@ -66,16 +68,34 @@ public void UseSetupsAgain()
6668 int givenValue = Randomizer < int > . Create ( ) ;
6769
6870 var firstChildFiller = new Filler < Child > ( ) ;
69- var childSetup = firstChildFiller . Setup ( ) . OnProperty ( x => x . Value ) . Use ( givenValue ) . Result ;
71+ var childSetup = firstChildFiller . Setup ( ) . OnProperty ( x => x . IntValue ) . Use ( givenValue ) . Result ;
7072
7173 var secondChildFiller = new Filler < Child > ( ) ;
7274 secondChildFiller . Setup ( childSetup ) ;
7375
7476 var child = secondChildFiller . Create ( ) ;
7577
76- Assert . AreEqual ( givenValue , child . Value ) ;
78+ Assert . AreEqual ( givenValue , child . IntValue ) ;
7779 }
7880
81+ [ TestMethod ]
82+ public void SetupsCanBeCreatedWithFactoryMethod ( )
83+ {
84+ var childSetup = FillerSetup . Create < Child > ( ) . OnProperty ( x => x . IntValue ) . Use ( 42 ) . Result ;
85+
86+ var child = Randomizer < Child > . Create ( childSetup ) ;
87+ Assert . AreEqual ( 42 , child . IntValue ) ;
88+ }
7989
90+ [ TestMethod ]
91+ public void SetupsCanBeCreatedWithFactoryMethodBasedOnExistingSetupManager ( )
92+ {
93+ var childSetup = FillerSetup . Create < Child > ( ) . OnProperty ( x => x . IntValue ) . Use ( 42 ) . Result ;
94+ childSetup = FillerSetup . Create < Child > ( childSetup ) . OnProperty ( x => x . StringValue ) . Use ( "Juchu" ) . Result ;
95+
96+ var child = Randomizer < Child > . Create ( childSetup ) ;
97+ Assert . AreEqual ( 42 , child . IntValue ) ;
98+ Assert . AreEqual ( "Juchu" , child . StringValue ) ;
99+ }
80100 }
81101}
0 commit comments