Version 2.x (#1359)

* Version 2.x

* Setup .NET 9

* 12

* cleanup some #if for NETSTANDARD1_3

* cleanup + fix tests for net8

* openapi

* NO ConfigureAwait(false) + cleanup

* .

* #endif

* HashSet

* WireMock.Net.NUnit

* HttpContext

* Add WebSockets (#1423)

* Add WebSockets

* Add tests

* fix

* more tests

* Add tests

* ...

* remove IOwin

* -

* tests

* fluent

* ok

* match

* .

* byte[]

* x

* func

* func

* byte

* trans

* ...

* frameworks.........

* jmes

* xxx

* sc

* using var httpClient = new HttpClient();

* usings

* maxRetries

* up

* xunit v3

* ct

* ---

* ct

* ct2

* T Unit

* WireMock.Net.TUnitTests / 10

* t unit first

* --project

* no tunit

* t2

* --project

* --project

* ci -  --project

* publish ./test/wiremock-coverage.xml

* windows

* .

* log

* ...

* log

* goed

* BodyType

* .

* .

* --scenario

* ...

* pact

* ct

* .

* WireMock.Net.RestClient.AwesomeAssertions (#1427)

* WireMock.Net.RestClient.AwesomeAssertions

* ok

* atpath

* fix test

* sonar fixes

* ports

* proxy test

* FIX?

* ---

* await Task.Delay(100, _ct);

* ?

* --project

* Aspire: use IDistributedApplicationEventingSubscriber (#1428)

* broadcast

* ok

* more tsts

* .

* Collection

* up

* .

* 2

* remove nfluent

* <VersionPrefix>2.0.0-preview-02</VersionPrefix>

* ...

* .

* nuget icon

* .

* <PackageReference Include="JmesPath.Net" Version="1.1.0" />

* x

* 500

* .

* fix some warnings

* ws
This commit is contained in:
Stef Heyenrath
2026-03-11 17:02:47 +01:00
committed by GitHub
parent d6e19532bc
commit a292f28dda
521 changed files with 79740 additions and 5246 deletions

View File

@@ -1,9 +1,6 @@
// Copyright © WireMock.Net
using FluentAssertions;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -80,7 +77,7 @@ public class CSharpCodeMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("CSharpCodeMatcher");
name.Should().Be("CSharpCodeMatcher");
}
[Fact]
@@ -93,6 +90,6 @@ public class CSharpCodeMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("x");
patterns.Should().ContainSingle("x");
}
}
}

View File

@@ -1,9 +1,6 @@
// Copyright © WireMock.Net
using FluentAssertions;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -52,7 +49,7 @@ public class ContentTypeMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("ContentTypeMatcher");
name.Should().Be("ContentTypeMatcher");
}
[Fact]
@@ -65,6 +62,6 @@ public class ContentTypeMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("x");
patterns.Should().ContainSingle("x");
}
}

View File

@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -18,7 +16,7 @@ public class ExactMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("ExactMatcher");
name.Should().Be("ExactMatcher");
}
[Fact]
@@ -31,7 +29,7 @@ public class ExactMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -44,7 +42,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("X").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -57,7 +55,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("x").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -70,7 +68,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("y").Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
[Fact]
@@ -83,7 +81,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("x").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -96,7 +94,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("x").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Theory]
@@ -112,7 +110,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("x").Score;
// Assert
Check.That(result).IsEqualTo(score);
result.Should().Be(score);
}
[Fact]
@@ -125,7 +123,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("caR").Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
[Fact]
@@ -138,7 +136,7 @@ public class ExactMatcherTests
double result = matcher.IsMatch("cat").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -151,6 +149,6 @@ public class ExactMatcherTests
double result = matcher.IsMatch("cat").Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
}

View File

@@ -1,8 +1,7 @@
// Copyright © WireMock.Net
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -19,7 +18,7 @@ public class ExactObjectMatcherTests
var name = matcher.Name;
// Assert
Check.That(name).Equals("ExactObjectMatcher");
name.Should().Be("ExactObjectMatcher");
}
[Fact]
@@ -33,7 +32,7 @@ public class ExactObjectMatcherTests
var score = matcher.IsMatch(checkValue).Score;
// Assert
Check.That(score).IsEqualTo(1.0);
score.Should().Be(1.0);
}
[Fact]
@@ -47,7 +46,7 @@ public class ExactObjectMatcherTests
var score = matcher.IsMatch(new { x = 500, s = "s" }).Score;
// Assert
Check.That(score).IsEqualTo(1.0);
score.Should().Be(1.0);
}
[Fact]
@@ -61,6 +60,6 @@ public class ExactObjectMatcherTests
var score = matcher.IsMatch(new { x = 500, s = "s" }).Score;
// Assert
Check.That(score).IsEqualTo(0.0);
score.Should().Be(0.0);
}
}
}

