@@ -28,7 +28,7 @@ public void GivenAListBuilderProxyInstance_WhenCallingIsListBuilderProxy_ThenRet
28
28
}
29
29
30
30
[ Fact ]
31
- public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
31
+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
32
32
{
33
33
var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
34
34
@@ -38,7 +38,15 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRig
38
38
}
39
39
40
40
[ Fact ]
41
- public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRightTypeShouldBeReturned ( )
41
+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
42
+ {
43
+ List < Customer > entities = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
44
+
45
+ entities . Count . ShouldBe ( 5 ) ;
46
+ }
47
+
48
+ [ Fact ]
49
+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfEntitiesOfTheRightTypeShouldBeReturned ( )
42
50
{
43
51
var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
44
52
@@ -48,7 +56,15 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRig
48
56
}
49
57
50
58
[ Fact ]
51
- public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfUniqueEntitiesShouldBeReturned ( )
59
+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfEntitiesOfTheRightTypeShouldBeReturned ( )
60
+ {
61
+ List < Customer > entities = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
62
+
63
+ entities . ShouldBeAssignableTo < IList < Customer > > ( ) ;
64
+ }
65
+
66
+ [ Fact ]
67
+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfUniqueEntitiesShouldBeReturned ( )
52
68
{
53
69
var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
54
70
@@ -67,7 +83,24 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfUniqueEntitiesSh
67
83
}
68
84
69
85
[ Fact ]
70
- public void GivenListOfBuildersWithCustomisation_WhenBuildingEntities_ThenTheCustomisationShouldTakeEffect ( )
86
+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfUniqueEntitiesShouldBeReturned ( )
87
+ {
88
+ List < Customer > entities = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
89
+
90
+ entities [ 0 ] . ShouldNotBe ( entities [ 1 ] ) ;
91
+ entities [ 0 ] . ShouldNotBe ( entities [ 2 ] ) ;
92
+ entities [ 0 ] . ShouldNotBe ( entities [ 3 ] ) ;
93
+ entities [ 0 ] . ShouldNotBe ( entities [ 4 ] ) ;
94
+ entities [ 1 ] . ShouldNotBe ( entities [ 2 ] ) ;
95
+ entities [ 1 ] . ShouldNotBe ( entities [ 3 ] ) ;
96
+ entities [ 1 ] . ShouldNotBe ( entities [ 4 ] ) ;
97
+ entities [ 2 ] . ShouldNotBe ( entities [ 3 ] ) ;
98
+ entities [ 2 ] . ShouldNotBe ( entities [ 4 ] ) ;
99
+ entities [ 3 ] . ShouldNotBe ( entities [ 4 ] ) ;
100
+ }
101
+
102
+ [ Fact ]
103
+ public void GivenListOfBuildersWithCustomisation_WhenBuildingEntitiesExplicitly_ThenTheCustomisationShouldTakeEffect ( )
71
104
{
72
105
var generator = new SequentialGenerator ( 0 , 100 ) ;
73
106
var list = CustomerBuilder . CreateListOfSize ( 3 )
@@ -80,7 +113,19 @@ public void GivenListOfBuildersWithCustomisation_WhenBuildingEntities_ThenTheCus
80
113
}
81
114
82
115
[ Fact ]
83
- public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEntities_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
116
+ public void GivenListOfBuildersWithCustomisation_WhenBuildingEntitiesImplicitly_ThenTheCustomisationShouldTakeEffect ( )
117
+ {
118
+ var generator = new SequentialGenerator ( 0 , 100 ) ;
119
+
120
+ List < Customer > data = CustomerBuilder . CreateListOfSize ( 3 )
121
+ . All ( ) . With ( b => b . WithFirstName ( generator . Generate ( ) . ToString ( ) ) ) ;
122
+
123
+ data . Select ( c => c . FirstName ) . ToArray ( )
124
+ . ShouldBe ( new [ ] { "0" , "1" , "2" } ) ;
125
+ }
126
+
127
+ [ Fact ]
128
+ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEntitiesExplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
84
129
{
85
130
var i = 0 ;
86
131
var customers = CustomerBuilder . CreateListOfSize ( 5 )
@@ -102,7 +147,28 @@ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEnti
102
147
}
103
148
104
149
[ Fact ]
105
- public void WhenBuildingEntities_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
150
+ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEntitiesImplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
151
+ {
152
+ var i = 0 ;
153
+ List < Customer > customers = CustomerBuilder . CreateListOfSize ( 5 )
154
+ . TheFirst ( 1 ) . WithFirstName ( "First" )
155
+ . TheNext ( 1 ) . WithLastName ( "Next Last" )
156
+ . TheLast ( 1 ) . WithLastName ( "Last Last" )
157
+ . ThePrevious ( 2 ) . With ( b => b . WithLastName ( "last" + ( ++ i ) . ToString ( ) ) )
158
+ . All ( ) . WhoJoinedIn ( 1999 ) ;
159
+
160
+ customers . ShouldBeAssignableTo < IList < Customer > > ( ) ;
161
+ customers . Count . ShouldBe ( 5 ) ;
162
+ customers [ 0 ] . FirstName . ShouldBe ( "First" ) ;
163
+ customers [ 1 ] . LastName . ShouldBe ( "Next Last" ) ;
164
+ customers [ 2 ] . LastName . ShouldBe ( "last1" ) ;
165
+ customers [ 3 ] . LastName . ShouldBe ( "last2" ) ;
166
+ customers [ 4 ] . LastName . ShouldBe ( "Last Last" ) ;
167
+ customers . ShouldAllBe ( c => c . YearJoined == 1999 ) ;
168
+ }
169
+
170
+ [ Fact ]
171
+ public void WhenBuildingEntitiesExplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
106
172
{
107
173
var customers = CustomerBuilder . CreateListOfSize ( 5 ) . BuildList ( ) ;
108
174
@@ -112,5 +178,17 @@ public void WhenBuildingEntities_ThenTheAnonymousValueFixtureIsSharedAcrossBuild
112
178
customers [ 3 ] . CustomerClass . ShouldBe ( CustomerClass . Gold ) ;
113
179
customers [ 4 ] . CustomerClass . ShouldBe ( CustomerClass . Platinum ) ;
114
180
}
181
+
182
+ [ Fact ]
183
+ public void WhenBuildingEntitiesImplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
184
+ {
185
+ List < Customer > customers = CustomerBuilder . CreateListOfSize ( 5 ) ;
186
+
187
+ customers [ 0 ] . CustomerClass . ShouldBe ( CustomerClass . Normal ) ;
188
+ customers [ 1 ] . CustomerClass . ShouldBe ( CustomerClass . Bronze ) ;
189
+ customers [ 2 ] . CustomerClass . ShouldBe ( CustomerClass . Silver ) ;
190
+ customers [ 3 ] . CustomerClass . ShouldBe ( CustomerClass . Gold ) ;
191
+ customers [ 4 ] . CustomerClass . ShouldBe ( CustomerClass . Platinum ) ;
192
+ }
115
193
}
116
194
}
0 commit comments