mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-22 01:20:14 +01:00
WithParam (#159)
This commit is contained in:
@@ -9,7 +9,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
public class RequestMessageParamMatcherTests
|
||||
{
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_AllMatch()
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_KeyWithValuesPresentInUrl_MatchExactOnStringValues()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key=test1,test2"), "GET", "127.0.0.1");
|
||||
@@ -24,7 +24,22 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_PartialMatch()
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_KeyWithValuesPresentInUrl_MatchExactOnExactMatchers()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key=test1,test2"), "GET", "127.0.0.1");
|
||||
var matcher = new RequestMessageParamMatcher(MatchBehaviour.AcceptOnMatch, "key", new IStringMatcher[] { new ExactMatcher("test1"), new ExactMatcher("test2") });
|
||||
|
||||
// Act
|
||||
var result = new RequestMatchResult();
|
||||
double score = matcher.GetMatchingScore(requestMessage, result);
|
||||
|
||||
// Assert
|
||||
Check.That(score).IsEqualTo(1.0d);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_KeyWithValuesPresentInUrl_MatchOnKeyWithValues_PartialMatch()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key=test0,test2"), "GET", "127.0.0.1");
|
||||
@@ -39,7 +54,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresent()
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresentInUrl_MatchOnKeyWithValues_Fails()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key"), "GET", "127.0.0.1");
|
||||
@@ -54,7 +69,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresent_WithNull()
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresentInUrl_MatchOnKey()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key"), "GET", "127.0.0.1");
|
||||
@@ -69,7 +84,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresent_WithEmptyArray()
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_OnlyKeyPresentInUrl_MatchOnKeyWithEmptyArray()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key"), "GET", "127.0.0.1");
|
||||
@@ -82,5 +97,20 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assert
|
||||
Check.That(score).IsEqualTo(1.0d);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestMessageParamMatcher_GetMatchingScore_KeyWithValuePresentInUrl_MatchOnKey()
|
||||
{
|
||||
// Assign
|
||||
var requestMessage = new RequestMessage(new Uri("http://localhost?key=frank@contoso.com"), "GET", "127.0.0.1");
|
||||
var matcher = new RequestMessageParamMatcher(MatchBehaviour.AcceptOnMatch, "key");
|
||||
|
||||
// Act
|
||||
var result = new RequestMatchResult();
|
||||
double score = matcher.GetMatchingScore(requestMessage, result);
|
||||
|
||||
// Assert
|
||||
Check.That(score).IsEqualTo(1.0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user