View File

@@ -1,19 +1,16 @@
// Copyright © WireMock.Net
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using AnyOfTypes;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Models;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
public class FormUrlEncodedMatcherTest
{
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
[Theory]
[InlineData("*=*")]
[InlineData("name=John Doe")]
@@ -29,12 +26,12 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch(params string[] patterns)
{
// Arrange
var content = new FormUrlEncodedContent(new[]
{
var content = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com")
});
var contentAsString = await content.ReadAsStringAsync();
]);
var contentAsString = await content.ReadAsStringAsync(_ct);
var matcher = new FormUrlEncodedMatcher(patterns.Select(p => new AnyOf<string, StringPattern>(p)).ToArray());
@@ -60,12 +57,12 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_And(bool expected, params string[] patterns)
{
// Arrange
var content = new FormUrlEncodedContent(new[]
{
var content = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com")
});
var contentAsString = await content.ReadAsStringAsync();
]);
var contentAsString = await content.ReadAsStringAsync(_ct);
var matcher = new FormUrlEncodedMatcher(patterns.Select(p => new AnyOf<string, StringPattern>(p)).ToArray(), true, MatchOperator.And);
@@ -80,12 +77,12 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties()
{
// Arrange
var content = new FormUrlEncodedContent(new[]
{
var content = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com")
});
var contentAsString = await content.ReadAsStringAsync();
]);
var contentAsString = await content.ReadAsStringAsync(_ct);
// The expectation is that the matcher requires all properties to be present in the content.
var matcher = new FormUrlEncodedMatcher(["name=*", "email=*", "required=*"], matchOperator: MatchOperator.And);

View File

