@@ -33,15 +33,15 @@ public void CompareCommand_ShouldHave_FormatsOption()
3333 formatsOption . Aliases . Count . ShouldBe ( 1 ) ;
3434 formatsOption . Aliases . ShouldContain ( "-f" ) ;
3535 formatsOption . Description . ShouldBe ( "Output format for the report." ) ;
36+ ( formatsOption . GetDefaultValue ( ) as string [ ] ) . ShouldBe ( [ "console" ] ) ;
3637 }
3738
3839 [ Theory ]
39- [ InlineData ( "markdown" , true ) ]
40- [ InlineData ( "jSOn" , true ) ]
41- [ InlineData ( "HIT-TXT" , true ) ]
42- [ InlineData ( "console" , true ) ]
43- [ InlineData ( "invalid-format" , false ) ]
44- public void Test_Validation_Format_Option ( string format , bool isValid )
40+ [ InlineData ( "markdown" ) ]
41+ [ InlineData ( "jSOn" ) ]
42+ [ InlineData ( "HIT-TXT" ) ]
43+ [ InlineData ( "console" ) ]
44+ public void When_Format_Is_Valid_Shouldnt_Have_Validation_Error ( string format )
4545 {
4646 // Arrange
4747 var command = "compare" ;
@@ -58,6 +58,31 @@ public void Test_Validation_Format_Option(string format, bool isValid)
5858 var firstOptionResult = parseResult . GetResult ( formatsOption ) ;
5959
6060 // Assert
61- firstOptionResult ? . Errors . Count ( ) . ShouldBe ( isValid ? 0 : 1 ) ;
61+ firstOptionResult ? . Errors . Count ( ) . ShouldBe ( 0 ) ;
62+ }
63+
64+ [ Theory ]
65+ [ InlineData ( "invalid-format" ) ]
66+ [ InlineData ( "csv" ) ]
67+ [ InlineData ( "html" ) ]
68+ public void When_Format_Is_Invalid_Should_Have_Validation_Error ( string ? format )
69+ {
70+ // Arrange
71+ var command = "compare" ;
72+ var option = "--format" ;
73+
74+ var toolCommands = new ToolCommands ( _provider ) ;
75+ var compareCommand = toolCommands . Subcommands . Single ( c => c . Name == command ) ;
76+ var formatsOption = compareCommand . Options . Single ( o => o . Name == option ) ;
77+ var validation = formatsOption . Validators . Single ( ) ;
78+
79+
80+ // Act
81+ var parseResult = toolCommands . Parse ( $ "{ command } { option } { format } ") ;
82+ var firstOptionResult = parseResult . GetResult ( formatsOption ) ;
83+
84+ // Assert
85+ firstOptionResult ? . Errors . Count ( ) . ShouldBe ( 1 ) ;
86+ firstOptionResult ? . Errors . ShouldContain ( e => e . Message == $ "Invalid format '{ format } '. Allowed values: console, markdown, json, hit-txt") ;
6287 }
6388}
0 commit comments