@@ -649,8 +649,11 @@ public void WinHttpHandler_UnsupportedWindows_Throw()
649649 "For more information, see https://aka.ms/aspnet/grpc/netframework." ) ;
650650 }
651651
652- [ Test ]
653- public void WinHttpHandler_SupportedWindows_Success( )
652+ #pragma warning disable CS0436 // Just need to have a type called WinHttpHandler to activate new behavior.
653+ [ TestCase ( typeof ( WinHttpHandler ) ) ]
654+ #pragma warning restore CS0436
655+ [ TestCase ( typeof ( WinHttpHandlerInherited ) ) ]
656+ public void WinHttpHandler_SupportedWindows_Success( Type handlerType )
654657 {
655658 // Arrange
656659 var services = new ServiceCollection( ) ;
@@ -660,9 +663,7 @@ public void WinHttpHandler_SupportedWindows_Success()
660663 OSVersion = Version . Parse ( "10.0.20348.169" )
661664 } ) ;
662665
663- #pragma warning disable CS0436 // Just need to have a type called WinHttpHandler to activate new behavior.
664- var winHttpHandler = new WinHttpHandler( new TestHttpMessageHandler ( ) ) ;
665- #pragma warning restore CS0436
666+ var winHttpHandler = ( HttpMessageHandler ) Activator. CreateInstance ( handlerType , new TestHttpMessageHandler ( ) ) ! ;
666667
667668 // Act
668669 var channel = GrpcChannel. ForAddress ( "https://localhost" , new GrpcChannelOptions
@@ -675,6 +676,15 @@ public void WinHttpHandler_SupportedWindows_Success()
675676 Assert. AreEqual ( HttpHandlerType . WinHttpHandler , channel . HttpHandlerType ) ;
676677 }
677678
679+ #pragma warning disable CS0436 // Just need to have a type called WinHttpHandler to activate new behavior.
680+ private class WinHttpHandlerInherited : WinHttpHandler
681+ {
682+ public WinHttpHandlerInherited(HttpMessageHandler innerHandler) : base(innerHandler)
683+ {
684+ }
685+ }
686+ #pragma warning restore CS0436
687+
678688#if SUPPORT_LOAD_BALANCING
679689 [Test]
680690 public void Resolver_SocketHttpHandlerWithConnectCallback_Error()
0 commit comments