mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-24 01:38:53 +02:00
Add more QueryParameterMultipleValueSupport NoComma tests
This commit is contained in:
@@ -104,7 +104,7 @@ public class RequestMessageBodyMatcher : IRequestMatcher
|
|||||||
/// Initializes a new instance of the <see cref="RequestMessageBodyMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageBodyMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="func">The function.</param>
|
/// <param name="func">The function.</param>
|
||||||
public RequestMessageBodyMatcher(Func<IBodyData, bool> func)
|
public RequestMessageBodyMatcher(Func<IBodyData?, bool> func)
|
||||||
{
|
{
|
||||||
BodyDataFunc = Guard.NotNull(func);
|
BodyDataFunc = Guard.NotNull(func);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
using FluentAssertions;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
using WireMock.Matchers.Request;
|
using WireMock.Matchers.Request;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
|
using WireMock.Owin;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace WireMock.Net.Tests.RequestMatchers
|
namespace WireMock.Net.Tests.RequestMatchers
|
||||||
@@ -172,5 +174,25 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
// Assert
|
// Assert
|
||||||
Check.That(score).IsEqualTo(1.0d);
|
Check.That(score).IsEqualTo(1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #849
|
||||||
|
[Fact]
|
||||||
|
public void RequestMessageParamMatcher_With1ParamContainingComma_Using_QueryParameterMultipleValueSupport_NoComma()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var options = new WireMockMiddlewareOptions
|
||||||
|
{
|
||||||
|
QueryParameterMultipleValueSupport = QueryParameterMultipleValueSupport.NoComma
|
||||||
|
};
|
||||||
|
var requestMessage = new RequestMessage(options, new UrlDetails("http://localhostquery=SELECT id, value FROM table WHERE id = 1&test=42"), "GET", "127.0.0.1");
|
||||||
|
var matcher = new RequestMessageParamMatcher(MatchBehaviour.AcceptOnMatch, "query", false, "SELECT id, value FROM table WHERE id = 1");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = new RequestMatchResult();
|
||||||
|
double score = matcher.GetMatchingScore(requestMessage, result);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
score.Should().Be(1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ public class QueryStringParserTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Parse_With1ParamContainingSpacesAndEqualSign()
|
public void Parse_With1ParamContainingSpacesSingleQuoteAndEqualSign()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string query = "?q=SELECT Id from User where username='user@gmail.com'";
|
string query = "?q=SELECT Id from User where username='user@gmail.com'";
|
||||||
@@ -287,6 +287,23 @@ public class QueryStringParserTests
|
|||||||
result["q"].Should().Equal(new WireMockList<string>("SELECT Id from User where username='user@gmail.com'"));
|
result["q"].Should().Equal(new WireMockList<string>("SELECT Id from User where username='user@gmail.com'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Issue #849
|
||||||
|
[Fact]
|
||||||
|
public void Parse_With1ParamContainingComma_Using_QueryParameterMultipleValueSupport_NoComma()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
string query = "?query=SELECT id, value FROM table WHERE id = 1&test=42";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = QueryStringParser.Parse(query, QueryParameterMultipleValueSupport.NoComma);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Count.Should().Be(2);
|
||||||
|
result["query"].Should().Equal(new WireMockList<string>("SELECT id, value FROM table WHERE id = 1"));
|
||||||
|
result["test"].Should().Equal(new WireMockList<string>("42"));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Parse_WithComplex()
|
public void Parse_WithComplex()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user