1- using System ;
1+ using CommandLine . ColorScheme ;
2+ using System ;
23using System . Collections . Generic ;
34using System . Reflection ;
4- using CommandLine . ColorScheme ;
55using Xunit ;
6- using Xunit . Extensions ;
76
87namespace CommandLine . Tests
98{
@@ -25,7 +24,7 @@ private void Validate(TestWriter _printer, params TextAndColor[] values)
2524 public void HelpTest1 ( IColors color )
2625 {
2726 TestWriter _printer = new TestWriter ( ) ;
28- var options = Helpers . Parse < Options3NoRequired > ( "-?" , _printer , color ) ;
27+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "-?" , _printer , color ) ) ;
2928
3029 Validate ( _printer ,
3130 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -79,8 +78,7 @@ public void HelpTestViaApi1(IColors color)
7978 public void HelpTest4 ( IColors color )
8079 {
8180 TestWriter _printer = new TestWriter ( ) ;
82-
83- var options = Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color ) ;
81+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color ) ) ;
8482
8583 Validate ( _printer ,
8684 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -107,7 +105,7 @@ public void HelpTest4(IColors color)
107105 public void HelpTest2 ( IColors color )
108106 {
109107 TestWriter _printer = new TestWriter ( ) ;
110- var options = Helpers . Parse < Options3NoRequired > ( "-?" , _printer , color ) ;
108+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "-?" , _printer , color ) ) ;
111109
112110 Validate ( _printer ,
113111 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -135,7 +133,7 @@ public void HelpTest2(IColors color)
135133 public void HelpTest3 ( IColors color )
136134 {
137135 TestWriter _printer = new TestWriter ( ) ;
138- var options = Helpers . Parse < OptionsNegative1 > ( "-?" , _printer , color ) ;
136+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < OptionsNegative1 > ( "-?" , _printer , color ) ) ;
139137
140138 Validate ( _printer ,
141139 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -157,7 +155,7 @@ public void HelpTest3(IColors color)
157155 public void DetailedHelp1 ( IColors color )
158156 {
159157 TestWriter _printer = new TestWriter ( ) ;
160- var options = Helpers . Parse < Options1 > ( "--help" , _printer , color ) ;
158+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options1 > ( "--help" , _printer , color ) ) ;
161159
162160 Validate ( _printer ,
163161 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -229,7 +227,7 @@ public void DetailedHelp1(IColors color)
229227 public void DetailedHelp2 ( IColors color )
230228 {
231229 TestWriter _printer = new TestWriter ( ) ;
232- var options = Helpers . Parse < Options3NoRequired > ( "--help" , _printer , color ) ;
230+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "--help" , _printer , color ) ) ;
233231
234232 Validate ( _printer ,
235233 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -345,7 +343,7 @@ public void DetailedHelpViaApi1(IColors color)
345343 public void DetailedHelpForGroups1 ( IColors color )
346344 {
347345 TestWriter _printer = new TestWriter ( ) ;
348- var options = Helpers . Parse < Groups1 > ( "--help" , _printer , color ) ;
346+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Groups1 > ( "--help" , _printer , color ) ) ;
349347
350348 Validate ( _printer ,
351349 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -477,7 +475,7 @@ public void HelpForCommandWithSlashQuestionMark(IColors color)
477475 public void HelpForTypeWithEnum ( IColors color )
478476 {
479477 TestWriter _printer = new TestWriter ( ) ;
480- var options = Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color ) ;
478+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color ) ) ;
481479
482480 Validate ( _printer ,
483481 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -506,7 +504,7 @@ public void HelpForTypeWithEnumWithNoHelpSettingSet(IColors color)
506504 // the help is not covered by the error flag.
507505 ParserOptions po = new ParserOptions ( ) { LogParseErrorToConsole = false } ;
508506 TestWriter _printer = new TestWriter ( ) ;
509- var options = Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color , po ) ;
507+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Options3NoRequired > ( "/?" , _printer , color , po ) ) ;
510508
511509 Validate ( _printer ,
512510 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -533,7 +531,7 @@ public void HelpForTypeWithEnumWithNoHelpSettingSet(IColors color)
533531 public void DetailedHelpForGroups2WithCommonArgs ( IColors color )
534532 {
535533 TestWriter _printer = new TestWriter ( ) ;
536- var options = Helpers . Parse < Groups2 > ( "--help" , _printer , color ) ;
534+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < Groups2 > ( "--help" , _printer , color ) ) ;
537535
538536 Validate ( _printer ,
539537 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
@@ -628,7 +626,7 @@ public void InvalidHelpFormat()
628626 public void HelpForTypeWithRequiredAndOptionalEnumsAndLists ( IColors color )
629627 {
630628 TestWriter _printer = new TestWriter ( ) ;
631- var options = Helpers . Parse < HelpGeneratorObject > ( "--help" , _printer , color ) ;
629+ var options = Assert . Throws < HelpRequestedException > ( ( ) => Helpers . Parse < HelpGeneratorObject > ( "--help" , _printer , color ) ) ;
632630
633631 Validate ( _printer ,
634632 new TextAndColor ( _printer . ForegroundColor , "Usage: " ) ,
0 commit comments