@@ -19,15 +19,15 @@ public override KeyValuePair<string, string> Convert(string str)
1919 }
2020 }
2121
22- public record Options ( KeyValuePair < string , string > [ ] Properties , string ? LogLevel ) ;
22+ public record Options ( KeyValuePair < string , string > [ ] Properties , string ? LogLevel , bool Test ) ;
2323
2424 [ Fact ]
25- public void Bind_Argument_Text_Returns_Expected ( )
25+ public void Bind_Option_Argument_Text_Returns_Expected ( )
2626 {
2727 var app = new CliApplicationBuilder ( "test" )
2828 . AddConverters ( [ new KeyValuePairConverter ( ) ] )
2929 . MapModel < Options > ( map => map . Option ( x => x . Properties , [ "--watermark" ] , Arity . ZeroOrMany ) )
30- . Route < Options > ( "test" , opt => 0 )
30+ . Route < Options > ( "test" , _ => 0 )
3131 . Build ( ) ;
3232
3333 var context = CliEngine . GetBindingContext ( app , [ "--watermark" , "id=value" ] ) ;
@@ -38,12 +38,12 @@ public void Bind_Argument_Text_Returns_Expected()
3838 }
3939
4040 [ Fact ]
41- public void Bind_Operand_Value_Returns_Expected ( )
41+ public void Bind_Option_Operand_Value_Returns_Expected ( )
4242 {
4343 var app = new CliApplicationBuilder ( "test" )
4444 . AddConverters ( [ new StringConverter ( ) ] )
4545 . MapModel < Options > ( map => map . Option ( x => x . LogLevel , [ "--level" ] ) )
46- . Route < Options > ( "test" , opt => 0 )
46+ . Route < Options > ( "test" , _ => 0 )
4747 . Build ( ) ;
4848
4949 CliEngine
@@ -61,4 +61,18 @@ public void Bind_Operand_Value_Returns_Expected()
6161 . GetValue < string ? > ( nameof ( Options . LogLevel ) )
6262 . ShouldBe ( "debug" ) ;
6363 }
64+
65+ [ Fact ]
66+ public void Bind_Switch_Returns_Expected ( )
67+ {
68+ var app = new CliApplicationBuilder ( "test" )
69+ . AddConverters ( [ new ParsableConverter < bool > ( ) ] )
70+ . MapModel < Options > ( map => map . Switch ( x => x . Test , [ "--test" ] ) )
71+ . Route < Options > ( "test" , _ => 0 )
72+ . Build ( ) ;
73+
74+ CliEngine . GetBindingContext ( app , [ "--test" ] )
75+ . GetValue < bool > ( nameof ( Options . Test ) )
76+ . ShouldBeTrue ( ) ;
77+ }
6478}
0 commit comments