11using AtleX . CommandLineArguments . Tests . Mocks ;
22using NUnit . Framework ;
33using System ;
4- using AtleX . CommandLineArguments . Validators ;
5- using System . Collections . Generic ;
64
75namespace AtleX . CommandLineArguments . Tests
86{
@@ -12,15 +10,33 @@ public class CommandLineArgumentsTests
1210 [ Test ]
1311 public void TryParse_ArgumentsNull_Throws ( )
1412 {
15- Assert . Throws < ArgumentNullException > ( ( ) => CommandLineArguments . TryParse < TestArguments > ( null , out TestArguments a ) ) ;
13+ Assert . Throws < ArgumentNullException > ( ( ) => CommandLineArguments . TryParse < TestArguments > ( null , out _ ) ) ;
1614 }
1715
1816 [ Test ]
1917 public void TryParse_WithoutConfiguration_Throws ( )
2018 {
19+ var oldConfig = CommandLineArguments . Configuration ;
20+
2121 CommandLineArguments . Configuration = null ;
2222
23- Assert . Throws < InvalidOperationException > ( ( ) => CommandLineArguments . TryParse < TestArguments > ( new string [ 0 ] , out TestArguments a ) ) ;
23+ Assert . Throws < InvalidOperationException > ( ( ) => CommandLineArguments . TryParse < TestArguments > ( new string [ 0 ] , out _ ) ) ;
24+
25+ CommandLineArguments . Configuration = oldConfig ; // The beauty of static, we need to restore the configuration
26+ }
27+
28+ [ Test ]
29+ public void TryParse_WithEmptyArgumentsAndDefaultConfiguration_Succeeds ( )
30+ {
31+ Assert . DoesNotThrow ( ( ) => CommandLineArguments . TryParse < TestArguments > ( new string [ 0 ] , out _ ) ) ;
32+ }
33+
34+ [ Test ]
35+ public void TryParse_WithUnknownArgumentsAndDefaultConfiguration_Succeeds ( )
36+ {
37+ var cliArgs = new string [ ] { "lorem" , "ipsum" } ;
38+
39+ Assert . DoesNotThrow ( ( ) => CommandLineArguments . TryParse < TestArguments > ( cliArgs , out _ ) ) ;
2440 }
2541 }
2642}
0 commit comments