11using System ;
22using System . Collections . Generic ;
33using System . Net . Http ;
4+ using System . Threading . Tasks ;
45using APIMatic . Core . Authentication ;
56using APIMatic . Core . Test . MockTypes . Authentication ;
67using APIMatic . Core . Types . Sdk . Exceptions ;
@@ -12,7 +13,7 @@ namespace APIMatic.Core.Test
1213 public class AuthenticationTest : TestBase
1314 {
1415 [ Test ]
15- public void Multiple_Authentication_Success_WithFirstAuth ( )
16+ public async Task Multiple_Authentication_Success_WithFirstAuth ( )
1617 {
1718 var globalConfiguration = new GlobalConfiguration . Builder ( )
1819 . ServerUrls ( new Dictionary < Enum , string >
@@ -28,7 +29,7 @@ public void Multiple_Authentication_Success_WithFirstAuth()
2829 . HttpConfiguration ( _clientConfiguration )
2930 . Build ( ) ;
3031
31- var request = globalConfiguration . GlobalRequestBuilder ( )
32+ var request = await globalConfiguration . GlobalRequestBuilder ( )
3233 . Setup ( HttpMethod . Get , "/auth" )
3334 . WithOrAuth ( auth => auth
3435 . AddAndGroup ( innerGroup => innerGroup
@@ -45,7 +46,7 @@ public void Multiple_Authentication_Success_WithFirstAuth()
4546 }
4647
4748 [ Test ]
48- public void Multiple_Authentication_Success_WithSecondAuth ( )
49+ public async Task Multiple_Authentication_Success_WithSecondAuth ( )
4950 {
5051 var basicAuthManager = new BasicAuthManager ( "username" , "password" ) ;
5152 var globalConfiguration = new GlobalConfiguration . Builder ( )
@@ -62,7 +63,7 @@ public void Multiple_Authentication_Success_WithSecondAuth()
6263 . HttpConfiguration ( _clientConfiguration )
6364 . Build ( ) ;
6465
65- var request = globalConfiguration . GlobalRequestBuilder ( )
66+ var request = await globalConfiguration . GlobalRequestBuilder ( )
6667 . Setup ( HttpMethod . Get , "/auth" )
6768 . WithOrAuth ( auth => auth
6869 . AddAndGroup ( innerGroup => innerGroup
@@ -95,7 +96,7 @@ public void Multiple_Authentication_OR_Validation_Failure()
9596 . HttpConfiguration ( _clientConfiguration )
9697 . Build ( ) ;
9798
98- var exp = Assert . Throws < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
99+ var exp = Assert . ThrowsAsync < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
99100 . Setup ( HttpMethod . Get , "/auth" )
100101 . WithOrAuth ( auth => auth
101102 . Add ( "basic" )
@@ -110,7 +111,7 @@ public void Multiple_Authentication_OR_Validation_Failure()
110111 }
111112
112113 [ Test ]
113- public void Multiple_Authentication_AND_Validation_Failure ( )
114+ public async Task Multiple_Authentication_AND_Validation_Failure ( )
114115 {
115116 var globalConfiguration = new GlobalConfiguration . Builder ( )
116117 . ServerUrls ( new Dictionary < Enum , string >
@@ -126,15 +127,24 @@ public void Multiple_Authentication_AND_Validation_Failure()
126127 . HttpConfiguration ( _clientConfiguration )
127128 . Build ( ) ;
128129
129- var exp = Assert . Throws < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
130+
131+ var exp = Assert . ThrowsAsync < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
130132 . Setup ( HttpMethod . Get , "/auth" )
131- . WithAndAuth ( auth => auth
132- . Add ( "query" )
133+ . WithAndAuth ( auth => auth . Add ( "query" )
133134 . Add ( "header" ) )
134135 . Build ( ) ) ;
135136
136137 Assert . AreEqual ( "Following authentication credentials are required:\n " +
137138 "-> Missing required header field: TOKEN" , exp . Message ) ;
139+
140+ async void AuthCode ( )
141+ {
142+ await globalConfiguration . GlobalRequestBuilder ( )
143+ . Setup ( HttpMethod . Get , "/auth" )
144+ . WithAndAuth ( auth => auth . Add ( "query" )
145+ . Add ( "header" ) )
146+ . Build ( ) ;
147+ }
138148 }
139149
140150 [ Test ]
@@ -153,7 +163,7 @@ public void Multiple_Authentication_AND_All_Missing_Validation_Failure()
153163 . HttpConfiguration ( _clientConfiguration )
154164 . Build ( ) ;
155165
156- var exp = Assert . Throws < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
166+ var exp = Assert . ThrowsAsync < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
157167 . Setup ( HttpMethod . Get , "/auth" )
158168 . WithAndAuth ( auth => auth
159169 . Add ( "query" )
@@ -184,7 +194,7 @@ public void Multiple_Authentication_AND_with_nested_OR_Validation_Failure()
184194 . HttpConfiguration ( _clientConfiguration )
185195 . Build ( ) ;
186196
187- var exp = Assert . Throws < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
197+ var exp = Assert . ThrowsAsync < AuthValidationException > ( ( ) => globalConfiguration . GlobalRequestBuilder ( )
188198 . Setup ( HttpMethod . Get , "/auth" )
189199 . WithAndAuth ( auth => auth
190200 . Add ( "query" )
0 commit comments