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

Commit

Permalink
Enable default server address test
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Mar 6, 2017
1 parent 0404bcc commit 7d94abd
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -129,7 +130,7 @@ private async Task RegisterIPEndPoint_Success(IPEndPoint endPoint, Func<IPEndPoi
}
}

[ConditionalFact(Skip = "Waiting on https://github.com/aspnet/Hosting/issues/917")]
[ConditionalFact]
[PortSupportedCondition(5000)]
public async Task DefaultsToPort5000()
{
Expand All @@ -147,13 +148,14 @@ public async Task DefaultsToPort5000()
{
host.Start();

var debugLog = testLogger.Messages.Single(log => log.LogLevel == LogLevel.Debug);
Assert.True(debugLog.Message.Contains("default"));
Assert.Equal(5000, host.GetPort());
Assert.Single(testLogger.Messages, log => log.LogLevel == LogLevel.Debug &&
string.Equals($"No listening endpoints were configured. Binding to {Constants.DefaultIPEndPoint} by default.",
log.Message, StringComparison.Ordinal));

foreach (var testUrl in new[] { "http://127.0.0.1:5000", "http://localhost:5000" })
foreach (var testUrl in new[] { "http://127.0.0.1:5000", /* "http://[::1]:5000" */})
{
var response = await HttpClientSlim.GetStringAsync(testUrl);
Assert.Equal(new Uri(testUrl).ToString(), response);
Assert.Equal(new Uri(testUrl).ToString(), await HttpClientSlim.GetStringAsync(testUrl));
}
}
}
Expand Down

0 comments on commit 7d94abd

Please sign in to comment.