@@ -29,40 +29,37 @@ public NetInfoTests()
2929 } ;
3030 }
3131
32- [ Fact ]
33- public void CtorGuardClauses ( )
32+ public class Constructor : NetInfoTests
3433 {
35- Assert . Throws < ArgumentNullException > ( "httpClientFactory" , ( ) => new NetInfo ( null ! , logger , Options . Create ( options ) ) ) ;
36- Assert . Throws < ArgumentNullException > ( "logger" , ( ) => new NetInfo ( httpClientFactory , null ! , Options . Create ( options ) ) ) ;
37- Assert . Throws < ArgumentNullException > ( "options" , ( ) => new NetInfo ( httpClientFactory , logger , null ! ) ) ;
34+ [ Fact ]
35+ public void GuardClauses ( )
36+ {
37+ Assert . Throws < ArgumentNullException > ( "httpClientFactory" , ( ) => new NetInfo ( null ! , logger , Options . Create ( options ) ) ) ;
38+ Assert . Throws < ArgumentNullException > ( "logger" , ( ) => new NetInfo ( httpClientFactory , null ! , Options . Create ( options ) ) ) ;
39+ Assert . Throws < ArgumentNullException > ( "options" , ( ) => new NetInfo ( httpClientFactory , logger , null ! ) ) ;
3840
39- options . ApiKey = null ;
40- var argEx = Assert . Throws < ApiKeyException > ( ( ) => new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ) ;
41- Assert . Equal ( "API key is required. Please provide it via options or set the HYPHEN_API_KEY environment variable." , argEx . Message ) ;
41+ options . ApiKey = null ;
4242
43- options . ApiKey = "public_abc123" ;
44- argEx = Assert . Throws < ApiKeyException > ( ( ) => new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ) ;
45- Assert . Equal ( "The provided API key is a public API key. Please provide a valid non public API key for authentication." , argEx . Message ) ;
46- }
43+ var ex1 = Assert . Throws < ApiKeyException > ( ( ) => new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ) ;
44+ Assert . Equal ( "API key is required. Please provide it via options or set the HYPHEN_API_KEY environment variable." , ex1 . Message ) ;
4745
48- [ Fact ]
49- public async ValueTask GuardClauses ( )
50- {
51- var netInfo = new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ;
46+ options . ApiKey = "public_abc123" ;
5247
53- await Assert . ThrowsAsync < ArgumentNullException > ( "ips" , ( ) => netInfo . GetIPInfos ( null ! , TestContext . Current . CancellationToken ) . AsTask ( ) ) ;
54- }
48+ var ex2 = Assert . Throws < ApiKeyException > ( ( ) => new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ) ;
49+ Assert . Equal ( "The provided API key is a public API key. Please provide a valid non public API key for authentication." , ex2 . Message ) ;
50+ }
5551
56- [ Theory ]
57- [ InlineData ( "false" , "https://net.info/" ) ]
58- [ InlineData ( "true" , "https://dev.net.info/" ) ]
59- public void UsesDefaultBaseUri ( string hyphenDevValue , string expectedUri )
60- {
61- Environment . SetEnvironmentVariable ( Env . Dev , hyphenDevValue ) ;
52+ [ Theory ]
53+ [ InlineData ( "false" , "https://net.info/" ) ]
54+ [ InlineData ( "true" , "https://dev.net.info/" ) ]
55+ public void UsesDefaultBaseUri ( string hyphenDevValue , string expectedUri )
56+ {
57+ Environment . SetEnvironmentVariable ( Env . Dev , hyphenDevValue ) ;
6258
63- var netInfo = new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ;
59+ var netInfo = new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ;
6460
65- Assert . Equal ( expectedUri , netInfo . BaseUri . ToString ( ) ) ;
61+ Assert . Equal ( expectedUri , netInfo . BaseUri . ToString ( ) ) ;
62+ }
6663 }
6764
6865 public class CurrentIP : NetInfoTests
@@ -225,6 +222,14 @@ public async ValueTask Throws()
225222
226223 public class MultipleIPs : NetInfoTests
227224 {
225+ [ Fact ]
226+ public async ValueTask GuardClause ( )
227+ {
228+ var netInfo = new NetInfo ( httpClientFactory , logger , Options . Create ( options ) ) ;
229+
230+ await Assert . ThrowsAsync < ArgumentNullException > ( "ips" , ( ) => netInfo . GetIPInfos ( null ! , TestContext . Current . CancellationToken ) . AsTask ( ) ) ;
231+ }
232+
228233 [ Fact ]
229234 public async ValueTask Returns200 ( )
230235 {
0 commit comments