Rename classes

This commit is contained in:
Stef Heyenrath
2017-01-18 07:42:05 +01:00
parent c0872995b0
commit 8f02e99a00
23 changed files with 142 additions and 147 deletions

View File

@@ -19,12 +19,12 @@ namespace WireMock.Net.ConsoleApplication
server server
.Given( .Given(
RequestBuilder Request
.WithUrl("/*") .WithUrl("/*")
.UsingGet() .UsingGet()
) )
.RespondWith( .RespondWith(
ResponseBuilder Response
.WithStatusCode(200) .WithStatusCode(200)
.WithHeader("Content-Type", "application/json") .WithHeader("Content-Type", "application/json")
.WithBody(@"{ ""msg"": ""Hello world!""}") .WithBody(@"{ ""msg"": ""Hello world!""}")

View File

@@ -43,15 +43,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy(Request request) public bool IsSatisfiedBy(RequestMessage requestMessage)
{ {
return _requestSpecs.All(spec => spec.IsSatisfiedBy(request)); return _requestSpecs.All(spec => spec.IsSatisfiedBy(requestMessage));
} }
} }
} }

View File

@@ -43,7 +43,7 @@ namespace WireMock
/// <summary> /// <summary>
/// The _request logs. /// The _request logs.
/// </summary> /// </summary>
private readonly IList<Request> _requestLogs = new List<Request>(); private readonly IList<RequestMessage> _requestLogs = new List<RequestMessage>();
/// <summary> /// <summary>
/// The _request mapper. /// The _request mapper.
@@ -104,13 +104,13 @@ namespace WireMock
/// <summary> /// <summary>
/// Gets the request logs. /// Gets the request logs.
/// </summary> /// </summary>
public IEnumerable<Request> RequestLogs public IEnumerable<RequestMessage> RequestLogs
{ {
get get
{ {
lock (((ICollection)_requestLogs).SyncRoot) lock (((ICollection)_requestLogs).SyncRoot)
{ {
return new ReadOnlyCollection<Request>(_requestLogs); return new ReadOnlyCollection<RequestMessage>(_requestLogs);
} }
} }
} }
@@ -162,7 +162,7 @@ namespace WireMock
/// <returns> /// <returns>
/// The <see cref="IEnumerable"/>. /// The <see cref="IEnumerable"/>.
/// </returns> /// </returns>
public IEnumerable<Request> SearchLogsFor(ISpecifyRequests spec) public IEnumerable<RequestMessage> SearchLogsFor(ISpecifyRequests spec)
{ {
lock (((ICollection)_requestLogs).SyncRoot) lock (((ICollection)_requestLogs).SyncRoot)
{ {
@@ -223,14 +223,14 @@ namespace WireMock
/// <summary> /// <summary>
/// The log request. /// The log request.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
private void LogRequest(Request request) private void LogRequest(RequestMessage requestMessage)
{ {
lock (((ICollection)_requestLogs).SyncRoot) lock (((ICollection)_requestLogs).SyncRoot)
{ {
_requestLogs.Add(request); _requestLogs.Add(requestMessage);
} }
} }

View File

@@ -27,9 +27,9 @@ namespace WireMock
/// The listener request. /// The listener request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="RequestBuilder"/>. /// The <see cref="Request"/>.
/// </returns> /// </returns>
public Request Map(HttpListenerRequest listenerRequest) public RequestMessage Map(HttpListenerRequest listenerRequest)
{ {
var path = listenerRequest.Url.AbsolutePath; var path = listenerRequest.Url.AbsolutePath;
var query = listenerRequest.Url.Query; var query = listenerRequest.Url.Query;
@@ -38,7 +38,7 @@ namespace WireMock
var listenerHeaders = listenerRequest.Headers; var listenerHeaders = listenerRequest.Headers;
var headers = listenerHeaders.AllKeys.ToDictionary(k => k, k => listenerHeaders[k]); var headers = listenerHeaders.AllKeys.ToDictionary(k => k, k => listenerHeaders[k]);
return new Request(path, query, verb, body, headers); return new RequestMessage(path, query, verb, body, headers);
} }
/// <summary> /// <summary>

View File

@@ -18,19 +18,19 @@ namespace WireMock
/// <summary> /// <summary>
/// The map. /// The map.
/// </summary> /// </summary>
/// <param name="response"> /// <param name="responseMessage">
/// The response. /// The response.
/// </param> /// </param>
/// <param name="result"> /// <param name="result">
/// The result. /// The result.
/// </param> /// </param>
public void Map(Response response, HttpListenerResponse result) public void Map(ResponseMessage responseMessage, HttpListenerResponse result)
{ {
result.StatusCode = response.StatusCode; result.StatusCode = responseMessage.StatusCode;
response.Headers.ToList().ForEach(pair => result.AddHeader(pair.Key, pair.Value)); responseMessage.Headers.ToList().ForEach(pair => result.AddHeader(pair.Key, pair.Value));
if (response.Body != null) if (responseMessage.Body != null)
{ {
var content = Encoding.UTF8.GetBytes(response.Body); var content = Encoding.UTF8.GetBytes(responseMessage.Body);
result.OutputStream.Write(content, 0, content.Length); result.OutputStream.Write(content, 0, content.Length);
} }
} }

View File

@@ -16,12 +16,12 @@ namespace WireMock
/// <summary> /// <summary>
/// The provide response. /// The provide response.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="Task"/>. /// The <see cref="Task"/>.
/// </returns> /// </returns>
Task<Response> ProvideResponse(Request request); Task<ResponseMessage> ProvideResponse(RequestMessage requestMessage);
} }
} }

