@@ -19,10 +19,16 @@ namespace Microsoft.Graph.DotnetCore.Core.Test.Requests
19
19
public class GraphClientFactoryTests : IDisposable
20
20
{
21
21
private MockRedirectHandler testHttpMessageHandler ;
22
+ private DelegatingHandler [ ] handlers ;
22
23
23
24
public GraphClientFactoryTests ( )
24
25
{
25
26
this . testHttpMessageHandler = new MockRedirectHandler ( ) ;
27
+ handlers = handlers = new DelegatingHandler [ 3 ] ;
28
+ handlers [ 0 ] = new RetryHandler ( ) ;
29
+ handlers [ 1 ] = new RedirectHandler ( ) ;
30
+ handlers [ 2 ] = new AuthenticationHandler ( ) ;
31
+
26
32
}
27
33
28
34
public void Dispose ( )
@@ -33,7 +39,7 @@ public void Dispose()
33
39
[ Fact ]
34
40
public void CreatePipelineWithoutHttpMessageHandlerInput ( )
35
41
{
36
- using ( RetryHandler retryHandler = ( RetryHandler ) GraphClientFactory . CreateDefaultHandlers ( ) )
42
+ using ( RetryHandler retryHandler = ( RetryHandler ) GraphClientFactory . CreatePipeline ( handlers ) )
37
43
using ( RedirectHandler redirectHandler = ( RedirectHandler ) retryHandler . InnerHandler )
38
44
using ( AuthenticationHandler authenticationHandler = ( AuthenticationHandler ) redirectHandler . InnerHandler )
39
45
using ( HttpClientHandler innerMost = ( HttpClientHandler ) authenticationHandler . InnerHandler )
@@ -53,7 +59,7 @@ public void CreatePipelineWithoutHttpMessageHandlerInput()
53
59
[ Fact ]
54
60
public void CreatePipelineWithHttpMessageHandlerInput ( )
55
61
{
56
- using ( RetryHandler retryHandler = ( RetryHandler ) GraphClientFactory . CreatePipeline ( null , this . testHttpMessageHandler ) )
62
+ using ( RetryHandler retryHandler = ( RetryHandler ) GraphClientFactory . CreatePipeline ( handlers , this . testHttpMessageHandler ) )
57
63
using ( RedirectHandler redirectHandler = ( RedirectHandler ) retryHandler . InnerHandler )
58
64
using ( AuthenticationHandler authenticationHandler = ( AuthenticationHandler ) redirectHandler . InnerHandler )
59
65
using ( MockRedirectHandler innerMost = ( MockRedirectHandler ) authenticationHandler . InnerHandler )
@@ -234,11 +240,10 @@ public async Task SendRequest_UnauthorizedWithAuthenticationProvider()
234
240
235
241
testHttpMessageHandler . SetHttpResponse ( unauthorizedResponse , okResponse ) ;
236
242
237
- var authHandler = new AuthenticationHandler ( new MockAuthenticationProvider ( ) . Object ) ;
238
- var pipeline = GraphClientFactory . CreateDefaultHandlers ( ) ;
243
+ handlers [ 2 ] = new AuthenticationHandler ( new MockAuthenticationProvider ( ) . Object ) ;
239
244
240
245
GraphClientFactory . DefaultHttpHandler = ( ) => this . testHttpMessageHandler ;
241
- using ( HttpClient client = GraphClientFactory . Create ( ) )
246
+ using ( HttpClient client = GraphClientFactory . Create ( handlers : handlers ) )
242
247
{
243
248
var response = await client . SendAsync ( httpRequestMessage , new CancellationToken ( ) ) ;
244
249
Assert . Same ( response , okResponse ) ;
0 commit comments