@@ -681,5 +681,84 @@ public void HelpWhenPassMoreParametersThanExpected()
681681 ) ;
682682 }
683683
684+ [ Fact ]
685+ public void EnsureThatRightParameterIsReportedForGroups ( )
686+ {
687+ // Invalid option should be in exception text
688+ var commandLine = "Command1 req1 -opt1=value" ;
689+
690+ TestWriter _printer = new TestWriter ( ) ;
691+
692+ var options = Helpers . Parse < Groups1 > ( commandLine , _printer ) ;
693+
694+ Validate ( _printer ,
695+ new TextAndColor ( ConsoleColor . Red , "Error" ) ,
696+ new TextAndColor ( ConsoleColor . Black , $ ": Could not find argument -opt1=value { Environment . NewLine } ") ,
697+ new TextAndColor ( ConsoleColor . Black , "Usage: " ) ,
698+ new TextAndColor ( ConsoleColor . Black , " " ) ,
699+ new TextAndColor ( ConsoleColor . White , "testhost.exe" ) ,
700+ new TextAndColor ( ConsoleColor . Black , " " ) ,
701+ new TextAndColor ( ConsoleColor . Green , "Command1" ) ,
702+ new TextAndColor ( ConsoleColor . Black , " " ) ,
703+ new TextAndColor ( ConsoleColor . Cyan , "p1" ) ,
704+ new TextAndColor ( ConsoleColor . Black , " " ) ,
705+ new TextAndColor ( ConsoleColor . Black , "[-" ) ,
706+ new TextAndColor ( ConsoleColor . Yellow , "opt1" ) ,
707+ new TextAndColor ( ConsoleColor . Black , " value] " ) ,
708+ new TextAndColor ( ConsoleColor . Black , " " ) ,
709+ new TextAndColor ( ConsoleColor . White , "testhost.exe" ) ,
710+ new TextAndColor ( ConsoleColor . Black , " " ) ,
711+ new TextAndColor ( ConsoleColor . Green , "Command2" ) ,
712+ new TextAndColor ( ConsoleColor . Black , " " ) ,
713+ new TextAndColor ( ConsoleColor . Cyan , "opt1" ) ,
714+ new TextAndColor ( ConsoleColor . Black , " " ) ,
715+ new TextAndColor ( ConsoleColor . Black , "[-" ) ,
716+ new TextAndColor ( ConsoleColor . Yellow , "opt1" ) ,
717+ new TextAndColor ( ConsoleColor . Black , " value] " ) ,
718+ new TextAndColor ( ConsoleColor . Black , "For detailed information run '" ) ,
719+ new TextAndColor ( ConsoleColor . White , "testhost --help" ) ,
720+ new TextAndColor ( ConsoleColor . Black , "'." )
721+ ) ;
722+ }
723+
724+ [ Fact ]
725+ public void ErrorWhenNoRequiredParametersInGroupSpecified ( )
726+ {
727+ // Invalid option should be in exception text
728+ var commandLine = "" ;
729+
730+ TestWriter _printer = new TestWriter ( ) ;
731+
732+ var options = Helpers . Parse < Groups1 > ( commandLine , _printer ) ;
733+
734+ Validate ( _printer ,
735+ new TextAndColor ( ConsoleColor . Red , "Error" ) ,
736+ new TextAndColor ( ConsoleColor . Black , $ ": Required parameters have not been specified { Environment . NewLine } ") ,
737+ new TextAndColor ( ConsoleColor . Black , "Usage: " ) ,
738+ new TextAndColor ( ConsoleColor . Black , " " ) ,
739+ new TextAndColor ( ConsoleColor . White , "testhost.exe" ) ,
740+ new TextAndColor ( ConsoleColor . Black , " " ) ,
741+ new TextAndColor ( ConsoleColor . Green , "Command1" ) ,
742+ new TextAndColor ( ConsoleColor . Black , " " ) ,
743+ new TextAndColor ( ConsoleColor . Cyan , "p1" ) ,
744+ new TextAndColor ( ConsoleColor . Black , " " ) ,
745+ new TextAndColor ( ConsoleColor . Black , "[-" ) ,
746+ new TextAndColor ( ConsoleColor . Yellow , "opt1" ) ,
747+ new TextAndColor ( ConsoleColor . Black , " value] " ) ,
748+ new TextAndColor ( ConsoleColor . Black , " " ) ,
749+ new TextAndColor ( ConsoleColor . White , "testhost.exe" ) ,
750+ new TextAndColor ( ConsoleColor . Black , " " ) ,
751+ new TextAndColor ( ConsoleColor . Green , "Command2" ) ,
752+ new TextAndColor ( ConsoleColor . Black , " " ) ,
753+ new TextAndColor ( ConsoleColor . Cyan , "opt1" ) ,
754+ new TextAndColor ( ConsoleColor . Black , " " ) ,
755+ new TextAndColor ( ConsoleColor . Black , "[-" ) ,
756+ new TextAndColor ( ConsoleColor . Yellow , "opt1" ) ,
757+ new TextAndColor ( ConsoleColor . Black , " value] " ) ,
758+ new TextAndColor ( ConsoleColor . Black , "For detailed information run '" ) ,
759+ new TextAndColor ( ConsoleColor . White , "testhost --help" ) ,
760+ new TextAndColor ( ConsoleColor . Black , "'." )
761+ ) ;
762+ }
684763 }
685764}
0 commit comments