mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 22:33:35 +01:00
* RejectOnMatch (wip) * RejectOnMatch (wip) * RejectOnMatch (wip) * RejectOnMatch (wip) * docs: improve sample app matcher to show use of reject on match * Reworked code review comments
87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using NFluent;
|
|
using WireMock.Matchers;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Matchers
|
|
{
|
|
public class SimMetricsMatcherTests
|
|
{
|
|
[Fact]
|
|
public void SimMetricsMatcher_GetName()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher("X");
|
|
|
|
// Act
|
|
string name = matcher.Name;
|
|
|
|
// Assert
|
|
Check.That(name).Equals("SimMetricsMatcher.Levenstein");
|
|
}
|
|
|
|
[Fact]
|
|
public void SimMetricsMatcher_GetPatterns()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher("X");
|
|
|
|
// Act
|
|
string[] patterns = matcher.GetPatterns();
|
|
|
|
// Assert
|
|
Check.That(patterns).ContainsExactly("X");
|
|
}
|
|
|
|
[Fact]
|
|
public void SimMetricsMatcher_IsMatch_1()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher("The cat walks in the street.");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch("The car drives in the street.");
|
|
|
|
// Assert
|
|
Check.That(result).IsStrictlyLessThan(1.0).And.IsStrictlyGreaterThan(0.5);
|
|
}
|
|
|
|
[Fact]
|
|
public void SimMetricsMatcher_IsMatch_2()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher("The cat walks in the street.");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch("Hello");
|
|
|
|
// Assert
|
|
Check.That(result).IsStrictlyLessThan(0.1).And.IsStrictlyGreaterThan(0.05);
|
|
}
|
|
|
|
[Fact]
|
|
public void SimMetricsMatcher_IsMatch_AcceptOnMatch()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher("test");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch("test");
|
|
|
|
// Assert
|
|
Check.That(result).IsEqualTo(1.0);
|
|
}
|
|
|
|
[Fact]
|
|
public void SimMetricsMatcher_IsMatch_RejectOnMatch()
|
|
{
|
|
// Assign
|
|
var matcher = new SimMetricsMatcher(MatchBehaviour.RejectOnMatch, "test");
|
|
|
|
// Act
|
|
double result = matcher.IsMatch("test");
|
|
|
|
// Assert
|
|
Check.That(result).IsEqualTo(0.0);
|
|
}
|
|
}
|
|
} |