HttpListener : Stop fix

This commit is contained in:
Stef Heyenrath
2017-03-21 14:45:34 +01:00
parent 9fcfb3109f
commit e9ee4e91f9
6 changed files with 41 additions and 14 deletions

View File

@@ -30,6 +30,16 @@ namespace WireMock.Net.Tests
return current;
}
[Test]
public void FluentMockServer_StartStop()
{
var server1 = FluentMockServer.Start("http://localhost:9090/");
server1.Stop();
var server2 = FluentMockServer.Start("http://localhost:9090/");
server2.Stop();
}
[Test]
public void FluentMockServer_ReadStaticMapping_WithNonGuidFilename()
{
@@ -346,7 +356,7 @@ namespace WireMock.Net.Tests
[TearDown]
public void ShutdownServer()
{
_server.Stop();
_server?.Stop();
}
}
}

View File

@@ -25,7 +25,7 @@ namespace WireMock.Net.Tests.Http
var port = PortUtil.FindFreeTcpPort();
bool called = false;
var urlPrefix = "http://localhost:" + port + "/";
var server = new TinyHttpServer(ctx => called = true, urlPrefix);
var server = new TinyHttpServer((ctx, token) => called = true, urlPrefix);
server.Start();
// when

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using NFluent;
using NUnit.Framework;
@@ -103,7 +104,7 @@ namespace WireMock.Net.Tests
{
private static volatile RequestMessage _lastRequestMessage;
private MapperServer(Action<HttpListenerContext> httpHandler, string urlPrefix) : base(httpHandler, urlPrefix)
private MapperServer(Action<HttpListenerContext, CancellationToken> httpHandler, string urlPrefix) : base(httpHandler, urlPrefix)
{
}
@@ -127,7 +128,7 @@ namespace WireMock.Net.Tests
int port = PortUtil.FindFreeTcpPort();
UrlPrefix = "http://localhost:" + port + "/";
var server = new MapperServer(
context =>
(context, token) =>
{
LastRequestMessage = new HttpListenerRequestMapper().Map(context.Request);
context.Response.Close();

View File

@@ -112,7 +112,7 @@ namespace WireMock.Net.Tests
var responseReady = new AutoResetEvent(false);
HttpListenerResponse response = null;
_server = new TinyHttpServer(
context =>
(context, token) =>
{
response = context.Response;
responseReady.Set();