JmesPathMatcherTests (#998)

This commit is contained in:
Stef Heyenrath
2023-09-27 21:42:34 +02:00
committed by GitHub
parent b63076a9ac
commit 9f9fc85a64
3 changed files with 79 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
@@ -163,4 +164,30 @@ public class JmesPathMatcherTests
// Assert
Check.That(match).IsEqualTo(0.0);
}
[Fact]
public void JmesPathMatcher_IsMatch_MultiplePatternsUsingMatchOperatorAnd()
{
// Assign
var matcher = new JmesPathMatcher(MatchOperator.And, "things.x == 'RequiredThing'", "things.x == 'abc'");
// Act
double score = matcher.IsMatch(JObject.Parse("{ \"things\": { \"x\": \"RequiredThing\" } }")).Score;
// Assert
score.Should().Be(0);
}
[Fact]
public void JmesPathMatcher_IsMatch_MultiplePatternsUsingMatchOperatorOr()
{
// Assign
var matcher = new JmesPathMatcher(MatchOperator.Or, "things.x == 'RequiredThing'", "things.x == 'abc'");
// Act
double score = matcher.IsMatch(JObject.Parse("{ \"things\": { \"x\": \"RequiredThing\" } }")).Score;
// Assert
score.Should().Be(1);
}
}