mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-12 05:11:31 +01:00
* wip * ... * . * ... * ... * path * url * b * t * client * . * RequestMessageMethodMatcherTests * . * h * . * fix tests * .
68 lines
1.6 KiB
C#
68 lines
1.6 KiB
C#
using NFluent;
|
|
using WireMock.Matchers;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Matchers;
|
|
|
|
public class XPathMatcherTests
|
|
{
|
|
[Fact]
|
|
public void XPathMatcher_GetName()
|
|
{
|
|
// Assign
|
|
var matcher = new XPathMatcher("X");
|
|
|
|
// Act
|
|
string name = matcher.Name;
|
|
|
|
// Assert
|
|
Check.That(name).Equals("XPathMatcher");
|
|
}
|
|
|
|
[Fact]
|
|
public void XPathMatcher_GetPatterns()
|
|
{
|
|
// Assign
|
|
var matcher = new XPathMatcher("X");
|
|
|
|
// Act
|
|
var patterns = matcher.GetPatterns();
|
|
|
|
// Assert
|
|
Check.That(patterns).ContainsExactly("X");
|
|
}
|
|
|
|
[Fact]
|
|
public void XPathMatcher_IsMatch_AcceptOnMatch()
|
|
{
|
|
// Assign
|
|
string xml = @"
|
|
<todo-list>
|
|
<todo-item id='a1'>abc</todo-item>
|
|
</todo-list>";
|
|
var matcher = new XPathMatcher("/todo-list[count(todo-item) = 1]");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch(xml);
|
|
|
|
// Assert
|
|
Check.That(result).IsEqualTo(1.0);
|
|
}
|
|
|
|
[Fact]
|
|
public void XPathMatcher_IsMatch_RejectOnMatch()
|
|
{
|
|
// Assign
|
|
string xml = @"
|
|
<todo-list>
|
|
<todo-item id='a1'>abc</todo-item>
|
|
</todo-list>";
|
|
var matcher = new XPathMatcher(MatchBehaviour.RejectOnMatch, false, MatchOperator.Or, "/todo-list[count(todo-item) = 1]");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch(xml);
|
|
|
|
// Assert
|
|
Check.That(result).IsEqualTo(0.0);
|
|
}
|
|
} |