@@ -709,6 +709,95 @@ public void RunOptions_Success_ListFloatParameter () {
709709 Assert . Equal ( new List < float > { 100.0f , 100.1f , 100.2f , 100.3f , 100.4f , 100.5f } , result . Parameter3 ) ;
710710 }
711711
712+ public record RunOptions_Success_StringParameter_Class {
713+ public string Parameter1 { get ; set ; } = "" ;
714+ public string Parameter2 { get ; set ; } = "" ;
715+ public string Parameter3 { get ; set ; } = "" ;
716+ }
717+
718+ [ Fact ]
719+ public void RunOptions_Success_StringParameter ( ) {
720+ //arrange
721+ var messages = new List < string > ( ) ;
722+ var fakeProvider = A . Fake < ICommandLineProvider > ( ) ;
723+ A . CallTo ( ( ) => fakeProvider . GetCommandLine ( ) ) . Returns ( "--parameter1=argus --parameter2=test values with spaces --parameter3=\" quotes string with spaces\" " ) ;
724+ A . CallTo ( ( ) => fakeProvider . WriteLine ( A < string > . _ ) ) . Invokes ( ( string fake ) => { messages . Add ( fake ) ; } ) ;
725+ var commandLine = new CommandLine ( fakeProvider ) ;
726+
727+ //act
728+ var result = commandLine
729+ . Application ( "TestApplication" , "1.0.0" )
730+ . AddOption ( fullName : "Parameter1" )
731+ . AddOption ( fullName : "Parameter2" )
732+ . AddOption ( fullName : "Parameter3" )
733+ . RunOptions < RunOptions_Success_StringParameter_Class > ( ) ;
734+
735+ //assert
736+ Assert . NotNull ( result ) ;
737+ Assert . Equal ( "argus" , result . Parameter1 ) ;
738+ Assert . Equal ( "test values with spaces" , result . Parameter2 ) ;
739+ Assert . Equal ( "quotes string with spaces" , result . Parameter3 ) ;
740+ }
741+
742+ public record RunOptions_Success_IEnumerableStringParameter_Class {
743+ public IEnumerable < string > Parameter1 { get ; set ; } = Enumerable . Empty < string > ( ) ;
744+ public IEnumerable < string > Parameter2 { get ; set ; } = Enumerable . Empty < string > ( ) ;
745+ public IEnumerable < string > Parameter3 { get ; set ; } = Enumerable . Empty < string > ( ) ;
746+ }
747+
748+ [ Fact ]
749+ public void RunOptions_Success_IEnumerableStringParameter ( ) {
750+ //arrange
751+ var messages = new List < string > ( ) ;
752+ var fakeProvider = A . Fake < ICommandLineProvider > ( ) ;
753+ A . CallTo ( ( ) => fakeProvider . GetCommandLine ( ) ) . Returns ( "--parameter1=argus bargus margus --parameter2=test values with spaces --parameter3=first1212121 \" quotes string with spaces\" last4534534" ) ;
754+ A . CallTo ( ( ) => fakeProvider . WriteLine ( A < string > . _ ) ) . Invokes ( ( string fake ) => { messages . Add ( fake ) ; } ) ;
755+ var commandLine = new CommandLine ( fakeProvider ) ;
756+
757+ //act
758+ var result = commandLine
759+ . Application ( "TestApplication" , "1.0.0" )
760+ . AddOption ( fullName : "Parameter1" )
761+ . AddOption ( fullName : "Parameter2" )
762+ . AddOption ( fullName : "Parameter3" )
763+ . RunOptions < RunOptions_Success_IEnumerableStringParameter_Class > ( ) ;
764+
765+ //assert
766+ Assert . NotNull ( result ) ;
767+ Assert . Equal ( new List < string > { "argus" , "bargus" , "margus" } , result . Parameter1 ) ;
768+ Assert . Equal ( new List < string > { "test" , "values" , "with" , "spaces" } , result . Parameter2 ) ;
769+ Assert . Equal ( new List < string > { "first1212121" , "quotes string with spaces" , "last4534534" } , result . Parameter3 ) ;
770+ }
771+
772+ public record RunOptions_Success_ListStringParameter_Class {
773+ public List < string > Parameter1 { get ; set ; } = Enumerable . Empty < string > ( ) . ToList ( ) ;
774+ public List < string > Parameter2 { get ; set ; } = Enumerable . Empty < string > ( ) . ToList ( ) ;
775+ public List < string > Parameter3 { get ; set ; } = Enumerable . Empty < string > ( ) . ToList ( ) ;
776+ }
777+
778+ [ Fact ]
779+ public void RunOptions_Success_ListStringParameter ( ) {
780+ //arrange
781+ var messages = new List < string > ( ) ;
782+ var fakeProvider = A . Fake < ICommandLineProvider > ( ) ;
783+ A . CallTo ( ( ) => fakeProvider . GetCommandLine ( ) ) . Returns ( "--parameter1=argus bargus margus --parameter2=test values with spaces --parameter3=first1212121 \" quotes string with spaces\" last4534534" ) ;
784+ A . CallTo ( ( ) => fakeProvider . WriteLine ( A < string > . _ ) ) . Invokes ( ( string fake ) => { messages . Add ( fake ) ; } ) ;
785+ var commandLine = new CommandLine ( fakeProvider ) ;
786+
787+ //act
788+ var result = commandLine
789+ . Application ( "TestApplication" , "1.0.0" )
790+ . AddOption ( fullName : "Parameter1" )
791+ . AddOption ( fullName : "Parameter2" )
792+ . AddOption ( fullName : "Parameter3" )
793+ . RunOptions < RunOptions_Success_ListStringParameter_Class > ( ) ;
794+
795+ //assert
796+ Assert . NotNull ( result ) ;
797+ Assert . Equal ( new List < string > { "argus" , "bargus" , "margus" } , result . Parameter1 ) ;
798+ Assert . Equal ( new List < string > { "test" , "values" , "with" , "spaces" } , result . Parameter2 ) ;
799+ Assert . Equal ( new List < string > { "first1212121" , "quotes string with spaces" , "last4534534" } , result . Parameter3 ) ;
800+ }
712801
713802 }
714803
0 commit comments