Add more tests for JmesPathMatchers and StringUtils.ParseMatchOperator (#1009)

* Add more tests for JmesPathMatchers and StringUtils.ParseMatchOperator

* .

* prio
This commit is contained in:
Stef Heyenrath
2023-10-16 17:13:52 +02:00
committed by GitHub
parent f7cd4b100e
commit 2f29d80336
8 changed files with 185 additions and 23 deletions

View File

@@ -300,6 +300,31 @@ public class RequestMessageBodyMatcherTests
Check.That(score).IsEqualTo(1.0d);
}
[Fact]
public void RequestMessageBodyMatcher_GetMatchingScore_BodyAsJson_JmesPathMatchers()
{
// Arrange
var body = new BodyData
{
BodyAsJson = new { requestId = "1", value = "A" },
DetectedBodyType = BodyType.Json
};
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", body);
var jmesMatcher1 = new JmesPathMatcher("requestId == '1'");
var jmesMatcher2 = new JmesPathMatcher("value == 'A'");
var bodyMatcher = new RequestMessageBodyMatcher(MatchOperator.And, jmesMatcher1, jmesMatcher2);
// Act
var result = new RequestMatchResult();
double score = bodyMatcher.GetMatchingScore(requestMessage, result);
// Assert
score.Should().Be(MatchScores.Perfect);
}
[Theory]
[InlineData(null, 0.0)]
[InlineData(new byte[0], 0.0)]