mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-17 22:50:05 +02:00
Fixed Issue #1
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using NFluent;
|
||||
using NUnit.Framework;
|
||||
using WireMock.RequestBuilders;
|
||||
|
||||
[module:
|
||||
SuppressMessage("StyleCop.CSharp.DocumentationRules",
|
||||
"SA1600:ElementsMustBeDocumented",
|
||||
SuppressMessage("StyleCop.CSharp.DocumentationRules",
|
||||
"SA1600:ElementsMustBeDocumented",
|
||||
Justification = "Reviewed. Suppression is OK here, as it's a tests class.")]
|
||||
[module:
|
||||
SuppressMessage("StyleCop.CSharp.DocumentationRules",
|
||||
"SA1633:FileMustHaveHeader",
|
||||
SuppressMessage("StyleCop.CSharp.DocumentationRules",
|
||||
"SA1633:FileMustHaveHeader",
|
||||
Justification = "Reviewed. Suppression is OK here, as unknown copyright and company.")]
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace WireMock.Net.Tests
|
||||
@@ -21,7 +22,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_url()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo");
|
||||
var spec = RequestBuilder.WithUrl("/foo");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
|
||||
@@ -34,7 +35,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_url_prefix()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo*");
|
||||
var spec = RequestBuilder.WithUrl("/foo*");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
|
||||
@@ -47,7 +48,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_not_matching_given_url()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo");
|
||||
var spec = RequestBuilder.WithUrl("/foo");
|
||||
|
||||
// when
|
||||
var request = new Request("/bar", string.Empty, "blabla", "whatever", new Dictionary<string, string>());
|
||||
@@ -60,7 +61,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_path()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithPath("/foo");
|
||||
var spec = RequestBuilder.WithPath("/foo");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", "?param=1", "blabla", "whatever", new Dictionary<string, string>());
|
||||
@@ -73,7 +74,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_url_and_method()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingPut();
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingPut();
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>());
|
||||
@@ -86,7 +87,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_matching_given_url_but_not_http_method()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingPut();
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingPut();
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "POST", "whatever", new Dictionary<string, string>());
|
||||
@@ -99,7 +100,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_matching_given_http_method_but_not_url()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/bar").UsingPut();
|
||||
var spec = RequestBuilder.WithUrl("/bar").UsingPut();
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string>());
|
||||
@@ -112,11 +113,11 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_url_and_headers()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } });
|
||||
|
||||
|
||||
// then
|
||||
Check.That(spec.IsSatisfiedBy(request)).IsTrue();
|
||||
}
|
||||
@@ -125,7 +126,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_not_matching_given_headers()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tatata");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tatata");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tata" } });
|
||||
@@ -134,14 +135,27 @@ namespace WireMock.Net.Tests
|
||||
Check.That(spec.IsSatisfiedBy(request)).IsFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Should_exclude_requests_not_matching_given_headers_ignorecase()
|
||||
{
|
||||
// given
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "abc", false);
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "ABC" } });
|
||||
|
||||
// then
|
||||
Check.That(spec.IsSatisfiedBy(request)).IsFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Should_specify_requests_matching_given_header_prefix()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata*");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithHeader("X-toto", "tata*");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "tatata" } });
|
||||
var request = new Request("/foo", string.Empty, "PUT", "whatever", new Dictionary<string, string> { { "X-toto", "TaTaTa" } });
|
||||
|
||||
// then
|
||||
Check.That(spec.IsSatisfiedBy(request)).IsTrue();
|
||||
@@ -151,7 +165,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_body()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithBody(" Hello world! ");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody(".*Hello world!.*");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } });
|
||||
@@ -164,7 +178,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_body_as_wildcard()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithBody("H*o wor?d!");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody("H.*o");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "Hello world!", new Dictionary<string, string> { { "X-toto", "tatata" } });
|
||||
@@ -177,7 +191,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_not_matching_given_body()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithUrl("/foo").UsingAnyVerb().WithBody(" Hello world! ");
|
||||
var spec = RequestBuilder.WithUrl("/foo").UsingAnyVerb().WithBody(" Hello world! ");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string> { { "X-toto", "tatata" } });
|
||||
@@ -190,7 +204,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_specify_requests_matching_given_params()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithPath("/foo").WithParam("bar", "1", "2");
|
||||
var spec = RequestBuilder.WithPath("/foo").WithParam("bar", "1", "2");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", "bar=1&bar=2", "Get", "Hello world!", new Dictionary<string, string>());
|
||||
@@ -203,7 +217,7 @@ namespace WireMock.Net.Tests
|
||||
public void Should_exclude_requests_not_matching_given_params()
|
||||
{
|
||||
// given
|
||||
var spec = Requests.WithPath("/foo").WithParam("bar", "1");
|
||||
var spec = RequestBuilder.WithPath("/foo").WithParam("bar", "1");
|
||||
|
||||
// when
|
||||
var request = new Request("/foo", string.Empty, "PUT", "XXXXXXXXXXX", new Dictionary<string, string>());
|
||||
|
||||
Reference in New Issue
Block a user