@@ -15,7 +15,9 @@ public class Parent
15
15
16
16
public class Child
17
17
{
18
- public int Value { get ; set ; }
18
+ public int IntValue { get ; set ; }
19
+
20
+ public string StringValue { get ; set ; }
19
21
}
20
22
21
23
[ TestMethod ]
@@ -24,10 +26,10 @@ public void RandomizerCreatesObjectsBasedOnPreviouseSetups()
24
26
int givenValue = Randomizer < int > . Create ( ) ;
25
27
26
28
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 ;
28
30
29
31
var child = Randomizer < Child > . Create ( childSetup ) ;
30
- Assert . AreEqual ( givenValue , child . Value ) ;
32
+ Assert . AreEqual ( givenValue , child . IntValue ) ;
31
33
}
32
34
33
35
[ TestMethod ]
@@ -36,13 +38,13 @@ public void UseSetupsAgainForPropertyConfigurations()
36
38
int givenValue = Randomizer < int > . Create ( ) ;
37
39
38
40
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 ;
40
42
41
43
var parentFiller = new Filler < Parent > ( ) ;
42
44
parentFiller . Setup ( ) . OnProperty ( x => x . Child ) . Use ( childSetup ) ;
43
45
44
46
var parent = parentFiller . Create ( ) ;
45
- Assert . AreEqual ( givenValue , parent . Child . Value ) ;
47
+ Assert . AreEqual ( givenValue , parent . Child . IntValue ) ;
46
48
}
47
49
48
50
[ TestMethod ]
@@ -51,13 +53,13 @@ public void UseSetupsAgainForTypeConfigurations()
51
53
int givenValue = Randomizer < int > . Create ( ) ;
52
54
53
55
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 ;
55
57
56
58
var parentFiller = new Filler < Parent > ( ) ;
57
59
parentFiller . Setup ( ) . OnType < Child > ( ) . Use ( childSetup ) ;
58
60
59
61
var parent = parentFiller . Create ( ) ;
60
- Assert . AreEqual ( givenValue , parent . Child . Value ) ;
62
+ Assert . AreEqual ( givenValue , parent . Child . IntValue ) ;
61
63
}
62
64
63
65
[ TestMethod ]
@@ -66,16 +68,34 @@ public void UseSetupsAgain()
66
68
int givenValue = Randomizer < int > . Create ( ) ;
67
69
68
70
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 ;
70
72
71
73
var secondChildFiller = new Filler < Child > ( ) ;
72
74
secondChildFiller . Setup ( childSetup ) ;
73
75
74
76
var child = secondChildFiller . Create ( ) ;
75
77
76
- Assert . AreEqual ( givenValue , child . Value ) ;
78
+ Assert . AreEqual ( givenValue , child . IntValue ) ;
77
79
}
78
80
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
+ }
79
89
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
+ }
80
100
}
81
101
}
0 commit comments