22
22
// POSSIBILITY OF SUCH DAMAGE.
23
23
#endregion
24
24
25
+ using System ;
25
26
using Fclp . Internals ;
26
27
using Fclp . Internals . Validators ;
27
28
using Machine . Specifications ;
@@ -44,6 +45,34 @@ abstract class NoDuplicateOptionValidatorTestContext : TestContextBase<NoDuplica
44
45
} ;
45
46
}
46
47
48
+ sealed class IsCaseSensitive
49
+ {
50
+ abstract class IsCaseSensitiveTestContext : NoDuplicateOptionValidatorTestContext
51
+ { }
52
+
53
+ class when_enabled : IsCaseSensitiveTestContext
54
+ {
55
+ Because of = ( ) => sut . IsCaseSensitive = true ;
56
+
57
+ It should_return_enabled = ( ) =>
58
+ sut . IsCaseSensitive . ShouldBeTrue ( ) ;
59
+
60
+ It should_set_the_comparison_type_to_case_sensitive = ( ) =>
61
+ sut . ComparisonType . ShouldEqual ( StringComparison . CurrentCulture ) ;
62
+ }
63
+
64
+ class when_disabled : IsCaseSensitiveTestContext
65
+ {
66
+ Because of = ( ) => sut . IsCaseSensitive = false ;
67
+
68
+ It should_return_enabled = ( ) =>
69
+ sut . IsCaseSensitive . ShouldBeFalse ( ) ;
70
+
71
+ It should_set_the_comparison_type_to_ignore_case = ( ) =>
72
+ sut . ComparisonType . ShouldEqual ( StringComparison . CurrentCultureIgnoreCase ) ;
73
+ }
74
+ }
75
+
47
76
sealed class Validate
48
77
{
49
78
[ Subject ( "Validate" ) ]
@@ -92,82 +121,176 @@ class when_there_have_been_no_options_setup_thus_far : ValidateTestContext
92
121
It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
93
122
}
94
123
95
- class when_an_existing_option_contains_the_same_short_name_but_it_differs_by_case : ValidateTestContext
124
+ sealed class when_case_sensitive
96
125
{
97
- Establish context = ( ) =>
126
+ abstract class CaseSensitiveTestContext : ValidateTestContext
98
127
{
99
- var existingOption =
100
- CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) ) ;
128
+ Establish context = ( ) => sut . IsCaseSensitive = true ;
129
+ }
101
130
102
- SetupExistingParserOptions ( existingOption ) ;
103
- } ;
131
+ class when_an_existing_option_contains_the_same_short_name_but_it_differs_by_case : CaseSensitiveTestContext
132
+ {
133
+ Establish context = ( ) =>
134
+ {
135
+ var existingOption =
136
+ CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) ) ;
104
137
105
- It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
106
- }
138
+ SetupExistingParserOptions ( existingOption ) ;
139
+ } ;
107
140
108
- class when_an_existing_option_contains_the_same_short_name : ValidateTestContext
109
- {
110
- Establish context = ( ) =>
141
+ It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
142
+ }
143
+
144
+ class when_an_existing_option_contains_the_same_short_name : CaseSensitiveTestContext
111
145
{
112
- var existingOption =
113
- CreateOptionWith ( shortName : option . Object . ShortName ) ;
146
+ Establish context = ( ) =>
147
+ {
148
+ var existingOption =
149
+ CreateOptionWith ( shortName : option . Object . ShortName ) ;
114
150
115
- SetupExistingParserOptions ( existingOption ) ;
116
- } ;
151
+ SetupExistingParserOptions ( existingOption ) ;
152
+ } ;
117
153
118
- It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
119
- }
154
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
155
+ }
120
156
121
- class when_an_existing_option_contains_the_same_long_name_but_it_differs_by_case : ValidateTestContext
122
- {
123
- Establish context = ( ) =>
157
+ class when_an_existing_option_contains_the_same_long_name_but_it_differs_by_case : CaseSensitiveTestContext
124
158
{
125
- var existingOption =
126
- CreateOptionWith ( longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
159
+ Establish context = ( ) =>
160
+ {
161
+ var existingOption =
162
+ CreateOptionWith ( longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
127
163
128
- SetupExistingParserOptions ( existingOption ) ;
129
- } ;
164
+ SetupExistingParserOptions ( existingOption ) ;
165
+ } ;
130
166
131
- It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
132
- }
167
+ It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
168
+ }
133
169
134
- class when_an_existing_option_contains_the_same_long_name : ValidateTestContext
135
- {
136
- Establish context = ( ) =>
170
+ class when_an_existing_option_contains_the_same_long_name : CaseSensitiveTestContext
137
171
{
138
- var existingOption =
139
- CreateOptionWith ( longName : option . Object . LongName ) ;
172
+ Establish context = ( ) =>
173
+ {
174
+ var existingOption =
175
+ CreateOptionWith ( longName : option . Object . LongName ) ;
140
176
141
- SetupExistingParserOptions ( existingOption ) ;
142
- } ;
177
+ SetupExistingParserOptions ( existingOption ) ;
178
+ } ;
143
179
144
- It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
145
- }
180
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
181
+ }
146
182
147
- class when_an_existing_option_contains_the_same_short_AND_long_name_but_they_differs_by_case : ValidateTestContext
148
- {
149
- Establish context = ( ) =>
183
+ class when_an_existing_option_contains_the_same_short_AND_long_name_but_they_differs_by_case : CaseSensitiveTestContext
150
184
{
151
- var existingOption =
152
- CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) , longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
185
+ Establish context = ( ) =>
186
+ {
187
+ var existingOption =
188
+ CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) , longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
153
189
154
- SetupExistingParserOptions ( existingOption ) ;
155
- } ;
190
+ SetupExistingParserOptions ( existingOption ) ;
191
+ } ;
156
192
157
- It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
193
+ It should_not_throw_an_error = ( ) => error . ShouldBeNull ( ) ;
194
+ }
195
+
196
+ class when_an_existing_option_contains_the_same_short_AND_long_name : CaseSensitiveTestContext
197
+ {
198
+ Establish context = ( ) =>
199
+ {
200
+ var existingOption =
201
+ CreateOptionWith ( shortName : option . Object . ShortName , longName : option . Object . LongName ) ;
202
+
203
+ SetupExistingParserOptions ( existingOption ) ;
204
+ } ;
205
+
206
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
207
+ }
158
208
}
159
209
160
- class when_an_existing_option_contains_the_same_short_AND_long_name : ValidateTestContext
210
+ sealed class when_ignore_case
161
211
{
162
- Establish context = ( ) =>
212
+ abstract class IgnoreCaseTestContext : ValidateTestContext
163
213
{
164
- var existingOption =
165
- CreateOptionWith ( shortName : option . Object . ShortName , longName : option . Object . LongName ) ;
214
+ Establish context = ( ) => sut . IsCaseSensitive = false ;
215
+ }
166
216
167
- SetupExistingParserOptions ( existingOption ) ;
168
- } ;
217
+ class when_an_existing_option_contains_the_same_short_name_but_it_differs_by_case : IgnoreCaseTestContext
218
+ {
219
+ Establish context = ( ) =>
220
+ {
221
+ var existingOption =
222
+ CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) ) ;
223
+
224
+ SetupExistingParserOptions ( existingOption ) ;
225
+ } ;
226
+
227
+ It should_throw_an_error_because_case_is_ignored = ( ) => error . ShouldNotBeNull ( ) ;
228
+ }
229
+
230
+ class when_an_existing_option_contains_the_same_short_name : IgnoreCaseTestContext
231
+ {
232
+ Establish context = ( ) =>
233
+ {
234
+ var existingOption =
235
+ CreateOptionWith ( shortName : option . Object . ShortName ) ;
236
+
237
+ SetupExistingParserOptions ( existingOption ) ;
238
+ } ;
239
+
240
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
241
+ }
242
+
243
+ class when_an_existing_option_contains_the_same_long_name_but_it_differs_by_case : IgnoreCaseTestContext
244
+ {
245
+ Establish context = ( ) =>
246
+ {
247
+ var existingOption =
248
+ CreateOptionWith ( longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
249
+
250
+ SetupExistingParserOptions ( existingOption ) ;
251
+ } ;
252
+
253
+ It should_throw_an_error_because_case_is_ignored = ( ) => error . ShouldNotBeNull ( ) ;
254
+ }
255
+
256
+ class when_an_existing_option_contains_the_same_long_name : IgnoreCaseTestContext
257
+ {
258
+ Establish context = ( ) =>
259
+ {
260
+ var existingOption =
261
+ CreateOptionWith ( longName : option . Object . LongName ) ;
262
+
263
+ SetupExistingParserOptions ( existingOption ) ;
264
+ } ;
265
+
266
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
267
+ }
268
+
269
+ class when_an_existing_option_contains_the_same_short_AND_long_name_but_they_differs_by_case : IgnoreCaseTestContext
270
+ {
271
+ Establish context = ( ) =>
272
+ {
273
+ var existingOption =
274
+ CreateOptionWith ( shortName : option . Object . ShortName . ToUpperInvariant ( ) , longName : option . Object . LongName . ToUpperInvariant ( ) ) ;
275
+
276
+ SetupExistingParserOptions ( existingOption ) ;
277
+ } ;
278
+
279
+ It should_throw_an_error_because_case_is_ignored = ( ) => error . ShouldNotBeNull ( ) ;
280
+ }
281
+
282
+ class when_an_existing_option_contains_the_same_short_AND_long_name : IgnoreCaseTestContext
283
+ {
284
+ Establish context = ( ) =>
285
+ {
286
+ var existingOption =
287
+ CreateOptionWith ( shortName : option . Object . ShortName , longName : option . Object . LongName ) ;
288
+
289
+ SetupExistingParserOptions ( existingOption ) ;
290
+ } ;
169
291
170
- It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
292
+ It should_throw_an_error = ( ) => error . ShouldNotBeNull ( ) ;
293
+ }
171
294
}
172
295
}
173
296
}
0 commit comments