@@ -38,20 +38,17 @@ public void StartWithInvalidAddressThrows()
38
38
}
39
39
40
40
[ Fact ]
41
- public void StartWithHttpsAddressThrows ( )
41
+ public void StartWithHttpsAddressConfiguresHttpsEndpoints ( )
42
42
{
43
- var testLogger = new TestApplicationErrorLogger { ThrowOnCriticalErrors = false } ;
43
+ var mockDefaultHttpsProvider = new Mock < IDefaultHttpsProvider > ( ) ;
44
44
45
- using ( var server = CreateServer ( new KestrelServerOptions ( ) , testLogger ) )
45
+ using ( var server = CreateServer ( new KestrelServerOptions ( ) , mockDefaultHttpsProvider . Object ) )
46
46
{
47
47
server . Features . Get < IServerAddressesFeature > ( ) . Addresses . Add ( "https://127.0.0.1:0" ) ;
48
48
49
- var exception = Assert . Throws < InvalidOperationException > ( ( ) => StartDummyApplication ( server ) ) ;
49
+ StartDummyApplication ( server ) ;
50
50
51
- Assert . Equal (
52
- $ "HTTPS endpoints can only be configured using { nameof ( KestrelServerOptions ) } .{ nameof ( KestrelServerOptions . Listen ) } ().",
53
- exception . Message ) ;
54
- Assert . Equal ( 1 , testLogger . CriticalErrorsLogged ) ;
51
+ mockDefaultHttpsProvider . Verify ( provider => provider . ConfigureHttps ( It . IsAny < ListenOptions > ( ) ) , Times . Once ) ;
55
52
}
56
53
}
57
54
@@ -275,6 +272,11 @@ private static KestrelServer CreateServer(KestrelServerOptions options, ILogger
275
272
return new KestrelServer ( Options . Create ( options ) , new MockTransportFactory ( ) , new LoggerFactory ( new [ ] { new KestrelTestLoggerProvider ( testLogger ) } ) , Mock . Of < IDefaultHttpsProvider > ( ) ) ;
276
273
}
277
274
275
+ private static KestrelServer CreateServer ( KestrelServerOptions options , IDefaultHttpsProvider defaultHttpsProvider )
276
+ {
277
+ return new KestrelServer ( Options . Create ( options ) , new MockTransportFactory ( ) , new LoggerFactory ( new [ ] { new KestrelTestLoggerProvider ( Mock . Of < ILogger > ( ) ) } ) , defaultHttpsProvider ) ;
278
+ }
279
+
278
280
private static void StartDummyApplication ( IServer server )
279
281
{
280
282
server . StartAsync ( new DummyApplication ( context => Task . CompletedTask ) , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
0 commit comments