@@ -0,0 +1,428 @@
// Copyright © WireMock.Net
using WireMock.Matchers;
namespace WireMock.Net.Tests.Matchers;
public class FuncMatcherTests
{
[Fact]
public void FuncMatcher_For_String_IsMatch_Should_Return_Perfect_When_Function_Returns_True()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch("test");
// Assert
result.IsPerfect().Should().BeTrue();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_Should_Return_Mismatch_When_Function_Returns_False()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch("other");
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_Should_Handle_Null_String()
{
// Arrange
Func<string?, bool> func = s => s == null;
var matcher = new FuncMatcher(func);
// Act - passing null as object, not as string
var result = matcher.IsMatch((object?)null);
// Assert - null object doesn't match, returns mismatch
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_With_ByteArray_Input_Should_Return_Mismatch()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(new byte[] { 1, 2, 3 });
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_With_Null_Object_Should_Return_Mismatch()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch((object?)null);
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_Should_Handle_Exception()
{
// Arrange
Func<string?, bool> func = s => throw new InvalidOperationException("Test exception");
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch("test");
// Assert
result.IsPerfect().Should().BeFalse();
result.Exception.Should().NotBeNull();
result.Exception.Should().BeOfType<InvalidOperationException>();
result.Exception!.Message.Should().Be("Test exception");
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_Should_Return_Perfect_When_Function_Returns_True()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length == 3;
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(new byte[] { 1, 2, 3 });
// Assert
result.IsPerfect().Should().BeTrue();
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_Should_Return_Mismatch_When_Function_Returns_False()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length == 3;
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(new byte[] { 1, 2, 3, 4, 5 });
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_Should_Handle_Null_ByteArray()
{
// Arrange
Func<byte[]?, bool> func = b => b == null;
var matcher = new FuncMatcher(func);
// Act - passing null as object, not as byte[]
var result = matcher.IsMatch((object?)null);
// Assert - null object doesn't match, returns mismatch
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_With_String_Input_Should_Return_Mismatch()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length > 0;
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch("test");
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_Should_Handle_Exception()
{
// Arrange
Func<byte[]?, bool> func = b => throw new InvalidOperationException("Bytes exception");
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(new byte[] { 1, 2, 3 });
// Assert
result.IsPerfect().Should().BeFalse();
result.Exception.Should().NotBeNull();
result.Exception.Should().BeOfType<InvalidOperationException>();
result.Exception!.Message.Should().Be("Bytes exception");
}
[Fact]
public void FuncMatcher_For_String_With_Contains_Logic_Should_Work()
{
// Arrange
Func<string?, bool> func = s => s?.Contains("foo") == true;
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch("foo");
var result2 = matcher.IsMatch("foobar");
var result3 = matcher.IsMatch("bar");
// Assert
result1.IsPerfect().Should().BeTrue();
result2.IsPerfect().Should().BeTrue();
result3.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_With_Length_Logic_Should_Work()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length > 2;
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch(new byte[] { 1 });
var result2 = matcher.IsMatch(new byte[] { 1, 2 });
var result3 = matcher.IsMatch(new byte[] { 1, 2, 3 });
// Assert
result1.IsPerfect().Should().BeFalse();
result2.IsPerfect().Should().BeFalse();
result3.IsPerfect().Should().BeTrue();
}
[Fact]
public void FuncMatcher_Name_Should_Return_FuncMatcher()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act & Assert
matcher.Name.Should().Be("FuncMatcher");
}
[Fact]
public void FuncMatcher_MatchBehaviour_Should_Return_AcceptOnMatch_By_Default()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act & Assert
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
}
[Fact]
public void FuncMatcher_MatchBehaviour_Should_Return_Custom_Value_For_String()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act & Assert
matcher.MatchBehaviour.Should().Be(MatchBehaviour.RejectOnMatch);
}
[Fact]
public void FuncMatcher_MatchBehaviour_Should_Return_Custom_Value_For_Bytes()
{
// Arrange
Func<byte[]?, bool> func = b => b != null;
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act & Assert
matcher.MatchBehaviour.Should().Be(MatchBehaviour.RejectOnMatch);
}
[Fact]
public void FuncMatcher_GetCSharpCodeArguments_For_String_Should_Return_Correct_Code()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var code = matcher.GetCSharpCodeArguments();
// Assert
code.Should().Be("new FuncMatcher(/* Func<string?, bool> function */, WireMock.Matchers.MatchBehaviour.AcceptOnMatch)");
}
[Fact]
public void FuncMatcher_GetCSharpCodeArguments_For_Bytes_Should_Return_Correct_Code()
{
// Arrange
Func<byte[]?, bool> func = b => b != null;
var matcher = new FuncMatcher(func);
// Act
var code = matcher.GetCSharpCodeArguments();
// Assert
code.Should().Be("new FuncMatcher(/* Func<byte[]?, bool> function */, WireMock.Matchers.MatchBehaviour.AcceptOnMatch)");
}
[Fact]
public void FuncMatcher_With_RejectOnMatch_For_String_Should_Invert_Result_When_True()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act
var result = matcher.IsMatch("test");
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_With_RejectOnMatch_For_String_Should_Invert_Result_When_False()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act
var result = matcher.IsMatch("other");
// Assert
result.IsPerfect().Should().BeTrue();
}
[Fact]
public void FuncMatcher_With_RejectOnMatch_For_Bytes_Should_Invert_Result_When_True()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length > 0;
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act
var result = matcher.IsMatch(new byte[] { 1, 2, 3 });
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_With_RejectOnMatch_For_Bytes_Should_Invert_Result_When_False()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length > 0;
var matcher = new FuncMatcher(func, MatchBehaviour.RejectOnMatch);
// Act
var result = matcher.IsMatch(new byte[0]);
// Assert
result.IsPerfect().Should().BeTrue();
}
[Fact]
public void FuncMatcher_For_String_IsMatch_With_Integer_Input_Should_Return_Mismatch()
{
// Arrange
Func<string?, bool> func = s => s == "test";
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(42);
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_IsMatch_With_Integer_Input_Should_Return_Mismatch()
{
// Arrange
Func<byte[]?, bool> func = b => b != null;
var matcher = new FuncMatcher(func);
// Act
var result = matcher.IsMatch(42);
// Assert
result.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_With_Empty_String_Should_Work()
{
// Arrange
Func<string?, bool> func = s => string.IsNullOrEmpty(s);
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch("");
var result2 = matcher.IsMatch("test");
// Assert
result1.IsPerfect().Should().BeTrue();
result2.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_With_Empty_Array_Should_Work()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length == 0;
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch(new byte[0]);
var result2 = matcher.IsMatch(new byte[] { 1 });
// Assert
result1.IsPerfect().Should().BeTrue();
result2.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_String_With_Complex_Logic_Should_Work()
{
// Arrange
Func<string?, bool> func = s => s != null && s.Length > 3 && s.StartsWith("t") && s.EndsWith("t");
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch("test");
var result2 = matcher.IsMatch("tart");
var result3 = matcher.IsMatch("tes");
var result4 = matcher.IsMatch("best");
// Assert
result1.IsPerfect().Should().BeTrue();
result2.IsPerfect().Should().BeTrue();
result3.IsPerfect().Should().BeFalse();
result4.IsPerfect().Should().BeFalse();
}
[Fact]
public void FuncMatcher_For_Bytes_With_Specific_Byte_Check_Should_Work()
{
// Arrange
Func<byte[]?, bool> func = b => b != null && b.Length > 0 && b[0] == 0xFF;
var matcher = new FuncMatcher(func);
// Act
var result1 = matcher.IsMatch(new byte[] { 0xFF, 0x00 });
var result2 = matcher.IsMatch(new byte[] { 0x00, 0xFF });
// Assert
result1.IsPerfect().Should().BeTrue();
result2.IsPerfect().Should().BeFalse();
}
}

View File

@@ -1,14 +1,9 @@
// Copyright © WireMock.Net
#if GRAPHQL
using System;
using System.Collections.Generic;
using FluentAssertions;
using GraphQLParser.Exceptions;
using WireMock.Exceptions;
using WireMock.Matchers;
using WireMock.Models;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -232,5 +227,4 @@ public class GraphQLMatcherTests
// Assert
action.Should().Throw<GraphQLSyntaxErrorException>();
}
}
#endif
}

