Fix match logic (#604)

This commit is contained in:
Stef Heyenrath
2021-04-18 19:30:03 +00:00
committed by GitHub
parent b17840cea9
commit fbecd3b119
3 changed files with 208 additions and 192 deletions

View File

@@ -209,13 +209,15 @@ namespace WireMock.Net.Tests.RequestMatchers
Check.That(score).IsEqualTo(1.0d);
}
[Fact]
public void RequestMessageBodyMatcher_GetMatchingScore_BodyAsBytes_IObjectMatcher()
[Theory]
[InlineData(new byte[] { 1 })]
[InlineData(new byte[] { 48 })]
public void RequestMessageBodyMatcher_GetMatchingScore_BodyAsBytes_IObjectMatcher(byte[] bytes)
{
// Assign
var body = new BodyData
{
BodyAsBytes = new byte[] { 1 },
BodyAsBytes = bytes,
DetectedBodyType = BodyType.Bytes
};
var objectMatcherMock = new Mock<IObjectMatcher>();

View File

@@ -2,6 +2,7 @@
using NFluent;
using System;
using System.Text;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Matchers.Request;
using WireMock.Models;
@@ -307,17 +308,20 @@ namespace WireMock.Net.Tests
Check.That(requestBuilder.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
}
[Fact]
public void Request_WithBodyAsBytes_ExactObjectMatcher_true()
[Theory]
[InlineData(new byte[] { 1 }, BodyType.Bytes)]
[InlineData(new byte[] { 48, 49, 50 }, BodyType.Bytes)]
[InlineData(new byte[] { 48, 49, 50 }, BodyType.String)]
public void Request_WithBodyAsBytes_ExactObjectMatcher_true(byte[] bytes, BodyType detectedBodyType)
{
// Assign
byte[] body = { 123 };
byte[] body = bytes;
var requestBuilder = Request.Create().UsingAnyMethod().WithBody(body);
var bodyData = new BodyData
{
BodyAsBytes = new byte[] { 123 },
DetectedBodyType = BodyType.Bytes
BodyAsBytes = bytes,
DetectedBodyType = detectedBodyType
};
// Act
@@ -325,7 +329,7 @@ namespace WireMock.Net.Tests
// Assert
var requestMatchResult = new RequestMatchResult();
Check.That(requestBuilder.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
requestBuilder.GetMatchingScore(request, requestMatchResult).Should().Be(1.0);
}
}
}