View File

@@ -16,12 +16,12 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
bool IsSatisfiedBy([NotNull] Request request); bool IsSatisfiedBy([NotNull] RequestMessage requestMessage);
} }
} }

View File

@@ -44,15 +44,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy(Request request) public bool IsSatisfiedBy(RequestMessage requestMessage)
{ {
return bodyRegex.IsMatch(request.Body); return bodyRegex.IsMatch(requestMessage.Body);
} }
} }
} }

View File

@@ -25,7 +25,7 @@ namespace WireMock.RequestBuilders
/// <summary> /// <summary>
/// The requests. /// The requests.
/// </summary> /// </summary>
public class RequestBuilder : CompositeRequestSpec, IVerbRequestBuilder, IHeadersRequestBuilder, IParamsRequestBuilder public class Request : CompositeRequestSpec, IVerbRequestBuilder, IHeadersRequestBuilder, IParamsRequestBuilder
{ {
/// <summary> /// <summary>
/// The _request specs. /// The _request specs.
@@ -33,12 +33,12 @@ namespace WireMock.RequestBuilders
private readonly IList<ISpecifyRequests> _requestSpecs; private readonly IList<ISpecifyRequests> _requestSpecs;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RequestBuilder"/> class. /// Initializes a new instance of the <see cref="Request"/> class.
/// </summary> /// </summary>
/// <param name="requestSpecs"> /// <param name="requestSpecs">
/// The request specs. /// The request specs.
/// </param> /// </param>
private RequestBuilder(IList<ISpecifyRequests> requestSpecs) : base(requestSpecs) private Request(IList<ISpecifyRequests> requestSpecs) : base(requestSpecs)
{ {
_requestSpecs = requestSpecs; _requestSpecs = requestSpecs;
} }
@@ -55,7 +55,7 @@ namespace WireMock.RequestBuilders
public static IVerbRequestBuilder WithUrl(string url) public static IVerbRequestBuilder WithUrl(string url)
{ {
var specs = new List<ISpecifyRequests>(); var specs = new List<ISpecifyRequests>();
var requests = new RequestBuilder(specs); var requests = new Request(specs);
specs.Add(new RequestUrlSpec(url)); specs.Add(new RequestUrlSpec(url));
return requests; return requests;
} }
@@ -72,7 +72,7 @@ namespace WireMock.RequestBuilders
public static IVerbRequestBuilder WithPath(string path) public static IVerbRequestBuilder WithPath(string path)
{ {
var specs = new List<ISpecifyRequests>(); var specs = new List<ISpecifyRequests>();
var requests = new RequestBuilder(specs); var requests = new Request(specs);
specs.Add(new RequestPathSpec(path)); specs.Add(new RequestPathSpec(path));
return requests; return requests;
} }

View File

@@ -52,15 +52,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy([NotNull] Request request) public bool IsSatisfiedBy([NotNull] RequestMessage requestMessage)
{ {
string headerValue = request.Headers[name]; string headerValue = requestMessage.Headers[name];
return patternRegex.IsMatch(headerValue); return patternRegex.IsMatch(headerValue);
} }
} }