View File

@@ -1,10 +1,8 @@
// Copyright © WireMock.Net
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -20,7 +18,7 @@ public class JmesPathMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("JmesPathMatcher");
name.Should().Be("JmesPathMatcher");
}
[Fact]
@@ -33,7 +31,7 @@ public class JmesPathMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -47,7 +45,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(bytes).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -60,7 +58,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(null).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -73,7 +71,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(string.Empty).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -87,7 +85,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(o).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -100,7 +98,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch("").Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -113,7 +111,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch("x").Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -126,7 +124,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(new { things = new { name = "RequiredThing" } }).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -149,7 +147,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(jobject).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -162,7 +160,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(JObject.Parse("{ \"things\": { \"x\": \"RequiredThing\" } }")).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -175,7 +173,7 @@ public class JmesPathMatcherTests
double match = matcher.IsMatch(JObject.Parse("{ \"things\": { \"x\": \"RequiredThing\" } }")).Score;
// Assert
Check.That(match).IsEqualTo(0.0);
match.Should().Be(0.0);
}
[Fact]
@@ -203,4 +201,4 @@ public class JmesPathMatcherTests
// Assert
score.Should().Be(1);
}
}
}

View File

@@ -1,14 +1,10 @@
// Copyright © WireMock.Net
using System;
using System.IO;
using FluentAssertions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -45,7 +41,7 @@ public class JsonMatcherTests
var name = matcher.Name;
// Assert
Check.That(name).Equals("JsonMatcher");
name.Should().Be("JsonMatcher");
}
[Fact]
@@ -58,7 +54,7 @@ public class JsonMatcherTests
var value = matcher.Value;
// Assert
Check.That(value).Equals("{}");
value.Should().Be("{}");
}
[Fact]
@@ -108,7 +104,7 @@ public class JsonMatcherTests
var match = matcher.IsMatch(bytes).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -122,7 +118,7 @@ public class JsonMatcherTests
var match = matcher.IsMatch(s).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -136,7 +132,7 @@ public class JsonMatcherTests
var match = matcher.IsMatch(o).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -527,4 +523,4 @@ public class JsonMatcherTests
// Assert
Assert.Equal(1.0, score);
}
}
}

View File

