@@ -30,14 +30,14 @@ namespace Fclp.Tests
3030 public class FluentCommandLineParserBuilderTests
3131 {
3232 [ Subject ( typeof ( FluentCommandLineBuilder < > ) ) ]
33- abstract class FluentCommandLineParserBuilderTestContext : TestContextBase < FluentCommandLineBuilder < TestApplicationArgs > >
33+ abstract class FluentCommandLineParserBuilderTestContext < TArg > : TestContextBase < FluentCommandLineBuilder < TArg > > where TArg : new ( )
3434 {
3535 Establish context = ( ) => CreateSut ( ) ;
3636 }
3737
3838 sealed class Parse
3939 {
40- abstract class ParseTestContext : FluentCommandLineParserBuilderTestContext
40+ abstract class ParseTestContext < TArg > : FluentCommandLineParserBuilderTestContext < TArg > where TArg : new ( )
4141 {
4242 protected static string [ ] args ;
4343 protected static ICommandLineParserResult result ;
@@ -46,18 +46,18 @@ abstract class ParseTestContext : FluentCommandLineParserBuilderTestContext
4646 result = sut . Parse ( args ) ;
4747 }
4848
49- class when_invoked_with_example : ParseTestContext
49+ class when_invoked_with_example : ParseTestContext < TestApplicationArgs >
5050 {
5151 Establish context = ( ) =>
5252 {
5353 sut . Setup ( x => x . NewValue )
54- . As ( 'v' , "value" ) ;
54+ . As ( 'v' , "value" ) ;
5555
5656 sut . Setup ( x => x . RecordId )
57- . As ( 'r' , "recordId" ) ;
57+ . As ( 'r' , "recordId" ) ;
5858
5959 sut . Setup ( x => x . Silent )
60- . As ( 's' , "silent" ) ;
60+ . As ( 's' , "silent" ) ;
6161
6262 args = new [ ] { "-r" , "10" , "-v" , "Mr. Smith" , "--silent" } ;
6363 } ;
@@ -72,13 +72,13 @@ class when_invoked_with_example : ParseTestContext
7272 sut . Object . NewValue . ShouldEqual ( "Mr. Smith" ) ;
7373 }
7474
75- class when_required_option_is_not_provided : ParseTestContext
75+ class when_required_option_is_not_provided : ParseTestContext < TestApplicationArgs >
7676 {
7777 Establish context = ( ) =>
7878 {
7979 sut . Setup ( x => x . NewValue )
80- . As ( 'v' , "value" )
81- . Required ( ) ;
80+ . As ( 'v' , "value" )
81+ . Required ( ) ;
8282
8383 args = new [ ] { "-r" , "10" , "--silent" } ;
8484 } ;
@@ -87,7 +87,7 @@ class when_required_option_is_not_provided : ParseTestContext
8787 result . HasErrors . ShouldBeTrue ( ) ;
8888 }
8989
90- class when_default_is_specified_on_an_option_that_is_not_specified : ParseTestContext
90+ class when_default_is_specified_on_an_option_that_is_not_specified : ParseTestContext < TestApplicationArgs >
9191 {
9292 protected static string expectedDefaultValue ;
9393
@@ -96,14 +96,14 @@ class when_default_is_specified_on_an_option_that_is_not_specified : ParseTestCo
9696 Create ( out expectedDefaultValue ) ;
9797
9898 sut . Setup ( x => x . RecordId )
99- . As ( 'r' , "recordId" ) ;
99+ . As ( 'r' , "recordId" ) ;
100100
101101 sut . Setup ( x => x . Silent )
102- . As ( 's' , "silent" ) ;
102+ . As ( 's' , "silent" ) ;
103103
104104 sut . Setup ( x => x . NewValue )
105- . As ( 'v' , "value" )
106- . SetDefault ( expectedDefaultValue ) ;
105+ . As ( 'v' , "value" )
106+ . SetDefault ( expectedDefaultValue ) ;
107107
108108 args = new [ ] { "-r" , "10" , "--silent" } ;
109109 } ;
@@ -112,6 +112,82 @@ class when_default_is_specified_on_an_option_that_is_not_specified : ParseTestCo
112112 sut . Object . NewValue . ShouldEqual ( expectedDefaultValue ) ;
113113
114114 }
115+
116+ class when_building_objects_with_list_properties : ParseTestContext < ListTestApplicationArgs >
117+ {
118+ Establish context = ( ) =>
119+ {
120+ sut . Setup ( x => x . Booleans )
121+ . As ( "booleans" ) ;
122+
123+ sut . Setup ( x => x . Doubles )
124+ . As ( "doubles" ) ;
125+
126+ sut . Setup ( x => x . Integers )
127+ . As ( "integers" ) ;
128+
129+ sut . Setup ( x => x . Strings )
130+ . As ( "strings" ) ;
131+
132+ args = new [ ]
133+ {
134+ "--booleans" , "true" , "false" , "false" , "true" ,
135+ "--doubles" , "123.456" , "789.456" , "456.123" ,
136+ "--integers" , "1" , "0" , "5" , "10" , "15" ,
137+ "--strings" , "a" , "list" , "of" , "strings"
138+ } ;
139+ } ;
140+
141+ It should_contains_only_the_expected_integers = ( ) =>
142+ sut . Object . Integers . ShouldContainOnly ( 1 , 0 , 5 , 10 , 15 ) ;
143+
144+ It should_contains_only_the_expected_doubles = ( ) =>
145+ sut . Object . Doubles . ShouldContainOnly ( 123.456d , 789.456d , 456.123d ) ;
146+
147+ It should_contains_only_the_expected_booleans = ( ) =>
148+ sut . Object . Booleans . ShouldContainOnly ( true , false , false , true ) ;
149+
150+ It should_contains_only_the_expected_strings = ( ) =>
151+ sut . Object . Strings . ShouldContainOnly ( "a" , "list" , "of" , "strings" ) ;
152+ }
153+
154+ class when_building_objects_with_enumerable_properties : ParseTestContext < EnumerableApplicationArgs >
155+ {
156+ Establish context = ( ) =>
157+ {
158+ sut . Setup ( x => x . Booleans )
159+ . As ( "booleans" ) ;
160+
161+ sut . Setup ( x => x . Doubles )
162+ . As ( "doubles" ) ;
163+
164+ sut . Setup ( x => x . Integers )
165+ . As ( "integers" ) ;
166+
167+ sut . Setup ( x => x . Strings )
168+ . As ( "strings" ) ;
169+
170+ args = new [ ]
171+ {
172+ "--booleans" , "true" , "false" , "false" , "true" ,
173+ "--doubles" , "123.456" , "789.456" , "456.123" ,
174+ "--integers" , "1" , "0" , "5" , "10" , "15" ,
175+ "--strings" , "a" , "list" , "of" , "strings"
176+ } ;
177+ } ;
178+
179+ It should_contains_only_the_expected_integers = ( ) =>
180+ sut . Object . Integers . ShouldContainOnly ( 1 , 0 , 5 , 10 , 15 ) ;
181+
182+ It should_contains_only_the_expected_doubles = ( ) =>
183+ sut . Object . Doubles . ShouldContainOnly ( 123.456d , 789.456d , 456.123d ) ;
184+
185+ It should_contains_only_the_expected_booleans = ( ) =>
186+ sut . Object . Booleans . ShouldContainOnly ( true , false , false , true ) ;
187+
188+ It should_contains_only_the_expected_strings = ( ) =>
189+ sut . Object . Strings . ShouldContainOnly ( "a" , "list" , "of" , "strings" ) ;
190+ }
115191 }
116192 }
117193}
0 commit comments