This commit is contained in:
Stef Heyenrath
2025-08-31 12:51:33 +02:00
parent 5b43a4f341
commit 4fd3ee1dfd
4 changed files with 19 additions and 20 deletions

View File

@@ -338,7 +338,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);

View File

@@ -24,7 +24,7 @@ public class NotNullOrEmptyMatcherTests
[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 +38,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 +52,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);

View File

@@ -5,7 +5,6 @@ using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Handlers;
using WireMock.Models;
using WireMock.ResponseBuilders;
@@ -52,10 +51,10 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
Check.That(j["Text"].Value<string>()).IsNotEmpty();
Check.That(j["Integer"].Value<int>()).IsEqualTo(1000);
Check.That(j["Long"].Value<long>()).IsStrictlyGreaterThan(77777777).And.IsStrictlyLessThan(99999999);
JObject j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
j["Text"]?.Value<string>().Should().NotBeNullOrEmpty();
j["Integer"]?.Value<int>().Should().Be(1000);
j["Long"]?.Value<long>().Should().BeInRange(77777777, 99999999);
}
[Fact]
@@ -75,8 +74,8 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
Check.That(j["Value"].Type).IsEqualTo(JTokenType.Boolean);
JObject j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
j["Value"]?.Type.Should().Be(JTokenType.Boolean);
}
[Theory]
@@ -166,9 +165,9 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
string value = j["StringValue"].Value<string>();
Check.That(new[] { "a", "b", "c" }.Contains(value)).IsTrue();
JObject j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
var value = j["StringValue"]?.Value<string>();
new[] { "a", "b", "c" }.Should().Contain(value);
}
[Fact]
@@ -188,8 +187,8 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
Check.That(j["Integer"].Value<int>()).IsStrictlyGreaterThan(10000000).And.IsStrictlyLessThan(99999999);
JObject j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
j["Integer"]?.Value<int>().Should().BeInRange(10000000, 99999999);
}
[Fact]
@@ -209,7 +208,7 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
// Assert
var j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
j["Long"].Value<long>().Should().BeInRange(1000000000, 9999999999);
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
j["Long"]?.Value<long>().Should().BeInRange(1000000000, 9999999999);
}
}

View File

@@ -31,7 +31,7 @@ public class FilePathUtilsTests
[InlineData(@"\", "")]
[InlineData(@"\\", "")]
[InlineData(@"\\a", "a")]
public void PathUtils_CleanPath_RemoveLeadingDirectorySeparators(string path, string expected)
public void PathUtils_CleanPath_RemoveLeadingDirectorySeparators(string? path, string? expected)
{
// Arrange
var cleanPath = FilePathUtils.CleanPath(path);