@@ -1,13 +1,9 @@
// Copyright © WireMock.Net
using System;
using System.IO;
using FluentAssertions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -23,7 +19,7 @@ public class JsonPartialMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("JsonPartialMatcher");
name.Should().Be("JsonPartialMatcher");
}
[Fact]
@@ -36,7 +32,7 @@ public class JsonPartialMatcherTests
object value = matcher.Value;
// Assert
Check.That(value).Equals("{}");
value.Should().Be("{}");
}
[Fact]
@@ -86,7 +82,7 @@ public class JsonPartialMatcherTests
double match = matcher.IsMatch(bytes).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -100,7 +96,7 @@ public class JsonPartialMatcherTests
double match = matcher.IsMatch(s).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -114,7 +110,7 @@ public class JsonPartialMatcherTests
double match = matcher.IsMatch(o).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -417,7 +413,7 @@ public class JsonPartialMatcherTests
[InlineData("{ \"test.nested\":\"value\" }", "{\"test\":{\"nested\":\"value1\"}}")]
[InlineData("{\"test\":{\"test1\":\"value\"}}", "{\"test\":{\"test1\":\"value1\"}}")]
[InlineData("[{ \"test.nested\":\"value\" }]", "[{\"test\":{\"nested\":\"value1\"}}]")]
public void JsonPartialMatcher_IsMatch_StringInputWithInvalidMatch(string value, string input)
public void JsonPartialMatcher_IsMatch_StringInputWithInvalidMatch(string value, string? input)
{
// Assign
var matcher = new JsonPartialMatcher(value);
@@ -466,4 +462,4 @@ public class JsonPartialMatcherTests
// Assert
Assert.Equal(0.0, match);
}
}
}

View File

@@ -1,13 +1,9 @@
// Copyright © WireMock.Net
using System;
using System.IO;
using FluentAssertions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -23,7 +19,7 @@ public class JsonPartialWildcardMatcherTests
var name = matcher.Name;
// Assert
Check.That(name).Equals("JsonPartialWildcardMatcher");
name.Should().Be("JsonPartialWildcardMatcher");
}
[Fact]
@@ -36,7 +32,7 @@ public class JsonPartialWildcardMatcherTests
var value = matcher.Value;
// Assert
Check.That(value).Equals("{}");
value.Should().Be("{}");
}
[Fact]
@@ -86,7 +82,7 @@ public class JsonPartialWildcardMatcherTests
var match = matcher.IsMatch(bytes).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -100,7 +96,7 @@ public class JsonPartialWildcardMatcherTests
var match = matcher.IsMatch(s).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -114,7 +110,7 @@ public class JsonPartialWildcardMatcherTests
var match = matcher.IsMatch(o).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -338,7 +334,7 @@ public class JsonPartialWildcardMatcherTests
[InlineData("{ \"test.nested\":\"value\" }", "{\"test\":{\"nested\":\"value1\"}}")]
[InlineData("{\"test\":{\"test1\":\"value\"}}", "{\"test\":{\"test1\":\"value1\"}}")]
[InlineData("[{ \"test.nested\":\"value\" }]", "[{\"test\":{\"nested\":\"value1\"}}]")]
public void JsonPartialWildcardMatcher_IsMatch_StringInputWithInvalidMatch(string value, string input)
public void JsonPartialWildcardMatcher_IsMatch_StringInputWithInvalidMatch(string value, string? input)
{
// Assign
var matcher = new JsonPartialWildcardMatcher(value);
@@ -420,4 +416,4 @@ public class JsonPartialWildcardMatcherTests
// Assert
Assert.Equal(1.0, match);
}
}
}

View File

