@@ -301,7 +301,8 @@ public async Task Handler_method_receives_option_arguments_bound_to_the_specifie
301
301
} ;
302
302
command . Handler = handler ;
303
303
304
- var parseResult = command . Parse ( $ "--value { testCase . CommandLine } ") ;
304
+ var commandLine = string . Join ( " " , testCase . CommandLineTokens . Select ( t => $ "--value { t } ") ) ;
305
+ var parseResult = command . Parse ( commandLine ) ;
305
306
306
307
var invocationContext = new InvocationContext ( parseResult ) ;
307
308
@@ -350,11 +351,11 @@ public async Task When_binding_fails_due_to_parameter_naming_mismatch_then_handl
350
351
public async Task Handler_method_receives_command_arguments_bound_to_the_specified_type (
351
352
Type type )
352
353
{
353
- var c = BindingCases [ type ] ;
354
+ var testCase = BindingCases [ type ] ;
354
355
355
356
var captureMethod = GetType ( )
356
357
. GetMethod ( nameof ( CaptureMethod ) , BindingFlags . NonPublic | BindingFlags . Static )
357
- . MakeGenericMethod ( c . ParameterType ) ;
358
+ . MakeGenericMethod ( testCase . ParameterType ) ;
358
359
359
360
var handler = CommandHandler . Create ( captureMethod ) ;
360
361
@@ -364,22 +365,23 @@ public async Task Handler_method_receives_command_arguments_bound_to_the_specifi
364
365
new Argument
365
366
{
366
367
Name = "value" ,
367
- ArgumentType = c . ParameterType
368
+ ArgumentType = testCase . ParameterType
368
369
}
369
370
} ;
370
371
command . Handler = handler ;
371
372
372
- var parseResult = command . Parse ( c . CommandLine ) ;
373
+ var commandLine = string . Join ( " " , testCase . CommandLineTokens ) ;
374
+ var parseResult = command . Parse ( commandLine ) ;
373
375
374
376
var invocationContext = new InvocationContext ( parseResult ) ;
375
377
376
378
await handler . InvokeAsync ( invocationContext ) ;
377
379
378
380
var boundValue = ( ( BoundValueCapturer ) invocationContext . InvocationResult ) . BoundValue ;
379
381
380
- boundValue . Should ( ) . BeOfType ( c . ParameterType ) ;
382
+ boundValue . Should ( ) . BeOfType ( testCase . ParameterType ) ;
381
383
382
- c . AssertBoundValue ( boundValue ) ;
384
+ testCase . AssertBoundValue ( boundValue ) ;
383
385
}
384
386
385
387
[ Theory ]
@@ -398,19 +400,19 @@ public async Task Handler_method_receives_command_arguments_bound_to_the_specifi
398
400
public async Task Handler_method_receives_command_arguments_explicitly_bound_to_the_specified_type (
399
401
Type type )
400
402
{
401
- var c = BindingCases [ type ] ;
403
+ var testCase = BindingCases [ type ] ;
402
404
403
405
var captureMethod = GetType ( )
404
406
. GetMethod ( nameof ( CaptureMethod ) , BindingFlags . NonPublic | BindingFlags . Static )
405
- . MakeGenericMethod ( c . ParameterType ) ;
407
+ . MakeGenericMethod ( testCase . ParameterType ) ;
406
408
var parameter = captureMethod . GetParameters ( ) [ 0 ] ;
407
409
408
410
var handler = CommandHandler . Create ( captureMethod ) ;
409
411
410
412
var argument = new Argument
411
413
{
412
414
Name = "value" ,
413
- ArgumentType = c . ParameterType
415
+ ArgumentType = testCase . ParameterType
414
416
} ;
415
417
416
418
var command = new Command (
@@ -425,17 +427,18 @@ public async Task Handler_method_receives_command_arguments_explicitly_bound_to_
425
427
bindingHandler . BindParameter ( parameter , argument ) ;
426
428
command . Handler = handler ;
427
429
428
- var parseResult = command . Parse ( c . CommandLine ) ;
430
+ var commandLine = string . Join ( " " , testCase . CommandLineTokens ) ;
431
+ var parseResult = command . Parse ( commandLine ) ;
429
432
430
433
var invocationContext = new InvocationContext ( parseResult ) ;
431
434
432
435
await handler . InvokeAsync ( invocationContext ) ;
433
436
434
437
var boundValue = ( ( BoundValueCapturer ) invocationContext . InvocationResult ) . BoundValue ;
435
438
436
- boundValue . Should ( ) . BeOfType ( c . ParameterType ) ;
439
+ boundValue . Should ( ) . BeOfType ( testCase . ParameterType ) ;
437
440
438
- c . AssertBoundValue ( boundValue ) ;
441
+ testCase . AssertBoundValue ( boundValue ) ;
439
442
}
440
443
441
444
[ Theory ]
@@ -455,16 +458,16 @@ public async Task Handler_method_receives_command_arguments_explicitly_bound_to_
455
458
public async Task Handler_method_receive_option_arguments_explicitly_bound_to_the_specified_type (
456
459
Type type )
457
460
{
458
- var c = BindingCases [ type ] ;
461
+ var testCase = BindingCases [ type ] ;
459
462
460
463
var captureMethod = GetType ( )
461
464
. GetMethod ( nameof ( CaptureMethod ) , BindingFlags . NonPublic | BindingFlags . Static )
462
- . MakeGenericMethod ( c . ParameterType ) ;
465
+ . MakeGenericMethod ( testCase . ParameterType ) ;
463
466
var parameter = captureMethod . GetParameters ( ) [ 0 ] ;
464
467
465
468
var handler = CommandHandler . Create ( captureMethod ) ;
466
469
467
- var option = new Option ( "--value" , argumentType : c . ParameterType ) ;
470
+ var option = new Option ( "--value" , argumentType : testCase . ParameterType ) ;
468
471
469
472
var command = new Command ( "command" )
470
473
{
@@ -477,7 +480,7 @@ public async Task Handler_method_receive_option_arguments_explicitly_bound_to_th
477
480
bindingHandler . BindParameter ( parameter , option ) ;
478
481
command . Handler = handler ;
479
482
480
- var commandLine = $ "--value { c . CommandLine } " ;
483
+ var commandLine = string . Join ( " " , testCase . CommandLineTokens . Select ( t => $ "--value { t } " ) ) ;
481
484
var parseResult = command . Parse ( commandLine ) ;
482
485
483
486
var invocationContext = new InvocationContext ( parseResult ) ;
@@ -486,9 +489,9 @@ public async Task Handler_method_receive_option_arguments_explicitly_bound_to_th
486
489
487
490
var boundValue = ( ( BoundValueCapturer ) invocationContext . InvocationResult ) . BoundValue ;
488
491
489
- boundValue . Should ( ) . BeOfType ( c . ParameterType ) ;
492
+ boundValue . Should ( ) . BeOfType ( testCase . ParameterType ) ;
490
493
491
- c . AssertBoundValue ( boundValue ) ;
494
+ testCase . AssertBoundValue ( boundValue ) ;
492
495
}
493
496
494
497
private static void CaptureMethod < T > ( T value , InvocationContext invocationContext )
@@ -550,7 +553,10 @@ public void Apply(InvocationContext context)
550
553
. Be ( Path . Combine ( ExistingDirectory ( ) , "file1.txt" ) ) ) ,
551
554
552
555
BindingTestCase . Create < FileInfo [ ] > (
553
- $ "{ Path . Combine ( ExistingDirectory ( ) , "file1.txt" ) } { Path . Combine ( ExistingDirectory ( ) , "file2.txt" ) } ",
556
+ new [ ] {
557
+ Path . Combine ( ExistingDirectory ( ) , "file1.txt" ) ,
558
+ Path . Combine ( ExistingDirectory ( ) , "file2.txt" )
559
+ } ,
554
560
o => o . Select ( f => f . FullName )
555
561
. Should ( )
556
562
. BeEquivalentTo ( new [ ]
@@ -569,17 +575,17 @@ public void Apply(InvocationContext context)
569
575
. Be ( ExistingDirectory ( ) ) ) ,
570
576
571
577
BindingTestCase . Create < DirectoryInfo [ ] > (
572
- $ " { ExistingDirectory ( ) } { ExistingDirectory ( ) } " ,
578
+ new [ ] { ExistingDirectory ( ) , ExistingDirectory ( ) } ,
573
579
fsi => fsi . Should ( )
574
- . BeAssignableTo < IEnumerable < DirectoryInfo > > ( )
575
- . Which
576
- . Select ( d => d . FullName )
577
- . Should ( )
578
- . BeEquivalentTo ( new [ ]
579
- {
580
- ExistingDirectory ( ) ,
581
- ExistingDirectory ( )
582
- } ) ) ,
580
+ . BeAssignableTo < IEnumerable < DirectoryInfo > > ( )
581
+ . Which
582
+ . Select ( d => d . FullName )
583
+ . Should ( )
584
+ . BeEquivalentTo ( new [ ]
585
+ {
586
+ ExistingDirectory ( ) ,
587
+ ExistingDirectory ( )
588
+ } ) ) ,
583
589
584
590
BindingTestCase . Create < FileSystemInfo > (
585
591
ExistingFile ( ) ,
@@ -633,19 +639,19 @@ public void Apply(InvocationContext context)
633
639
variationName : nameof ( NonexistentPathWithoutTrailingSlash ) ) ,
634
640
635
641
BindingTestCase . Create < string [ ] > (
636
- "one two" ,
642
+ new [ ] { "one" , " two" } ,
637
643
o => o . Should ( ) . BeEquivalentTo ( new [ ] { "one" , "two" } ) ) ,
638
644
639
645
BindingTestCase . Create < List < string > > (
640
- "one two" ,
646
+ new [ ] { "one" , " two" } ,
641
647
o => o . Should ( ) . BeEquivalentTo ( new List < string > { "one" , "two" } ) ) ,
642
648
643
649
BindingTestCase . Create < int [ ] > (
644
- "1 2" ,
650
+ new [ ] { "1" , "2" } ,
645
651
o => o . Should ( ) . BeEquivalentTo ( new [ ] { 1 , 2 } ) ) ,
646
652
647
653
BindingTestCase . Create < List < int > > (
648
- "1 2" ,
654
+ new [ ] { "1" , "2" } ,
649
655
o => o . Should ( ) . BeEquivalentTo ( new List < int > { 1 , 2 } ) )
650
656
} ;
651
657
0 commit comments