@@ -28,7 +28,7 @@ public void GivenAListBuilderProxyInstance_WhenCallingIsListBuilderProxy_ThenRet
2828 }
2929
3030 [ Fact ]
31- public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
31+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
3232 {
3333 var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
3434
@@ -38,7 +38,15 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRig
3838 }
3939
4040 [ 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 ( )
4250 {
4351 var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
4452
@@ -48,7 +56,15 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfEntitiesOfTheRig
4856 }
4957
5058 [ 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 ( )
5268 {
5369 var builders = BasicCustomerBuilder . CreateListOfSize ( 5 ) ;
5470
@@ -67,7 +83,24 @@ public void GivenListOfBuilders_WhenCallingBuildList_ThenAListOfUniqueEntitiesSh
6783 }
6884
6985 [ 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 ( )
71104 {
72105 var generator = new SequentialGenerator ( 0 , 100 ) ;
73106 var list = CustomerBuilder . CreateListOfSize ( 3 )
@@ -80,7 +113,19 @@ public void GivenListOfBuildersWithCustomisation_WhenBuildingEntities_ThenTheCus
80113 }
81114
82115 [ 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 ( )
84129 {
85130 var i = 0 ;
86131 var customers = CustomerBuilder . CreateListOfSize ( 5 )
@@ -102,7 +147,28 @@ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEnti
102147 }
103148
104149 [ 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 ( )
106172 {
107173 var customers = CustomerBuilder . CreateListOfSize ( 5 ) . BuildList ( ) ;
108174
@@ -112,5 +178,17 @@ public void WhenBuildingEntities_ThenTheAnonymousValueFixtureIsSharedAcrossBuild
112178 customers [ 3 ] . CustomerClass . ShouldBe ( CustomerClass . Gold ) ;
113179 customers [ 4 ] . CustomerClass . ShouldBe ( CustomerClass . Platinum ) ;
114180 }
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+ }
115193 }
116194}
0 commit comments