View File

@@ -25,7 +25,7 @@ namespace WireMock
/// <summary> /// <summary>
/// The request. /// The request.
/// </summary> /// </summary>
public class Request public class RequestMessage
{ {
/// <summary> /// <summary>
/// The _params. /// The _params.
@@ -33,7 +33,7 @@ namespace WireMock
private readonly Dictionary<string, List<string>> _params = new Dictionary<string, List<string>>(); private readonly Dictionary<string, List<string>> _params = new Dictionary<string, List<string>>();
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Request"/> class. /// Initializes a new instance of the <see cref="RequestMessage"/> class.
/// </summary> /// </summary>
/// <param name="path"> /// <param name="path">
/// The path. /// The path.
@@ -50,7 +50,7 @@ namespace WireMock
/// <param name="headers"> /// <param name="headers">
/// The headers. /// The headers.
/// </param> /// </param>
public Request(string path, string query, string verb, string body, IDictionary<string, string> headers) public RequestMessage(string path, string query, string verb, string body, IDictionary<string, string> headers)
{ {
if (!string.IsNullOrEmpty(query)) if (!string.IsNullOrEmpty(query))
{ {
@@ -127,12 +127,7 @@ namespace WireMock
/// </returns> /// </returns>
public List<string> GetParameter(string key) public List<string> GetParameter(string key)
{ {
if (_params.ContainsKey(key)) return _params.ContainsKey(key) ? _params[key] : new List<string>();
{
return _params[key];
}
return new List<string>();
} }
} }
} }

View File

@@ -52,15 +52,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy([NotNull] Request request) public bool IsSatisfiedBy([NotNull] RequestMessage requestMessage)
{ {
return request.GetParameter(_key).Intersect(_values).Count() == _values.Count; return requestMessage.GetParameter(_key).Intersect(_values).Count() == _values.Count;
} }
} }
} }

View File

@@ -44,15 +44,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy([NotNull] Request request) public bool IsSatisfiedBy([NotNull] RequestMessage requestMessage)
{ {
return _path.IsMatch(request.Path); return _path.IsMatch(requestMessage.Path);
} }
} }
} }

View File

@@ -44,15 +44,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy(Request request) public bool IsSatisfiedBy(RequestMessage requestMessage)
{ {
return urlRegex.IsMatch(request.Url); return urlRegex.IsMatch(requestMessage.Url);
} }
} }
} }

View File

