Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix failing HttpListener tests #19579

Merged
merged 2 commits into from
May 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ public void Add_PrefixAlreadyRegisteredAndStarted_ThrowsHttpListenerException()

public static IEnumerable<object[]> InvalidPrefix_TestData()
{
yield return new object[] { "http://microsoft.com/" };
// [ActiveIssue(19593, TestPlatforms.OSX)]
if (!PlatformDetection.IsOSX)
{
yield return new object[] { $"http://{Guid.NewGuid().ToString("N")}/" };
}
yield return new object[] { "http://[]/" };
yield return new object[] { "http://[::1%2]/" };
yield return new object[] { "http://[::]/" };
Expand All @@ -252,7 +256,6 @@ public static IEnumerable<object[]> InvalidPrefix_TestData()
yield return new object[] { "http://\\/" };
}

[ActiveIssue(19526)]
[Theory]
[MemberData(nameof(InvalidPrefix_TestData))]
public void Add_InvalidPrefixNotStarted_ThrowsHttpListenerExceptionOnStart(string uriPrefix)
Expand All @@ -265,15 +268,14 @@ public void Add_InvalidPrefixNotStarted_ThrowsHttpListenerExceptionOnStart(strin
Assert.Throws<HttpListenerException>(() => listener.Start());
}

[ActiveIssue(19526)]
[Theory]
[MemberData(nameof(InvalidPrefix_TestData))]
public void Add_InvalidPrefixAlreadyStarted_ThrowsHttpListenerExceptionOnAdd(string uriPrefix)
{
using (var factory = new HttpListenerFactory())
{
HttpListener listener = factory.GetListener();
Assert.Single(listener.Prefixes);
Assert.Single(listener.Prefixes);

Assert.Throws<HttpListenerException>(() => listener.Prefixes.Add(uriPrefix));
}
Expand Down Expand Up @@ -362,7 +364,6 @@ public void Contains_NullPrefix_ThrowsArgumentNullException()
Assert.Throws<ArgumentNullException>("key", () => listener.Prefixes.Contains(null));
}

[ActiveIssue(19526)]
[Fact]
public void Remove_PrefixExistsNotStarted_ReturnsTrue()
{
Expand All @@ -374,9 +375,8 @@ public void Remove_PrefixExistsNotStarted_ReturnsTrue()
Assert.Equal(0, listener.Prefixes.Count);
}

[ActiveIssue(19526)]
[Fact]
public async Task Remove_PrefixExistsStarted_ReturnsTrue()
public void Remove_PrefixExistsStarted_ReturnsTrue()
{
using (var factory = new HttpListenerFactory())
{
Expand All @@ -387,11 +387,8 @@ public async Task Remove_PrefixExistsStarted_ReturnsTrue()
Assert.False(listener.Prefixes.Contains(uriPrefix));
Assert.Equal(0, listener.Prefixes.Count);

// Trying to connect to the HttpListener should now fail.
using (var client = new HttpClient())
{
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetStringAsync(factory.ListeningUrl));
}
// Even though the listener has no prefixes, it should still be listening.
Assert.True(listener.IsListening);
}
}

Expand Down