@@ -1,11 +1,7 @@
// Copyright © WireMock.Net
using System;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -21,7 +17,7 @@ public class JsonPathMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("JsonPathMatcher");
name.Should().Be("JsonPathMatcher");
}
[Fact]
@@ -34,7 +30,7 @@ public class JsonPathMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -48,7 +44,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(bytes).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -61,7 +57,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(null).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -74,7 +70,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(string.Empty).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -88,7 +84,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(o).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -101,7 +97,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch("").Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -114,7 +110,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch("x").Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -127,7 +123,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(new { Id = 1, Name = "Test" }).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -140,7 +136,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(new { things = new { name = "x" } }).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -154,7 +150,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(json).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -168,7 +164,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(json).Score;
// Assert
Check.That(match).IsEqualTo(0);
match.Should().Be(0);
}
[Fact]
@@ -187,7 +183,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(jobject).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -200,7 +196,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(JObject.Parse("{\"Id\":1,\"Name\":\"Test\"}")).Score;
// Assert
Check.That(match).IsEqualTo(1);
match.Should().Be(1);
}
[Fact]
@@ -213,7 +209,7 @@ public class JsonPathMatcherTests
double match = matcher.IsMatch(JObject.Parse("{\"Id\":1,\"Name\":\"Test\"}")).Score;
// Assert
Check.That(match).IsEqualTo(0.0);
match.Should().Be(0.0);
}
[Fact]
@@ -233,7 +229,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(1.0);
match.Should().Be(1.0);
}
[Fact]
@@ -255,7 +251,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(1.0);
match.Should().Be(1.0);
}
[Fact]
@@ -277,7 +273,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(0.0);
match.Should().Be(0.0);
}
[Fact]
@@ -295,7 +291,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(0.0);
match.Should().Be(0.0);
}
[Fact]
@@ -313,7 +309,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(0.0);
match.Should().Be(0.0);
}
[Fact]
@@ -337,7 +333,7 @@ public class JsonPathMatcherTests
}")).Score;
// Assert
Check.That(match).IsEqualTo(1.0);
match.Should().Be(1.0);
}
[Fact]
@@ -387,4 +383,4 @@ public class JsonPathMatcherTests
// Assert
match.Should().Be(1);
}
}
}

View File

@@ -2,7 +2,7 @@
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Matchers;
using Xunit;
@@ -99,7 +99,7 @@ public class LinqMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("LinqMatcher");
name.Should().Be("LinqMatcher");
}
[Fact]
@@ -112,6 +112,6 @@ public class LinqMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("x");
patterns.Should().ContainExactly("x");
}
}
}

View File

@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -11,16 +9,16 @@ public class MatchBehaviourHelperTests
[Fact]
public void MatchBehaviourHelper_Convert_AcceptOnMatch()
{
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 0.0)).IsEqualTo(0.0);
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 0.5)).IsEqualTo(0.5);
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 1.0)).IsEqualTo(1.0);
MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 0.0).Should().Be(0.0);
MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 0.5).Should().Be(0.5);
MatchBehaviourHelper.Convert(MatchBehaviour.AcceptOnMatch, 1.0).Should().Be(1.0);
}
[Fact]
public void MatchBehaviourHelper_Convert_RejectOnMatch()
{
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 0.0)).IsEqualTo(1.0);
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 0.5)).IsEqualTo(0.0);
Check.That(MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 1.0)).IsEqualTo(0.0);
MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 0.0).Should().Be(1.0);
MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 0.5).Should().Be(0.0);
MatchBehaviourHelper.Convert(MatchBehaviour.RejectOnMatch, 1.0).Should().Be(0.0);
}
}

View File

@@ -1,6 +1,4 @@
using FluentAssertions;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;

View File

@@ -1,11 +1,7 @@
// Copyright © WireMock.Net
#if MIMEKIT
using System;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -98,5 +94,4 @@ public class MimePartMatcherTests
// Assert
result.Score.Should().Be(MatchScores.Perfect);
}
}
#endif
}

View File

@@ -1,10 +1,6 @@
// Copyright © WireMock.Net
#if GRAPHQL
using System;
using FluentAssertions;
using WireMock.GraphQL.Models;
using Xunit;
namespace WireMock.Net.Tests.Matchers.Models;
@@ -94,5 +90,4 @@ public class WireMockCustomScalarGraphTypeTests
// Assert
result.Should().Be("someString");
}
}
#endif
}

View File