@@ -41,15 +41,15 @@ namespace WireMock
/// <summary> /// <summary>
/// The is satisfied by. /// The is satisfied by.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsSatisfiedBy([NotNull] Request request) public bool IsSatisfiedBy([NotNull] RequestMessage requestMessage)
{ {
return request.Verb == _verb; return requestMessage.Verb == _verb;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -21,12 +21,12 @@ namespace WireMock.ResponseBuilders
/// <summary> /// <summary>
/// The responses. /// The responses.
/// </summary> /// </summary>
public class ResponseBuilder : IHeadersResponseBuilder public class Response : IHeadersResponseBuilder
{ {
/// <summary> /// <summary>
/// The _response. /// The _response.
/// </summary> /// </summary>
private readonly Response _response; private readonly ResponseMessage _responseMessage;
/// <summary> /// <summary>
/// The _delay. /// The _delay.
@@ -34,14 +34,14 @@ namespace WireMock.ResponseBuilders
private TimeSpan _delay = TimeSpan.Zero; private TimeSpan _delay = TimeSpan.Zero;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ResponseBuilder"/> class. /// Initializes a new instance of the <see cref="Response"/> class.
/// </summary> /// </summary>
/// <param name="response"> /// <param name="responseMessage">
/// The response. /// The response.
/// </param> /// </param>
public ResponseBuilder(Response response) public Response(ResponseMessage responseMessage)
{ {
_response = response; _responseMessage = responseMessage;
} }
/// <summary> /// <summary>
@@ -73,23 +73,23 @@ namespace WireMock.ResponseBuilders
/// </returns> /// </returns>
public static IHeadersResponseBuilder WithStatusCode(int code) public static IHeadersResponseBuilder WithStatusCode(int code)
{ {
var response = new Response { StatusCode = code }; var response = new ResponseMessage { StatusCode = code };
return new ResponseBuilder(response); return new Response(response);
} }
/// <summary> /// <summary>
/// The provide response. /// The provide response.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="Task"/>. /// The <see cref="Task"/>.
/// </returns> /// </returns>
public async Task<Response> ProvideResponse(Request request) public async Task<ResponseMessage> ProvideResponse(RequestMessage requestMessage)
{ {
await Task.Delay(_delay); await Task.Delay(_delay);
return _response; return _responseMessage;
} }
/// <summary> /// <summary>
@@ -106,7 +106,7 @@ namespace WireMock.ResponseBuilders
/// </returns> /// </returns>
public IHeadersResponseBuilder WithHeader(string name, string value) public IHeadersResponseBuilder WithHeader(string name, string value)
{ {
_response.AddHeader(name, value); _responseMessage.AddHeader(name, value);
return this; return this;
} }
@@ -121,7 +121,7 @@ namespace WireMock.ResponseBuilders
/// </returns> /// </returns>
public IDelayResponseBuilder WithBody(string body) public IDelayResponseBuilder WithBody(string body)
{ {
_response.Body = body; _responseMessage.Body = body;
return this; return this;
} }

View File

@@ -21,7 +21,7 @@ namespace WireMock
/// <summary> /// <summary>
/// The response. /// The response.
/// </summary> /// </summary>
public class Response public class ResponseMessage
{ {
/// <summary> /// <summary>
/// The _headers. /// The _headers.

View File

@@ -50,29 +50,29 @@ namespace WireMock
/// <summary> /// <summary>
/// The response to. /// The response to.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="Task"/>. /// The <see cref="Task"/>.
/// </returns> /// </returns>
public Task<Response> ResponseTo(Request request) public Task<ResponseMessage> ResponseTo(RequestMessage requestMessage)
{ {
return _provider.ProvideResponse(request); return _provider.ProvideResponse(requestMessage);
} }
/// <summary> /// <summary>
/// The is request handled. /// The is request handled.
/// </summary> /// </summary>
/// <param name="request"> /// <param name="requestMessage">
/// The request. /// The request.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="bool"/>. /// The <see cref="bool"/>.
/// </returns> /// </returns>
public bool IsRequestHandled(Request request) public bool IsRequestHandled(RequestMessage requestMessage)
{ {
return _requestSpec.IsSatisfiedBy(request); return _requestSpec.IsSatisfiedBy(requestMessage);
} }
} }
} }

View File

@@ -43,10 +43,10 @@ namespace WireMock.Net.Tests
_server = FluentMockServer.Start(); _server = FluentMockServer.Start();
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/foo") .WithUrl("/foo")
.UsingGet()) .UsingGet())
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(200) .WithStatusCode(200)
.WithBody(@"{ msg: ""Hello world!""}")); .WithBody(@"{ msg: ""Hello world!""}"));
@@ -100,7 +100,7 @@ namespace WireMock.Net.Tests
await new HttpClient().GetAsync("http://localhost:" + _server.Port + "/bar"); await new HttpClient().GetAsync("http://localhost:" + _server.Port + "/bar");
// then // then
var result = _server.SearchLogsFor(RequestBuilder.WithUrl("/b.*")); var result = _server.SearchLogsFor(Request.WithUrl("/b.*"));
Check.That(result).HasSize(1); Check.That(result).HasSize(1);
var requestLogged = result.First(); var requestLogged = result.First();
Check.That(requestLogged.Url).IsEqualTo("/bar"); Check.That(requestLogged.Url).IsEqualTo("/bar");
@@ -127,10 +127,10 @@ namespace WireMock.Net.Tests
_server = FluentMockServer.Start(); _server = FluentMockServer.Start();
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/foo") .WithUrl("/foo")
.UsingGet()) .UsingGet())
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(200) .WithStatusCode(200)
.WithBody(@"{ msg: ""Hello world!""}")); .WithBody(@"{ msg: ""Hello world!""}"));
@@ -149,17 +149,17 @@ namespace WireMock.Net.Tests
_server = FluentMockServer.Start(); _server = FluentMockServer.Start();
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/foo") .WithUrl("/foo")
.UsingGet()) .UsingGet())
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(307) .WithStatusCode(307)
.WithHeader("Location", "/bar")); .WithHeader("Location", "/bar"));
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/bar") .WithUrl("/bar")
.UsingGet()) .UsingGet())
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(200) .WithStatusCode(200)
.WithBody("REDIRECT SUCCESSFUL")); .WithBody("REDIRECT SUCCESSFUL"));
@@ -178,9 +178,9 @@ namespace WireMock.Net.Tests
_server = FluentMockServer.Start(); _server = FluentMockServer.Start();
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/*")) .WithUrl("/*"))
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(200) .WithStatusCode(200)
.WithBody(@"{ msg: ""Hello world!""}") .WithBody(@"{ msg: ""Hello world!""}")
.AfterDelay(TimeSpan.FromMilliseconds(2000))); .AfterDelay(TimeSpan.FromMilliseconds(2000)));
@@ -202,9 +202,9 @@ namespace WireMock.Net.Tests
_server = FluentMockServer.Start(); _server = FluentMockServer.Start();
_server.AddRequestProcessingDelay(TimeSpan.FromMilliseconds(2000)); _server.AddRequestProcessingDelay(TimeSpan.FromMilliseconds(2000));
_server _server
.Given(RequestBuilder .Given(Request
.WithUrl("/*")) .WithUrl("/*"))
.RespondWith(ResponseBuilder .RespondWith(Response
.WithStatusCode(200) .WithStatusCode(200)
.WithBody(@"{ msg: ""Hello world!""}")); .WithBody(@"{ msg: ""Hello world!""}"));

View File

@@ -49,8 +49,8 @@ namespace WireMock.Net.Tests
await client.GetAsync(MapperServer.UrlPrefix + "toto"); await client.GetAsync(MapperServer.UrlPrefix + "toto");
// then // then
Check.That(MapperServer.LastRequest).IsNotNull(); Check.That(MapperServer.LastRequestMessage).IsNotNull();
Check.That(MapperServer.LastRequest.Url).IsEqualTo("/toto"); Check.That(MapperServer.LastRequestMessage.Url).IsEqualTo("/toto");
} }
[Test] [Test]
@@ -63,8 +63,8 @@ namespace WireMock.Net.Tests
await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!")); await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!"));
// then // then
Check.That(MapperServer.LastRequest).IsNotNull(); Check.That(MapperServer.LastRequestMessage).IsNotNull();
Check.That(MapperServer.LastRequest.Verb).IsEqualTo("put"); Check.That(MapperServer.LastRequestMessage.Verb).IsEqualTo("put");
} }
[Test] [Test]
@@ -77,8 +77,8 @@ namespace WireMock.Net.Tests
await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!")); await client.PutAsync(MapperServer.UrlPrefix, new StringContent("Hello!"));
// then // then
Check.That(MapperServer.LastRequest).IsNotNull(); Check.That(MapperServer.LastRequestMessage).IsNotNull();
Check.That(MapperServer.LastRequest.Body).IsEqualTo("Hello!"); Check.That(MapperServer.LastRequestMessage.Body).IsEqualTo("Hello!");
} }
[Test] [Test]
@@ -92,9 +92,9 @@ namespace WireMock.Net.Tests
await client.GetAsync(MapperServer.UrlPrefix); await client.GetAsync(MapperServer.UrlPrefix);
// then // then
Check.That(MapperServer.LastRequest).IsNotNull(); Check.That(MapperServer.LastRequestMessage).IsNotNull();
Check.That(MapperServer.LastRequest.Headers).Not.IsNullOrEmpty(); Check.That(MapperServer.LastRequestMessage.Headers).Not.IsNullOrEmpty();
Check.That(MapperServer.LastRequest.Headers.Contains(new KeyValuePair<string, string>("X-Alex", "1706"))).IsTrue(); Check.That(MapperServer.LastRequestMessage.Headers.Contains(new KeyValuePair<string, string>("X-Alex", "1706"))).IsTrue();
} }
[Test] [Test]
@@ -107,9 +107,9 @@ namespace WireMock.Net.Tests
await client.GetAsync(MapperServer.UrlPrefix + "index.html?id=toto"); await client.GetAsync(MapperServer.UrlPrefix + "index.html?id=toto");
// then // then
Check.That(MapperServer.LastRequest).IsNotNull(); Check.That(MapperServer.LastRequestMessage).IsNotNull();
Check.That(MapperServer.LastRequest.Path).EndsWith("/index.html"); Check.That(MapperServer.LastRequestMessage.Path).EndsWith("/index.html");
Check.That(MapperServer.LastRequest.GetParameter("id")).HasSize(1); Check.That(MapperServer.LastRequestMessage.GetParameter("id")).HasSize(1);
} }
[TearDown] [TearDown]
@@ -120,22 +120,22 @@ namespace WireMock.Net.Tests
private class MapperServer : TinyHttpServer private class MapperServer : TinyHttpServer
{ {
private static volatile Request _lastRequest; private static volatile RequestMessage _lastRequestMessage;
private MapperServer(string urlPrefix, Action<HttpListenerContext> httpHandler) : base(urlPrefix, httpHandler) private MapperServer(string urlPrefix, Action<HttpListenerContext> httpHandler) : base(urlPrefix, httpHandler)
{ {
} }
public static Request LastRequest public static RequestMessage LastRequestMessage
{ {
get get
{ {
return _lastRequest; return _lastRequestMessage;
} }
private set private set
{ {
_lastRequest = value; _lastRequestMessage = value;
} }
} }
@@ -149,7 +149,7 @@ namespace WireMock.Net.Tests
UrlPrefix, UrlPrefix,
context => context =>
{ {
LastRequest = new HttpListenerRequestMapper().Map(context.Request); LastRequestMessage = new HttpListenerRequestMapper().Map(context.Request);
context.Response.Close(); context.Response.Close();
}); });
((TinyHttpServer)server).Start(); ((TinyHttpServer)server).Start();
@@ -159,7 +159,7 @@ namespace WireMock.Net.Tests
public new void Stop() public new void Stop()
{ {
base.Stop(); base.Stop();
LastRequest = null; LastRequestMessage = null;
} }
} }
} }

View File

@@ -37,7 +37,7 @@ namespace WireMock.Net.Tests
public void Should_map_status_code_from_original_response() public void Should_map_status_code_from_original_response()
{ {
// given // given
var response = new Response { StatusCode = 404 }; var response = new ResponseMessage { StatusCode = 404 };
var httpListenerResponse = CreateHttpListenerResponse(); var httpListenerResponse = CreateHttpListenerResponse();
// when // when
@@ -51,7 +51,7 @@ namespace WireMock.Net.Tests
public void Should_map_headers_from_original_response() public void Should_map_headers_from_original_response()
{ {
// given // given
var response = new Response(); var response = new ResponseMessage();
response.AddHeader("cache-control", "no-cache"); response.AddHeader("cache-control", "no-cache");
var httpListenerResponse = CreateHttpListenerResponse(); var httpListenerResponse = CreateHttpListenerResponse();
@@ -68,7 +68,7 @@ namespace WireMock.Net.Tests
public void Should_map_body_from_original_response() public void Should_map_body_from_original_response()
{ {
// given // given
var response = new Response(); var response = new ResponseMessage();
response.Body = "Hello !!!"; response.Body = "Hello !!!";
var httpListenerResponse = CreateHttpListenerResponse(); var httpListenerResponse = CreateHttpListenerResponse();

View File

@@ -21,7 +21,7 @@ namespace WireMock.Net.Tests
public void Should_handle_empty_query() public void Should_handle_empty_query()
{ {
// given // given
var request = new Request("/foo", string.Empty, "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(request.GetParameter("foo")).IsEmpty(); Check.That(request.GetParameter("foo")).IsEmpty();
@@ -31,7 +31,7 @@ namespace WireMock.Net.Tests
public void Should_parse_query_params() public void Should_parse_query_params()
{ {
// given // given
var request = new Request("/foo", "foo=bar&multi=1&multi=2", "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", "foo=bar&multi=1&multi=2", "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(request.GetParameter("foo")).Contains("bar"); Check.That(request.GetParameter("foo")).Contains("bar");

View File

@@ -22,10 +22,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_url() public void Should_specify_requests_matching_given_url()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo"); var spec = Request.WithUrl("/foo");
// when // when
var request = new Request("/foo", string.Empty, "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -35,10 +35,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_url_prefix() public void Should_specify_requests_matching_given_url_prefix()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo*"); var spec = Request.WithUrl("/foo*");
// when // when
var request = new Request("/foo/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -48,10 +48,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_not_matching_given_url() public void Should_exclude_requests_not_matching_given_url()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo"); var spec = Request.WithUrl("/foo");
// when // when
var request = new Request("/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -61,10 +61,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_path() public void Should_specify_requests_matching_given_path()
{ {
// given // given
var spec = RequestBuilder.WithPath("/foo"); var spec = Request.WithPath("/foo");
// when // when
var request = new Request("/foo", "?param=1", "blabla", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", "?param=1", "blabla", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -74,10 +74,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_url_and_method() public void Should_specify_requests_matching_given_url_and_method()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingPut(); var spec = Request.WithUrl("/foo").UsingPut();
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -87,10 +87,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_matching_given_url_but_not_http_method() public void Should_exclude_requests_matching_given_url_but_not_http_method()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingPut(); var spec = Request.WithUrl("/foo").UsingPut();
// when // when
var request = new Request("/foo", string.Empty, "POST", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "POST", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -100,10 +100,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_matching_given_http_method_but_not_url() public void Should_exclude_requests_matching_given_http_method_but_not_url()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/bar").UsingPut(); var spec = Request.WithUrl("/bar").UsingPut();
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -113,10 +113,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_url_and_headers() public void Should_specify_requests_matching_given_url_and_headers()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata"); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -126,10 +126,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_not_matching_given_headers() public void Should_exclude_requests_not_matching_given_headers()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tatata"); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tatata");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -139,10 +139,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_not_matching_given_headers_ignorecase() public void Should_exclude_requests_not_matching_given_headers_ignorecase()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "abc", false); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "abc", false);
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "ABC" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "ABC" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -152,10 +152,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_header_prefix() public void Should_specify_requests_matching_given_header_prefix()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata*"); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata*");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "TaTaTa" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "TaTaTa" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -165,10 +165,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_body() public void Should_specify_requests_matching_given_body()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody(".*Hello world!.*"); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithBody(".*Hello world!.*");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -178,10 +178,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_body_as_wildcard() public void Should_specify_requests_matching_given_body_as_wildcard()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody("H.*o"); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithBody("H.*o");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -191,10 +191,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_not_matching_given_body() public void Should_exclude_requests_not_matching_given_body()
{ {
// given // given
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody(" Hello world! "); var spec = Request.WithUrl("/foo").UsingAnyVerb().WithBody(" Hello world! ");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string> { { "X-toto", "tatata" } }); var request = new RequestMessage("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string> { { "X-toto", "tatata" } });
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();
@@ -204,10 +204,10 @@ namespace WireMock.Net.Tests
public void Should_specify_requests_matching_given_params() public void Should_specify_requests_matching_given_params()
{ {
// given // given
var spec = RequestBuilder.WithPath("/foo").WithParam("bar", "1", "2"); var spec = Request.WithPath("/foo").WithParam("bar", "1", "2");
// when // when
var request = new Request("/foo", "bar=1&bar=2", "Get", "Hello world!", new Dictionary<string, string>()); var request = new RequestMessage("/foo", "bar=1&bar=2", "Get", "Hello world!", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsTrue(); Check.That(spec.IsSatisfiedBy(request)).IsTrue();
@@ -217,10 +217,10 @@ namespace WireMock.Net.Tests
public void Should_exclude_requests_not_matching_given_params() public void Should_exclude_requests_not_matching_given_params()
{ {
// given // given
var spec = RequestBuilder.WithPath("/foo").WithParam("bar", "1"); var spec = Request.WithPath("/foo").WithParam("bar", "1");
// when // when
var request = new Request("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string>()); var request = new RequestMessage("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string>());
// then // then
Check.That(spec.IsSatisfiedBy(request)).IsFalse(); Check.That(spec.IsSatisfiedBy(request)).IsFalse();