44using Shouldly ;
55using TestStack . Dossier . DataSources . Generators ;
66using TestStack . Dossier . Lists ;
7- using TestStack . Dossier . Tests . Builders ;
87using TestStack . Dossier . Tests . Stubs . ViewModels ;
98using Xunit ;
109
1110namespace TestStack . Dossier . Tests
1211{
13- public class BuilderBuildListTests
12+ // ReSharper disable once InconsistentNaming
13+ public class Builder_CreateListTests
1414 {
15- private DateTime _enrollmentDate = new DateTime ( 2004 , 9 , 9 ) ;
15+ private readonly DateTime _enrollmentDate = new DateTime ( 2004 , 9 , 9 ) ;
1616
1717 [ Fact ]
1818 public void GivenANormalBuilderInstance_WhenCallingIsListBuilderProxy_ThenReturnFalse ( )
@@ -31,65 +31,65 @@ public void GivenAListBuilderProxyInstance_WhenCallingIsListBuilderProxy_ThenRet
3131 }
3232
3333 [ Fact ]
34- public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
34+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfObjectsOfTheRightSizeShouldBeReturned ( )
3535 {
3636 var builders = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
3737
38- var entities = builders . BuildList ( ) ;
38+ var objects = builders . BuildList ( ) ;
3939
40- entities . Count . ShouldBe ( 5 ) ;
40+ objects . Count . ShouldBe ( 5 ) ;
4141 }
4242
4343 [ Fact ]
44- public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfEntitiesOfTheRightSizeShouldBeReturned ( )
44+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfObjectsOfTheRightSizeShouldBeReturned ( )
4545 {
46- List < StudentViewModel > entities = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
46+ List < StudentViewModel > objects = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
4747
48- entities . Count . ShouldBe ( 5 ) ;
48+ objects . Count . ShouldBe ( 5 ) ;
4949 }
5050
5151 [ Fact ]
52- public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfEntitiesOfTheRightTypeShouldBeReturned ( )
52+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfObjectsOfTheRightTypeShouldBeReturned ( )
5353 {
5454 var builders = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
5555
56- var entities = builders . BuildList ( ) ;
56+ var objects = builders . BuildList ( ) ;
5757
58- entities . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
58+ objects . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
5959 }
6060
6161 [ Fact ]
62- public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfEntitiesOfTheRightTypeShouldBeReturned ( )
62+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfObjectsOfTheRightTypeShouldBeReturned ( )
6363 {
64- List < StudentViewModel > entities = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
64+ List < StudentViewModel > objects = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
6565
66- entities . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
66+ objects . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
6767 }
6868
6969 [ Fact ]
70- public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfUniqueEntitiesShouldBeReturned ( )
70+ public void GivenListOfBuilders_WhenCallingBuildListExplicitly_ThenAListOfUniqueObjectsShouldBeReturned ( )
7171 {
7272 var builders = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
7373
74- var entities = builders . BuildList ( ) ;
74+ var objects = builders . BuildList ( ) ;
7575
76- entities . ShouldBeUnique ( ) ;
76+ objects . ShouldBeUnique ( ) ;
7777 }
7878
7979 [ Fact ]
80- public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfUniqueEntitiesShouldBeReturned ( )
80+ public void GivenListOfBuilders_WhenCallingBuildListImplicitly_ThenAListOfUniqueObjectsShouldBeReturned ( )
8181 {
82- List < StudentViewModel > entities = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
82+ List < StudentViewModel > objects = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
8383
84- entities . ShouldBeUnique ( ) ;
84+ objects . ShouldBeUnique ( ) ;
8585 }
8686
8787 [ Fact ]
88- public void GivenListOfBuildersWithCustomisation_WhenBuildingEntitiesExplicitly_ThenTheCustomisationShouldTakeEffect ( )
88+ public void GivenListOfBuildersWithCustomisation_WhenBuildingObjectsExplicitly_ThenTheCustomisationShouldTakeEffect ( )
8989 {
9090 var generator = new SequentialGenerator ( 0 , 100 ) ;
91- var list = StudentViewModelBuilder . CreateListOfSize ( 3 )
92- . All ( ) . With ( b => b . WithFirstName ( generator . Generate ( ) . ToString ( ) ) ) ;
91+ var list = Builder < StudentViewModel > . CreateListOfSize ( 3 )
92+ . All ( ) . With ( b => b . Set ( x => x . FirstName , generator . Generate ( ) . ToString ( ) ) ) ;
9393
9494 var data = list . BuildList ( ) ;
9595
@@ -98,27 +98,27 @@ public void GivenListOfBuildersWithCustomisation_WhenBuildingEntitiesExplicitly_
9898 }
9999
100100 [ Fact ]
101- public void GivenListOfBuildersWithCustomisation_WhenBuildingEntitiesImplicitly_ThenTheCustomisationShouldTakeEffect ( )
101+ public void GivenListOfBuildersWithCustomisation_WhenBuildingObjectsImplicitly_ThenTheCustomisationShouldTakeEffect ( )
102102 {
103103 var generator = new SequentialGenerator ( 0 , 100 ) ;
104104
105- List < StudentViewModel > data = StudentViewModelBuilder . CreateListOfSize ( 3 )
106- . All ( ) . With ( b => b . WithFirstName ( generator . Generate ( ) . ToString ( ) ) ) ;
105+ List < StudentViewModel > data = Builder < StudentViewModel > . CreateListOfSize ( 3 )
106+ . All ( ) . With ( b => b . Set ( x => x . FirstName , generator . Generate ( ) . ToString ( ) ) ) ;
107107
108108 data . Select ( c => c . FirstName ) . ToArray ( )
109109 . ShouldBe ( new [ ] { "0" , "1" , "2" } ) ;
110110 }
111111
112112 [ Fact ]
113- public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEntitiesExplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
113+ public void GivenListOfBuildersWithComplexCustomisations_WhenBuildingObjectsExplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
114114 {
115115 var i = 0 ;
116- var studentViewModels = StudentViewModelBuilder . CreateListOfSize ( 5 )
117- . TheFirst ( 1 ) . WithFirstName ( "First" )
118- . TheNext ( 1 ) . WithLastName ( "Next Last" )
119- . TheLast ( 1 ) . WithLastName ( "Last Last" )
120- . ThePrevious ( 2 ) . With ( b => b . WithLastName ( "last" + ( ++ i ) . ToString ( ) ) )
121- . All ( ) . WhoEntrolledIn ( _enrollmentDate )
116+ var studentViewModels = Builder < StudentViewModel > . CreateListOfSize ( 5 )
117+ . TheFirst ( 1 ) . Set ( x => x . FirstName , "First" )
118+ . TheNext ( 1 ) . Set ( x => x . LastName , "Next Last" )
119+ . TheLast ( 1 ) . Set ( x => x . LastName , "Last Last" )
120+ . ThePrevious ( 2 ) . With ( b => b . Set ( x => x . LastName , "last" + ( ++ i ) . ToString ( ) ) )
121+ . All ( ) . Set ( x => x . EnrollmentDate , _enrollmentDate )
122122 . BuildList ( ) ;
123123
124124 studentViewModels . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
@@ -132,15 +132,15 @@ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEnti
132132 }
133133
134134 [ Fact ]
135- public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEntitiesImplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
135+ public void GivenListOfBuildersWithComplexCustomisations_WhenBuildingObjectsImplicitly_ThenThenTheListIsBuiltAndModifiedCorrectly ( )
136136 {
137137 var i = 0 ;
138- List < StudentViewModel > studentViewModels = StudentViewModelBuilder . CreateListOfSize ( 5 )
139- . TheFirst ( 1 ) . WithFirstName ( "First" )
140- . TheNext ( 1 ) . WithLastName ( "Next Last" )
141- . TheLast ( 1 ) . WithLastName ( "Last Last" )
142- . ThePrevious ( 2 ) . With ( b => b . WithLastName ( "last" + ( ++ i ) . ToString ( ) ) )
143- . All ( ) . WhoEntrolledIn ( _enrollmentDate ) ;
138+ List < StudentViewModel > studentViewModels = Builder < StudentViewModel > . CreateListOfSize ( 5 )
139+ . TheFirst ( 1 ) . Set ( x => x . FirstName , "First" )
140+ . TheNext ( 1 ) . Set ( x => x . LastName , "Next Last" )
141+ . TheLast ( 1 ) . Set ( x => x . LastName , "Last Last" )
142+ . ThePrevious ( 2 ) . With ( b => b . Set ( x => x . LastName , "last" + ( ++ i ) . ToString ( ) ) )
143+ . All ( ) . Set ( x => x . EnrollmentDate , _enrollmentDate ) ;
144144
145145 studentViewModels . ShouldBeAssignableTo < IList < StudentViewModel > > ( ) ;
146146 studentViewModels . Count . ShouldBe ( 5 ) ;
@@ -153,17 +153,17 @@ public void GivenListOfBuildersWithARangeOfCustomisationMethods_WhenBuildingEnti
153153 }
154154
155155 [ Fact ]
156- public void WhenBuildingEntitiesExplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
156+ public void WhenBuildingObjectsExplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
157157 {
158- var studentViewModels = StudentViewModelBuilder . CreateListOfSize ( 5 ) . BuildList ( ) ;
158+ var studentViewModels = Builder < StudentViewModel > . CreateListOfSize ( 5 ) . BuildList ( ) ;
159159
160160 studentViewModels . Select ( x => x . Grade ) . ShouldBeUnique ( ) ;
161161 }
162162
163163 [ Fact ]
164- public void WhenBuildingEntitiesImplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
164+ public void WhenBuildingObjectsImplicitly_ThenTheAnonymousValueFixtureIsSharedAcrossBuilders ( )
165165 {
166- List < StudentViewModel > studentViewModels = StudentViewModelBuilder . CreateListOfSize ( 5 ) ;
166+ List < StudentViewModel > studentViewModels = Builder < StudentViewModel > . CreateListOfSize ( 5 ) ;
167167
168168 studentViewModels . Select ( x => x . Grade ) . ShouldBeUnique ( ) ;
169169 }
0 commit comments