@@ -1,9 +1,6 @@
// Copyright © WireMock.Net
using FluentAssertions;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -17,14 +14,14 @@ public class NotNullOrEmptyMatcherTests
var name = matcher.Name;
// Assert
Check.That(name).Equals("NotNullOrEmptyMatcher");
name.Should().Be("NotNullOrEmptyMatcher");
}
[Theory]
[InlineData(null, 0.0)]
[InlineData(new byte[0], 0.0)]
[InlineData(new byte[] { 48 }, 1.0)]
public void NotNullOrEmptyMatcher_IsMatch_ByteArray(byte[] data, double expected)
public void NotNullOrEmptyMatcher_IsMatch_ByteArray(byte[]? data, double expected)
{
// Act
var matcher = new NotNullOrEmptyMatcher();
@@ -38,7 +35,7 @@ public class NotNullOrEmptyMatcherTests
[InlineData(null, 0.0)]
[InlineData("", 0.0)]
[InlineData("x", 1.0)]
public void NotNullOrEmptyMatcher_IsMatch_String(string @string, double expected)
public void NotNullOrEmptyMatcher_IsMatch_String(string? @string, double expected)
{
// Act
var matcher = new NotNullOrEmptyMatcher();
@@ -52,11 +49,11 @@ public class NotNullOrEmptyMatcherTests
[InlineData(null, 0.0)]
[InlineData("", 0.0)]
[InlineData("x", 1.0)]
public void NotNullOrEmptyMatcher_IsMatch_StringAsObject(string @string, double expected)
public void NotNullOrEmptyMatcher_IsMatch_StringAsObject(string? @string, double expected)
{
// Act
var matcher = new NotNullOrEmptyMatcher();
var result = matcher.IsMatch((object)@string).Score;
var result = matcher.IsMatch((object?)@string).Score;
// Assert
result.Should().Be(expected);
@@ -82,4 +79,4 @@ public class NotNullOrEmptyMatcherTests
// Assert
patterns.Should().BeEmpty();
}
}
}

View File

@@ -1,18 +1,15 @@
// Copyright © WireMock.Net
#if PROTOBUF
using System;
using System.Threading.Tasks;
using FluentAssertions;
using ProtoBuf;
using WireMock.Matchers;
using WireMock.Models;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
public class ProtoBufMatcherTests
{
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
private const string MessageType = "greet.HelloRequest";
private static IdOrTexts ProtoDefinition => new(null, @"
@@ -41,7 +38,7 @@ message HelloReply {
// Act
var matcher = new ProtoBufMatcher(() => ProtoDefinition, MessageType);
var result = await matcher.DecodeAsync(bytes).ConfigureAwait(false);
var result = await matcher.DecodeAsync(bytes, _ct);
// Assert
result.Should().BeEquivalentTo(new { name = "stef" });
@@ -55,7 +52,7 @@ message HelloReply {
// Act
var matcher = new ProtoBufMatcher(() => ProtoDefinition, MessageType);
var result = await matcher.IsMatchAsync(bytes).ConfigureAwait(false);
var result = await matcher.IsMatchAsync(bytes, _ct);
// Assert
result.Score.Should().Be(MatchScores.Perfect);
@@ -71,7 +68,7 @@ message HelloReply {
// Act
var matcher = new ProtoBufMatcher(() => ProtoDefinition, MessageType, matcher: jsonMatcher);
var result = await matcher.IsMatchAsync(bytes);
var result = await matcher.IsMatchAsync(bytes, _ct);
// Assert
result.Score.Should().Be(MatchScores.Perfect);
@@ -86,7 +83,7 @@ message HelloReply {
// Act
var matcher = new ProtoBufMatcher(() => ProtoDefinition, MessageType);
var result = await matcher.IsMatchAsync(bytes);
var result = await matcher.IsMatchAsync(bytes, _ct);
// Assert
result.Score.Should().Be(MatchScores.Mismatch);
@@ -101,11 +98,10 @@ message HelloReply {
// Act
var matcher = new ProtoBufMatcher(() => ProtoDefinition, "greet.Greeter.X");
var result = await matcher.IsMatchAsync(bytes);
var result = await matcher.IsMatchAsync(bytes, _ct);
// Assert
result.Score.Should().Be(MatchScores.Mismatch);
result.Exception.Should().BeOfType<ArgumentException>();
}
}
#endif
}

View File

@@ -1,10 +1,6 @@
// Copyright © WireMock.Net
using System;
using FluentAssertions;
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -20,7 +16,7 @@ public class RegexMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("RegexMatcher");
name.Should().Be("RegexMatcher");
}
[Fact]
@@ -33,7 +29,7 @@ public class RegexMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -44,8 +40,8 @@ public class RegexMatcherTests
bool case2 = new RegexMatcher("X", true).IgnoreCase;
// Assert
Check.That(case1).IsFalse();
Check.That(case2).IsTrue();
case1.Should().BeFalse();
case2.Should().BeTrue();
}
[Fact]
@@ -58,7 +54,7 @@ public class RegexMatcherTests
double result = matcher.IsMatch("Hello world!").Score;
// Assert
Check.That(result).IsEqualTo(1.0d);
result.Should().Be(1.0d);
}
[Fact]
@@ -71,7 +67,7 @@ public class RegexMatcherTests
double result = matcher.IsMatch(null).Score;
// Assert
Check.That(result).IsEqualTo(0.0d);
result.Should().Be(0.0d);
}
[Fact]
@@ -110,7 +106,7 @@ public class RegexMatcherTests
double result = matcher.IsMatch("hello").Score;
// Assert
Check.That(result).IsEqualTo(1.0d);
result.Should().Be(1.0d);
}
[Fact]
@@ -123,6 +119,6 @@ public class RegexMatcherTests
double result = matcher.IsMatch("hello").Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
}

