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

Commit

Permalink
Tests were added twice while rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Apr 14, 2017
1 parent d2c578c commit 08f9056
Showing 1 changed file with 0 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,74 +297,6 @@ public async Task DoesNotOverrideDirectConfigurationWithIServerAddressesFeature_
}
}

[ConditionalFact]
[PortSupportedCondition(5002)]
public async Task OverrideDirectConfigurationWithIServerAddressesFeature_Succeeds()
{
var overrideAddress = "http://localhost:5002";
var testLogger = new TestApplicationErrorLogger();

var hostBuilder = new WebHostBuilder()
.UseKestrel(options => options.Listen(IPAddress.Loopback, 5001))
.UseUrls(overrideAddress)
.PreferHostingUrls(true)
.UseLoggerFactory(_ => new KestrelTestLoggerFactory(testLogger))
.Configure(ConfigureEchoAddress);

using (var host = hostBuilder.Build())
{
host.Start();

Assert.Equal(5002, host.GetPort());
Assert.Single(testLogger.Messages, log => log.LogLevel == LogLevel.Warning &&
string.Equals($"Overriding endpoints defined in UseKestrel() since {nameof(IServerAddressesFeature.PreferHostingUrls)} is set to true. Binding to address(es) '{overrideAddress}' instead.",
log.Message, StringComparison.Ordinal));

Assert.Equal(new Uri(overrideAddress).ToString(), await HttpClientSlim.GetStringAsync(overrideAddress));
}
}

[ConditionalFact]
[PortSupportedCondition(5001)]
public async Task DoesNotOverrideDirectConfigurationWithIServerAddressesFeature_IfPreferHostingUrlsFalse()
{
var endPointAddress = "http://localhost:5001";

var hostBuilder = new WebHostBuilder()
.UseKestrel(options => options.Listen(IPAddress.Loopback, 5001))
.UseUrls("http://localhost:5002")
.PreferHostingUrls(false)
.Configure(ConfigureEchoAddress);

using (var host = hostBuilder.Build())
{
host.Start();

Assert.Equal(5001, host.GetPort());
Assert.Equal(new Uri(endPointAddress).ToString(), await HttpClientSlim.GetStringAsync(endPointAddress));
}
}

[ConditionalFact]
[PortSupportedCondition(5001)]
public async Task DoesNotOverrideDirectConfigurationWithIServerAddressesFeature_IfAddressesEmpty()
{
var endPointAddress = "http://localhost:5001";

var hostBuilder = new WebHostBuilder()
.UseKestrel(options => options.Listen(IPAddress.Loopback, 5001))
.PreferHostingUrls(true)
.Configure(ConfigureEchoAddress);

using (var host = hostBuilder.Build())
{
host.Start();

Assert.Equal(5001, host.GetPort());
Assert.Equal(new Uri(endPointAddress).ToString(), await HttpClientSlim.GetStringAsync(endPointAddress));
}
}

[Fact]
public void ThrowsWhenBindingLocalhostToIPv4AddressInUse()
{
Expand Down

0 comments on commit 08f9056

Please sign in to comment.