@@ -25,7 +25,7 @@ public class GraphClientFactoryTests : IDisposable
25
25
public GraphClientFactoryTests ( )
26
26
{
27
27
this . testHttpMessageHandler = new MockRedirectHandler ( ) ;
28
- handlers = handlers = new DelegatingHandler [ 3 ] ;
28
+ handlers = new DelegatingHandler [ 3 ] ;
29
29
handlers [ 0 ] = new RetryHandler ( ) ;
30
30
handlers [ 1 ] = new RedirectHandler ( ) ;
31
31
handlers [ 2 ] = new AuthenticationHandler ( authenticationProvider . Object ) ;
@@ -37,24 +37,27 @@ public void Dispose()
37
37
this . testHttpMessageHandler . Dispose ( ) ;
38
38
}
39
39
40
+ // Note:
41
+ // 1. Xunit's IsType doesn't consider inheritance behind the classes.
42
+ // 2. We can't control the order of execution for the tests
43
+ // and 'GraphClientFactory.DefaultHttpHandler' can easily be modified
44
+ // by other tests since it's a static delegate.
40
45
[ Fact ]
41
46
public void CreatePipelineWithoutHttpMessageHandlerInput ( )
42
47
{
43
48
using ( RetryHandler retryHandler = ( RetryHandler ) GraphClientFactory . CreatePipeline ( handlers ) )
44
49
using ( RedirectHandler redirectHandler = ( RedirectHandler ) retryHandler . InnerHandler )
45
50
using ( AuthenticationHandler authenticationHandler = ( AuthenticationHandler ) redirectHandler . InnerHandler )
46
- using ( HttpClientHandler innerMost = ( HttpClientHandler ) authenticationHandler . InnerHandler )
51
+ using ( HttpMessageHandler innerMost = authenticationHandler . InnerHandler )
47
52
{
48
- System . Diagnostics . Debug . WriteLine ( "InvalidCast: " + authenticationHandler . InnerHandler . GetType ( ) . ToString ( ) ) ;
49
-
50
53
Assert . NotNull ( retryHandler ) ;
51
54
Assert . NotNull ( redirectHandler ) ;
52
55
Assert . NotNull ( authenticationHandler ) ;
53
56
Assert . NotNull ( innerMost ) ;
54
57
Assert . IsType ( typeof ( RetryHandler ) , retryHandler ) ;
55
58
Assert . IsType ( typeof ( RedirectHandler ) , redirectHandler ) ;
56
59
Assert . IsType ( typeof ( AuthenticationHandler ) , authenticationHandler ) ;
57
- Assert . IsType ( typeof ( HttpClientHandler ) , innerMost ) ;
60
+ Assert . True ( innerMost is HttpMessageHandler ) ;
58
61
}
59
62
60
63
}
0 commit comments