mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-18 23:33:47 +01:00
HttpListener : Stop fix
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user