View File

@@ -1,10 +1,7 @@
// Copyright © WireMock.Net
using System.Linq;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Matchers.Request;
using Xunit;
namespace WireMock.Net.Tests.Matchers;

View File

@@ -1,8 +1,7 @@
// Copyright © WireMock.Net
using NFluent;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -18,7 +17,7 @@ public class SimMetricsMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("SimMetricsMatcher.Levenstein");
name.Should().Be("SimMetricsMatcher.Levenstein");
}
[Fact]
@@ -31,7 +30,7 @@ public class SimMetricsMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -44,7 +43,7 @@ public class SimMetricsMatcherTests
double result = matcher.IsMatch("The car drives in the street.").Score;
// Assert
Check.That(result).IsStrictlyLessThan(1.0).And.IsStrictlyGreaterThan(0.5);
result.Should().BeLessThan(1.0).And.BeGreaterThan(0.5);
}
[Fact]
@@ -57,7 +56,7 @@ public class SimMetricsMatcherTests
double result = matcher.IsMatch("Hello").Score;
// Assert
Check.That(result).IsStrictlyLessThan(0.1).And.IsStrictlyGreaterThan(0.05);
result.Should().BeLessThan(0.1).And.BeGreaterThan(0.05);
}
[Fact]
@@ -70,7 +69,7 @@ public class SimMetricsMatcherTests
double result = matcher.IsMatch("test").Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -83,6 +82,6 @@ public class SimMetricsMatcherTests
double result = matcher.IsMatch("test").Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
}

View File

@@ -1,11 +1,8 @@
// Copyright © WireMock.Net
using AnyOfTypes;
using FluentAssertions;
using NFluent;
using WireMock.Matchers;
using WireMock.Models;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -124,7 +121,7 @@ public class WildcardMatcherTest
var name = matcher.Name;
// Assert
Check.That(name).Equals("WildcardMatcher");
name.Should().Be("WildcardMatcher");
}
[Fact]
@@ -137,7 +134,7 @@ public class WildcardMatcherTest
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly(new AnyOf<string, StringPattern>("x"));
patterns.Should().Equal(new[] { new AnyOf<string, StringPattern>("x") });
}
[Fact]
@@ -149,6 +146,6 @@ public class WildcardMatcherTest
// Act
var result = matcher.IsMatch("m").Score;
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
}
}

View File

@@ -1,9 +1,7 @@
// Copyright © WireMock.Net
using NFluent;
using WireMock.Admin.Mappings;
using WireMock.Matchers;
using Xunit;
namespace WireMock.Net.Tests.Matchers;
@@ -19,7 +17,7 @@ public class XPathMatcherTests
string name = matcher.Name;
// Assert
Check.That(name).Equals("XPathMatcher");
name.Should().Be("XPathMatcher");
}
[Fact]
@@ -32,7 +30,7 @@ public class XPathMatcherTests
var patterns = matcher.GetPatterns();
// Assert
Check.That(patterns).ContainsExactly("X");
patterns.Should().ContainSingle("X");
}
[Fact]
@@ -49,7 +47,7 @@ public class XPathMatcherTests
double result = matcher.IsMatch(xml).Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -81,7 +79,7 @@ public class XPathMatcherTests
double result = matcher.IsMatch(input).Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -114,7 +112,7 @@ public class XPathMatcherTests
double result = matcher.IsMatch(input).Score;
// Assert
Check.That(result).IsEqualTo(1.0);
result.Should().Be(1.0);
}
[Fact]
@@ -131,6 +129,6 @@ public class XPathMatcherTests
double result = matcher.IsMatch(xml).Score;
// Assert
Check.That(result).IsEqualTo(0.0);
result.Should().Be(0.0);
}
}
}