diff --git a/examples/WireMock.Net.Console.NETCoreApp/Program.cs b/examples/WireMock.Net.Console.NETCoreApp/Program.cs
index 3c607385..02a03a67 100644
--- a/examples/WireMock.Net.Console.NETCoreApp/Program.cs
+++ b/examples/WireMock.Net.Console.NETCoreApp/Program.cs
@@ -28,6 +28,14 @@ namespace WireMock.Net.Console.NETCoreApp
server.AllowPartialMapping();
+ server
+ .Given(Request.Create().WithPath("/bbc").UsingGet())
+ .RespondWith(Response.Create().FromProxyUrl("http://www.bbc.com"));
+
+ server
+ .Given(Request.Create().WithPath("/google").UsingGet())
+ .RespondWith(Response.Create().FromProxyUrl("http://www.google.com"));
+
server
.Given(Request.Create().WithPath(p => p.Contains("x")).UsingGet())
.AtPriority(4)
diff --git a/src/WireMock.Net/Admin/Mappings/ResponseModel.cs b/src/WireMock.Net/Admin/Mappings/ResponseModel.cs
index 0cf72ee8..bd12064a 100644
--- a/src/WireMock.Net/Admin/Mappings/ResponseModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/ResponseModel.cs
@@ -78,5 +78,11 @@ namespace WireMock.Admin.Mappings
/// The delay in milliseconds.
///
public int? Delay { get; set; }
+
+ ///
+ /// Gets or sets the Proxy URL.
+ ///
+ /// ProxyUrl
+ public string ProxyUrl { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/DynamicResponseProvider.cs b/src/WireMock.Net/DynamicResponseProvider.cs
index ac31f004..82ca49f5 100644
--- a/src/WireMock.Net/DynamicResponseProvider.cs
+++ b/src/WireMock.Net/DynamicResponseProvider.cs
@@ -16,7 +16,7 @@ namespace WireMock
_responseMessageFunc = responseMessageFunc;
}
- public Task ProvideResponse(RequestMessage requestMessage)
+ public Task ProvideResponseAsync(RequestMessage requestMessage)
{
return Task.FromResult(_responseMessageFunc(requestMessage));
}
diff --git a/src/WireMock.Net/IResponseProvider.cs b/src/WireMock.Net/IResponseProvider.cs
index 7c785ee2..6643c9ca 100644
--- a/src/WireMock.Net/IResponseProvider.cs
+++ b/src/WireMock.Net/IResponseProvider.cs
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
+using JetBrains.Annotations;
namespace WireMock
{
@@ -10,12 +11,8 @@ namespace WireMock
///
/// The provide response.
///
- ///
- /// The request.
- ///
- ///
- /// The .
- ///
- Task ProvideResponse(RequestMessage requestMessage);
+ /// The request.
+ /// The .
+ Task ProvideResponseAsync([NotNull] RequestMessage requestMessage);
}
-}
+}
\ No newline at end of file
diff --git a/src/WireMock.Net/Mapping.cs b/src/WireMock.Net/Mapping.cs
index c7d3c5a8..06c953d4 100644
--- a/src/WireMock.Net/Mapping.cs
+++ b/src/WireMock.Net/Mapping.cs
@@ -65,10 +65,10 @@ namespace WireMock
/// The response to.
///
/// The request message.
- /// The .
- public async Task ResponseTo(RequestMessage requestMessage)
+ /// The .
+ public async Task ResponseToAsync(RequestMessage requestMessage)
{
- return await Provider.ProvideResponse(requestMessage);
+ return await Provider.ProvideResponseAsync(requestMessage);
}
///
diff --git a/src/WireMock.Net/Owin/WireMockMiddleware.cs b/src/WireMock.Net/Owin/WireMockMiddleware.cs
index c8f769ce..f6bfc9b6 100644
--- a/src/WireMock.Net/Owin/WireMockMiddleware.cs
+++ b/src/WireMock.Net/Owin/WireMockMiddleware.cs
@@ -103,7 +103,7 @@ namespace WireMock.Owin
}
}
- response = await targetMapping.ResponseTo(request);
+ response = await targetMapping.ResponseToAsync(request);
}
catch (Exception ex)
{
diff --git a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
index 4b4841af..f8f8d3a0 100644
--- a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
+++ b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
@@ -17,7 +17,7 @@ namespace WireMock.ResponseBuilders
IResponseBuilder WithBody([NotNull] string body, [CanBeNull] Encoding encoding = null);
///
- /// The with body.
+ /// The with body as Json.
///
/// The body.
/// The body encoding.
diff --git a/src/WireMock.Net/ResponseBuilders/IProxyResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IProxyResponseBuilder.cs
new file mode 100644
index 00000000..502eef16
--- /dev/null
+++ b/src/WireMock.Net/ResponseBuilders/IProxyResponseBuilder.cs
@@ -0,0 +1,17 @@
+using JetBrains.Annotations;
+
+namespace WireMock.ResponseBuilders
+{
+ ///
+ /// The ProxyResponseBuilder interface.
+ ///
+ public interface IProxyResponseBuilder : IStatusCodeResponseBuilder
+ {
+ ///
+ /// From Proxy URL.
+ ///
+ /// The proxy url.
+ /// A .
+ IResponseBuilder FromProxyUrl([NotNull] string proxyUrl);
+ }
+}
\ No newline at end of file
diff --git a/src/WireMock.Net/ResponseBuilders/IResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IResponseBuilder.cs
index 276cdd63..b1b13b56 100644
--- a/src/WireMock.Net/ResponseBuilders/IResponseBuilder.cs
+++ b/src/WireMock.Net/ResponseBuilders/IResponseBuilder.cs
@@ -3,7 +3,7 @@
///
/// The ResponseBuilder interface.
///
- public interface IResponseBuilder : IStatusCodeResponseBuilder
+ public interface IResponseBuilder : IProxyResponseBuilder
{
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/ResponseBuilders/IStatusCodeResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IStatusCodeResponseBuilder.cs
index 664aeaae..9b8767af 100644
--- a/src/WireMock.Net/ResponseBuilders/IStatusCodeResponseBuilder.cs
+++ b/src/WireMock.Net/ResponseBuilders/IStatusCodeResponseBuilder.cs
@@ -10,18 +10,14 @@ namespace WireMock.ResponseBuilders
///
/// The with status code.
///
- ///
- /// The code.
- ///
+ /// The code.
/// The .
IResponseBuilder WithStatusCode(int code);
///
/// The with status code.
///
- ///
- /// The code.
- ///
+ /// The code.
/// The .
IResponseBuilder WithStatusCode(HttpStatusCode code);
diff --git a/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs
index 0db91f2c..11af07f2 100644
--- a/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs
+++ b/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs
@@ -1,7 +1,7 @@
namespace WireMock.ResponseBuilders
{
///
- /// The BodyResponseBuilder interface.
+ /// The TransformResponseBuilder interface.
///
public interface ITransformResponseBuilder : IDelayResponseBuilder
{
diff --git a/src/WireMock.Net/ResponseBuilders/Response.cs b/src/WireMock.Net/ResponseBuilders/Response.cs
index b0351c8e..8f57999c 100644
--- a/src/WireMock.Net/ResponseBuilders/Response.cs
+++ b/src/WireMock.Net/ResponseBuilders/Response.cs
@@ -1,6 +1,9 @@
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Linq;
using System.Net;
+using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using HandlebarsDotNet;
@@ -28,6 +31,11 @@ namespace WireMock.ResponseBuilders
///
public bool UseTransformer { get; private set; }
+ ///
+ /// The Proxy URL to use.
+ ///
+ public string ProxyUrl { get; private set; }
+
///
/// Gets the response message.
///
@@ -184,7 +192,7 @@ namespace WireMock.ResponseBuilders
/// The body asbase64.
/// The Encoding.
/// A .
- public IResponseBuilder WithBodyAsBase64(string bodyAsbase64, Encoding encoding = null)
+ public IResponseBuilder WithBodyAsBase64([NotNull] string bodyAsbase64, Encoding encoding = null)
{
Check.NotNull(bodyAsbase64, nameof(bodyAsbase64));
@@ -230,19 +238,72 @@ namespace WireMock.ResponseBuilders
return WithDelay(TimeSpan.FromMilliseconds(milliseconds));
}
+ ///
+ /// From Proxy URL.
+ ///
+ /// The proxy url.
+ /// A .
+ [PublicAPI]
+ public IResponseBuilder FromProxyUrl(string proxyUrl)
+ {
+ Check.NotEmpty(proxyUrl, nameof(proxyUrl));
+
+ ProxyUrl = proxyUrl;
+ return this;
+ }
+
///
/// The provide response.
///
- ///
- /// The request.
- ///
- ///
- /// The .
- ///
- public async Task ProvideResponse(RequestMessage requestMessage)
+ /// The request.
+ /// The .
+ public async Task ProvideResponseAsync(RequestMessage requestMessage)
{
+ Check.NotNull(requestMessage, nameof(requestMessage));
+
ResponseMessage responseMessage;
- if (UseTransformer)
+
+ if (ProxyUrl != null)
+ {
+ using (var client = new HttpClient())
+ {
+ var httpRequestMessage = new HttpRequestMessage(new HttpMethod(requestMessage.Method), ProxyUrl);
+
+ // Overwrite the host header
+ httpRequestMessage.Headers.Host = new Uri(ProxyUrl).Authority;
+
+ // Set headers if present
+ if (requestMessage.Headers != null)
+ {
+ foreach (var headerName in requestMessage.Headers.Keys.Where(k => k.ToUpper() != "HOST"))
+ {
+ httpRequestMessage.Headers.Add(headerName, new[] { requestMessage.Headers[headerName] });
+ }
+ }
+
+ // Set Body if present
+ if (requestMessage.BodyAsBytes != null && requestMessage.BodyAsBytes.Length > 0)
+ {
+ httpRequestMessage.Content = new ByteArrayContent(requestMessage.BodyAsBytes);
+ }
+
+ // Call the URL
+ var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
+
+ // Transform response
+ responseMessage = new ResponseMessage
+ {
+ StatusCode = (int)httpResponseMessage.StatusCode,
+ Body = await httpResponseMessage.Content.ReadAsStringAsync()
+ };
+
+ foreach (var header in httpResponseMessage.Headers)
+ {
+ responseMessage.AddHeader(header.Key, header.Value.FirstOrDefault());
+ }
+ }
+ }
+ else if (UseTransformer)
{
responseMessage = new ResponseMessage { StatusCode = ResponseMessage.StatusCode, BodyOriginal = ResponseMessage.Body };
diff --git a/src/WireMock.Net/Server/FluentMockServer.Admin.cs b/src/WireMock.Net/Server/FluentMockServer.Admin.cs
index c1c2a089..09e38f8b 100644
--- a/src/WireMock.Net/Server/FluentMockServer.Admin.cs
+++ b/src/WireMock.Net/Server/FluentMockServer.Admin.cs
@@ -466,6 +466,14 @@ namespace WireMock.Server
{
IResponseBuilder responseBuilder = Response.Create();
+ if (responseModel.Delay > 0)
+ responseBuilder = responseBuilder.WithDelay(responseModel.Delay.Value);
+
+ if (!string.IsNullOrEmpty(responseModel.ProxyUrl))
+ {
+ return responseBuilder.FromProxyUrl(responseModel.ProxyUrl);
+ }
+
if (responseModel.StatusCode.HasValue)
responseBuilder = responseBuilder.WithStatusCode(responseModel.StatusCode.Value);
@@ -492,9 +500,6 @@ namespace WireMock.Server
if (responseModel.UseTransformer)
responseBuilder = responseBuilder.WithTransformer();
- if (responseModel.Delay > 0)
- responseBuilder = responseBuilder.WithDelay(responseModel.Delay.Value);
-
return responseBuilder;
}
@@ -511,7 +516,7 @@ namespace WireMock.Server
var bodyMatcher = request.GetRequestMessageMatcher();
var methodMatcher = request.GetRequestMessageMatcher();
- return new MappingModel
+ var mappingModel = new MappingModel
{
Guid = mapping.Guid,
Title = mapping.Title,
@@ -562,20 +567,36 @@ namespace WireMock.Server
},
Response = new ResponseModel
{
- StatusCode = response.ResponseMessage.StatusCode,
- Headers = response.ResponseMessage.Headers,
- Body = response.ResponseMessage.Body,
- UseTransformer = response.UseTransformer,
- Delay = response.Delay?.Milliseconds,
+ Delay = response.Delay?.Milliseconds
+ }
+ };
- BodyEncoding = response.ResponseMessage.BodyEncoding != null ? new EncodingModel
+ if (!string.IsNullOrEmpty(response.ProxyUrl))
+ {
+ mappingModel.Response.StatusCode = null;
+ mappingModel.Response.Headers = null;
+ mappingModel.Response.Body = null;
+ mappingModel.Response.UseTransformer = false;
+ mappingModel.Response.BodyEncoding = null;
+ mappingModel.Response.ProxyUrl = response.ProxyUrl;
+ }
+ else
+ {
+ mappingModel.Response.StatusCode = response.ResponseMessage.StatusCode;
+ mappingModel.Response.Headers = response.ResponseMessage.Headers;
+ mappingModel.Response.Body = response.ResponseMessage.Body;
+ mappingModel.Response.UseTransformer = response.UseTransformer;
+ mappingModel.Response.BodyEncoding = response.ResponseMessage.BodyEncoding != null
+ ? new EncodingModel
{
EncodingName = response.ResponseMessage.BodyEncoding.EncodingName,
CodePage = response.ResponseMessage.BodyEncoding.CodePage,
WebName = response.ResponseMessage.BodyEncoding.WebName
- } : null
- }
- };
+ }
+ : null;
+ }
+
+ return mappingModel;
}
private MatcherModel[] Map([CanBeNull] IEnumerable matchers)
diff --git a/src/WireMock.Net/Server/FluentMockServer.cs b/src/WireMock.Net/Server/FluentMockServer.cs
index 2682993f..408f980c 100644
--- a/src/WireMock.Net/Server/FluentMockServer.cs
+++ b/src/WireMock.Net/Server/FluentMockServer.cs
@@ -6,7 +6,6 @@ using System.Linq;
using System.Text;
using JetBrains.Annotations;
using WireMock.Http;
-using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Matchers.Request;
using WireMock.RequestBuilders;
@@ -21,9 +20,7 @@ namespace WireMock.Server
public partial class FluentMockServer : IDisposable
{
private readonly IOwinSelfHost _httpServer;
-
private readonly object _syncRoot = new object();
-
private readonly WireMockMiddlewareOptions _options = new WireMockMiddlewareOptions();
///
@@ -56,6 +53,7 @@ namespace WireMock.Server
}
}
+ #region Start/Stop
///
/// Starts the specified settings.
///
@@ -185,6 +183,16 @@ namespace WireMock.Server
}
}
+ ///
+ /// Stop this server.
+ ///
+ [PublicAPI]
+ public void Stop()
+ {
+ _httpServer?.StopAsync();
+ }
+ #endregion
+
///
/// Adds the catch all mapping.
///
@@ -197,15 +205,6 @@ namespace WireMock.Server
.RespondWith(new DynamicResponseProvider(request => new ResponseMessage { StatusCode = 404, Body = "No matching mapping found" }));
}
- ///
- /// Stop this server.
- ///
- [PublicAPI]
- public void Stop()
- {
- _httpServer?.StopAsync();
- }
-
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
@@ -264,9 +263,7 @@ namespace WireMock.Server
///
/// The add request processing delay.
///
- ///
- /// The delay.
- ///
+ /// The delay.
[PublicAPI]
public void AddGlobalProcessingDelay(TimeSpan delay)
{
diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj
index f2aa2b2c..b5f0a4ae 100644
--- a/src/WireMock.Net/WireMock.Net.csproj
+++ b/src/WireMock.Net/WireMock.Net.csproj
@@ -46,6 +46,7 @@
+
@@ -54,6 +55,7 @@
+
diff --git a/test/WireMock.Net.Tests/FluentMockServerTests.cs b/test/WireMock.Net.Tests/FluentMockServerTests.cs
index 427ccf18..8773f11a 100644
--- a/test/WireMock.Net.Tests/FluentMockServerTests.cs
+++ b/test/WireMock.Net.Tests/FluentMockServerTests.cs
@@ -353,6 +353,22 @@ namespace WireMock.Net.Tests
Check.That(watch.ElapsedMilliseconds).IsStrictlyGreaterThan(200);
}
+ [Fact]
+ public async Task Should_proxy_responses()
+ {
+ // given
+ _server = FluentMockServer.Start();
+ _server
+ .Given(Request.Create().WithPath("/*"))
+ .RespondWith(Response.Create().FromProxyUrl("http://www.google.com"));
+
+ // when
+ var result = await new HttpClient().GetStringAsync("http://localhost:" + _server.Ports[0] + "/foo");
+
+ // then
+ Check.That(result).Contains("google");
+ }
+
//[TearDown]
public void Dispose()
{
diff --git a/test/WireMock.Net.Tests/HttpListenerRequestMapperTests.cs b/test/WireMock.Net.Tests/HttpListenerRequestMapperTests.cs
deleted file mode 100644
index 3153ab13..00000000
--- a/test/WireMock.Net.Tests/HttpListenerRequestMapperTests.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//using System;
-//using System.Collections.Generic;
-//using System.Net;
-//using System.Net.Http;
-//using System.Threading;
-//using System.Threading.Tasks;
-//using NFluent;
-//using Xunit;
-//using WireMock.Matchers;
-//using WireMock.RequestBuilders;
-//using WireMock.ResponseBuilders;
-//using WireMock.Server;
-
-//namespace WireMock.Net.Tests
-//{
-// //[TestFixture]
-// public class HttpListenerRequestMapperTests : IDisposable
-// {
-// private FluentMockServer _server;
-
-// public HttpListenerRequestMapperTests()
-// {
-// _server = FluentMockServer.Start();
-// }
-
-// [Fact]
-// public async Task Should_map_uri_from_listener_request()
-// {
-// // given
-// var client = new HttpClient();
-
-// // when
-// await client.GetAsync(MapperServer.UrlPrefix + "toto");
-
-// // then
-// Check.That(MapperServer.LastRequestMessage).IsNotNull();
-// Check.That(MapperServer.LastRequestMessage.Path).IsEqualTo("/toto");
-// }
-
-// [Fact]
-// public async Task Should_map_verb_from_listener_request()
-// {
-// // given
-// var client = new HttpClient();
-
-// // when
-// await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!"));
-
-// // then
-// Check.That(MapperServer.LastRequestMessage).IsNotNull();
-// Check.That(MapperServer.LastRequestMessage.Method).IsEqualTo("put");
-// }
-
-// [Fact]
-// public async Task Should_map_body_from_listener_request()
-// {
-// // given
-// var client = new HttpClient();
-
-// // when
-// await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!"));
-
-// // then
-// Check.That(MapperServer.LastRequestMessage).IsNotNull();
-// Check.That(MapperServer.LastRequestMessage.Body).IsEqualTo("Hello!");
-// }
-
-// [Fact]
-// public async Task Should_map_headers_from_listener_request()
-// {
-// // given
-// var client = new HttpClient();
-// client.DefaultRequestHeaders.Add("X-Alex", "1706");
-
-// // when
-// await client.GetAsync(MapperServer.UrlPrefix);
-
-// // then
-// Check.That(MapperServer.LastRequestMessage).IsNotNull();
-// Check.That(MapperServer.LastRequestMessage.Headers).Not.IsNullOrEmpty();
-// Check.That(MapperServer.LastRequestMessage.Headers.Contains(new KeyValuePair("X-Alex", "1706"))).IsTrue();
-// }
-
-// [Fact]
-// public async Task Should_map_params_from_listener_request()
-// {
-// // given
-// var client = new HttpClient();
-
-// // when
-// await client.GetAsync(MapperServer.UrlPrefix + "index.html?id=toto");
-
-// // then
-// Check.That(MapperServer.LastRequestMessage).IsNotNull();
-// Check.That(MapperServer.LastRequestMessage.Path).EndsWith("/index.html");
-// Check.That(MapperServer.LastRequestMessage.GetParameter("id")).HasSize(1);
-// }
-
-// public void Dispose()
-// {
-// _server.Stop().Wait();
-// }
-// }
-//}
diff --git a/test/WireMock.Net.Tests/HttpListenerResponseMapperTests.cs b/test/WireMock.Net.Tests/HttpListenerResponseMapperTests.cs
deleted file mode 100644
index ea43ca1b..00000000
--- a/test/WireMock.Net.Tests/HttpListenerResponseMapperTests.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-//using System;
-//using System.Net;
-//using System.Net.Http;
-//using System.Text;
-//using System.Threading;
-//using System.Threading.Tasks;
-//using NFluent;
-//using Xunit;
-//using WireMock.Http;
-//using WireMock.Owin;
-
-//namespace WireMock.Net.Tests
-//{
-// //[TestFixture]
-// public class HttpListenerResponseMapperTests : IDisposable
-// {
-// private TinyHttpServer _server;
-// private Task _responseMsgTask;
-
-// [Fact]
-// public void Should_map_status_code_from_original_response()
-// {
-// // given
-// var response = new ResponseMessage { StatusCode = 404 };
-// var httpListenerResponse = CreateHttpListenerResponse();
-
-// // when
-// new HttpListenerResponseMapper().Map(response, httpListenerResponse);
-
-// // then
-// Check.That(httpListenerResponse.StatusCode).IsEqualTo(404);
-// }
-
-// [Fact]
-// public void Should_map_headers_from_original_response()
-// {
-// // given
-// var response = new ResponseMessage();
-// response.AddHeader("cache-control", "no-cache");
-// var httpListenerResponse = CreateHttpListenerResponse();
-
-// // when
-// new HttpListenerResponseMapper().Map(response, httpListenerResponse);
-
-// // then
-// Check.That(httpListenerResponse.Headers).HasSize(1);
-// Check.That(httpListenerResponse.Headers.Keys).Contains("cache-control");
-// Check.That(httpListenerResponse.Headers.Get("cache-control")).Contains("no-cache");
-// }
-
-// [Fact]
-// public void Should_map_body_from_original_response()
-// {
-// // given
-// var response = new ResponseMessage
-// {
-// Body = "Hello !!!"
-// };
-
-// var httpListenerResponse = CreateHttpListenerResponse();
-
-// // when
-// new OwinResponseMapper().Map(response, httpListenerResponse);
-
-// // then
-// var responseMessage = ToResponseMessage(httpListenerResponse);
-// Check.That(responseMessage).IsNotNull();
-
-// var contentTask = responseMessage.Content.ReadAsStringAsync();
-// Check.That(contentTask.Result).IsEqualTo("Hello !!!");
-// }
-
-// [Fact]
-// public void Should_map_encoded_body_from_original_response()
-// {
-// // given
-// var response = new ResponseMessage
-// {
-// Body = "Hello !!!",
-// BodyEncoding = Encoding.ASCII
-// };
-
-// var httpListenerResponse = CreateHttpListenerResponse();
-
-// // when
-// new HttpListenerResponseMapper().Map(response, httpListenerResponse);
-
-// // then
-// Check.That(httpListenerResponse.ContentEncoding).Equals(Encoding.ASCII);
-
-// var responseMessage = ToResponseMessage(httpListenerResponse);
-// Check.That(responseMessage).IsNotNull();
-
-// var contentTask = responseMessage.Content.ReadAsStringAsync();
-// Check.That(contentTask.Result).IsEqualTo("Hello !!!");
-// }
-
-// //[TearDown]
-// public void Dispose()
-// {
-// _server?.Stop();
-// }
-
-// ///
-// /// Dirty HACK to get HttpListenerResponse instances
-// ///
-// ///
-// /// The .
-// ///
-// public HttpListenerResponse CreateHttpListenerResponse()
-// {
-// var port = PortUtil.FindFreeTcpPort();
-// var urlPrefix = "http://localhost:" + port + "/";
-// var responseReady = new AutoResetEvent(false);
-// HttpListenerResponse response = null;
-// _server = new TinyHttpServer(
-// (context, token) =>
-// {
-// response = context.Response;
-// responseReady.Set();
-// }, urlPrefix);
-// _server.Start();
-// _responseMsgTask = new HttpClient().GetAsync(urlPrefix);
-// responseReady.WaitOne();
-// return response;
-// }
-
-// public HttpResponseMessage ToResponseMessage(HttpListenerResponse listenerResponse)
-// {
-// listenerResponse.Close();
-// _responseMsgTask.Wait();
-// return _responseMsgTask.Result;
-// }
-// }
-//}
diff --git a/test/WireMock.Net.Tests/ResponseTests.cs b/test/WireMock.Net.Tests/ResponseTests.cs
index a2f6c7c6..e0c5d717 100644
--- a/test/WireMock.Net.Tests/ResponseTests.cs
+++ b/test/WireMock.Net.Tests/ResponseTests.cs
@@ -24,7 +24,7 @@ namespace WireMock.Net.Tests
.WithTransformer();
// act
- var responseMessage = await response.ProvideResponse(request);
+ var responseMessage = await response.ProvideResponseAsync(request);
// then
Check.That(responseMessage.Body).Equals("test http://localhost/foo /foo post");
@@ -43,7 +43,7 @@ namespace WireMock.Net.Tests
.WithTransformer();
// act
- var responseMessage = await response.ProvideResponse(request);
+ var responseMessage = await response.ProvideResponseAsync(request);
// then
Check.That(responseMessage.Body).Equals("test keya=1 idx=1 idx=2 keyb=5");
@@ -60,7 +60,7 @@ namespace WireMock.Net.Tests
var response = Response.Create().WithHeader("x", "{{request.headers.Content-Type}}").WithBody("test").WithTransformer();
// act
- var responseMessage = await response.ProvideResponse(request);
+ var responseMessage = await response.ProvideResponseAsync(request);
// then
Check.That(responseMessage.Body).Equals("test");
@@ -78,7 +78,7 @@ namespace WireMock.Net.Tests
var response = Response.Create().WithBody("test", Encoding.ASCII);
// act
- var responseMessage = await response.ProvideResponse(request);
+ var responseMessage = await response.ProvideResponseAsync(request);
// then
Check.That(responseMessage.Body).Equals("test");
@@ -96,7 +96,7 @@ namespace WireMock.Net.Tests
var response = Response.Create().WithBodyAsJson(new { value = "test" }, Encoding.ASCII);
// act
- var responseMessage = await response.ProvideResponse(request);
+ var responseMessage = await response.ProvideResponseAsync(request);
// then
Check.That(responseMessage.Body).Equals("{\"value\":\"test\"}");