Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit c714e4a

Browse files
author
Cesar Blum Silveira
committed
Update tests.
1 parent d399794 commit c714e4a

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

test/Kestrel.Core.Tests/KestrelServerTests.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,17 @@ public void StartWithInvalidAddressThrows()
3838
}
3939

4040
[Fact]
41-
public void StartWithHttpsAddressThrows()
41+
public void StartWithHttpsAddressConfiguresHttpsEndpoints()
4242
{
43-
var testLogger = new TestApplicationErrorLogger { ThrowOnCriticalErrors = false };
43+
var mockDefaultHttpsProvider = new Mock<IDefaultHttpsProvider>();
4444

45-
using (var server = CreateServer(new KestrelServerOptions(), testLogger))
45+
using (var server = CreateServer(new KestrelServerOptions(), mockDefaultHttpsProvider.Object))
4646
{
4747
server.Features.Get<IServerAddressesFeature>().Addresses.Add("https://127.0.0.1:0");
4848

49-
var exception = Assert.Throws<InvalidOperationException>(() => StartDummyApplication(server));
49+
StartDummyApplication(server);
5050

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);
5552
}
5653
}
5754

@@ -275,6 +272,11 @@ private static KestrelServer CreateServer(KestrelServerOptions options, ILogger
275272
return new KestrelServer(Options.Create(options), new MockTransportFactory(), new LoggerFactory(new[] { new KestrelTestLoggerProvider(testLogger) }), Mock.Of<IDefaultHttpsProvider>());
276273
}
277274

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+
278280
private static void StartDummyApplication(IServer server)
279281
{
280282
server.StartAsync(new DummyApplication(context => Task.CompletedTask), CancellationToken.None).GetAwaiter().GetResult();

test/Kestrel.FunctionalTests/AddressRegistrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ public void ThrowsWhenBindingLocalhostToDynamicPort()
511511
}
512512

513513
[Theory]
514-
[InlineData("https://localhost")]
515514
[InlineData("ftp://localhost")]
515+
[InlineData("ssh://localhost")]
516516
public void ThrowsForUnsupportedAddressFromHosting(string addr)
517517
{
518518
var hostBuilder = new WebHostBuilder()

0 commit comments

Comments
 (0)