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,14 +1,9 @@
// Copyright © WireMock.Net
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using NFluent;
using WireMock.Types;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -31,14 +26,14 @@ public class BodyParserTests
};
// Act
var body = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var body = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
Check.That(body.BodyAsBytes).IsNotNull();
Check.That(body.BodyAsJson).IsNotNull();
Check.That(body.BodyAsString).Equals(bodyAsJson);
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
body.BodyAsBytes.Should().NotBeNull();
body.BodyAsJson.Should().NotBeNull();
body.BodyAsString.Should().Be(bodyAsJson);
body.DetectedBodyType.Should().Be(detectedBodyType);
body.DetectedBodyTypeFromContentType.Should().Be(detectedBodyTypeFromContentType);
}
[Theory]
@@ -55,14 +50,14 @@ public class BodyParserTests
};
// Act
var body = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var body = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
Check.That(body.BodyAsBytes).IsNotNull();
Check.That(body.BodyAsJson).IsNull();
Check.That(body.BodyAsString).Equals(bodyAsString);
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
body.BodyAsBytes.Should().NotBeNull();
body.BodyAsJson.Should().BeNull();
body.BodyAsString.Should().Be(bodyAsString);
body.DetectedBodyType.Should().Be(detectedBodyType);
body.DetectedBodyTypeFromContentType.Should().Be(detectedBodyTypeFromContentType);
}
[Theory]
@@ -80,10 +75,10 @@ public class BodyParserTests
};
// act
var body = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var body = await BodyParser.ParseAsync(bodyParserSettings);
// assert
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
body.DetectedBodyType.Should().Be(detectedBodyType);
}
[Theory]
@@ -101,10 +96,10 @@ public class BodyParserTests
};
// act
var body = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var body = await BodyParser.ParseAsync(bodyParserSettings);
// assert
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
body.DetectedBodyType.Should().Be(detectedBodyType);
}
[Fact]
@@ -142,14 +137,14 @@ public class BodyParserTests
};
// Act
var result = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var result = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
Check.That(result.DetectedBodyType).IsEqualTo(BodyType.String);
Check.That(result.DetectedBodyTypeFromContentType).IsEqualTo(BodyType.MultiPart);
Check.That(result.BodyAsBytes).IsNotNull();
Check.That(result.BodyAsJson).IsNull();
Check.That(result.BodyAsString).IsNotNull();
result.DetectedBodyType.Should().Be(BodyType.String);
result.DetectedBodyTypeFromContentType.Should().Be(BodyType.MultiPart);
result.BodyAsBytes.Should().NotBeNull();
result.BodyAsJson.Should().BeNull();
result.BodyAsString.Should().NotBeNull();
}
[Fact]
@@ -166,14 +161,14 @@ public class BodyParserTests
};
// Act
var result = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var result = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
Check.That(result.DetectedBodyType).IsEqualTo(BodyType.Bytes);
Check.That(result.DetectedBodyTypeFromContentType).IsEqualTo(BodyType.MultiPart);
Check.That(result.BodyAsBytes).IsNotNull();
Check.That(result.BodyAsJson).IsNull();
Check.That(result.BodyAsString).IsNull();
result.DetectedBodyType.Should().Be(BodyType.Bytes);
result.DetectedBodyTypeFromContentType.Should().Be(BodyType.MultiPart);
result.BodyAsBytes.Should().NotBeNull();
result.BodyAsJson.Should().BeNull();
result.BodyAsString.Should().BeNull();
}
[Theory]
@@ -189,14 +184,14 @@ public class BodyParserTests
};
// Act
var body = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var body = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
Check.That(body.BodyAsBytes).IsNotNull();
Check.That(body.BodyAsJson).IsNull();
Check.That(body.BodyAsString).Equals(bodyAsString);
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
body.BodyAsBytes.Should().NotBeNull();
body.BodyAsJson.Should().BeNull();
body.BodyAsString.Should().Be(bodyAsString);
body.DetectedBodyType.Should().Be(detectedBodyType);
body.DetectedBodyTypeFromContentType.Should().Be(detectedBodyTypeFromContentType);
}
[Theory]
@@ -217,7 +212,7 @@ public class BodyParserTests
};
// Act
var result = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var result = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
result.DetectedBodyType.Should().Be(BodyType.String);
@@ -246,7 +241,7 @@ public class BodyParserTests
};
// Act
var result = await BodyParser.ParseAsync(bodyParserSettings).ConfigureAwait(false);
var result = await BodyParser.ParseAsync(bodyParserSettings);
// Assert
result.BodyAsBytes.Should().BeEquivalentTo(compressed);
@@ -265,7 +260,7 @@ public class BodyParserTests
[InlineData("PATCH", true)]
public void BodyParser_ShouldParseBodyForMethodAndAllowAllIsFalse_ExpectedResultForKnownMethods(string method, bool resultShouldBe)
{
Check.That(BodyParser.ShouldParseBody(method, false)).Equals(resultShouldBe);
BodyParser.ShouldParseBody(method, false).Should().Be(resultShouldBe);
}
[Theory]
@@ -282,7 +277,7 @@ public class BodyParserTests
[InlineData("SOME-UNKNOWN-METHOD")]
public void BodyParser_ShouldParseBodyForMethodAndAllowAllIsTrue_ExpectedResultShouldBeTrue(string method)
{
Check.That(BodyParser.ShouldParseBody(method, true)).IsTrue();
BodyParser.ShouldParseBody(method, true).Should().BeTrue();
}
[Theory]
@@ -290,6 +285,7 @@ public class BodyParserTests
[InlineData("SOME-UNKNOWN-METHOD")]
public void BodyParser_ShouldParseBody_DefaultIsTrueForUnknownMethods(string method)
{
Check.That(BodyParser.ShouldParseBody(method, false)).IsTrue();
BodyParser.ShouldParseBody(method, false).Should().BeTrue();
}
}
}

View File

@@ -1,9 +1,7 @@
// Copyright © WireMock.Net
using System.Text;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,9 +1,7 @@
// Copyright © WireMock.Net
using FluentAssertions;
using Newtonsoft.Json.Linq;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,12 +1,9 @@
// Copyright © WireMock.Net
using System;
using System.Text;
using FluentAssertions;
using RandomDataGenerator.FieldOptions;
using RandomDataGenerator.Randomizers;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,10 +1,7 @@
// Copyright © WireMock.Net
using System;
using System.Globalization;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -39,7 +36,6 @@ public class CultureInfoUtilsTests
result.Should().Be(expectedCulture);
}
#if !NETSTANDARD1_3
[Fact]
public void Parse_IntegerInput_ReturnsExpectedCultureInfo()
{
@@ -53,7 +49,6 @@ public class CultureInfoUtilsTests
// Assert
result.Should().Be(expectedCulture);
}
#endif
[Fact]
public void Parse_CurrentCultureInput_ReturnsCurrentCulture()

View File

@@ -1,11 +1,8 @@
// Copyright © WireMock.Net
using FluentAssertions;
using Moq;
using System;
using WireMock.Handlers;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,9 +1,7 @@
// Copyright © WireMock.Net
using NFluent;
using System.IO;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -18,7 +16,7 @@ public class FilePathUtilsTests
var cleanPath = FilePathUtils.CleanPath(path);
// Assert
Check.That(cleanPath).Equals("subdirectory" + Path.DirectorySeparatorChar + "MyXmlResponse.xml");
cleanPath.Should().Be("subdirectory" + Path.DirectorySeparatorChar + "MyXmlResponse.xml");
}
[Theory]
@@ -31,7 +29,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);
@@ -40,6 +38,6 @@ public class FilePathUtilsTests
var withoutDirectorySeparators = FilePathUtils.RemoveLeadingDirectorySeparators(cleanPath);
// Assert
Check.That(withoutDirectorySeparators).Equals(expected);
withoutDirectorySeparators.Should().Be(expected);
}
}
}

View File

@@ -1,10 +1,7 @@
// Copyright © WireMock.Net
using FluentAssertions;
using System;
using System.Net;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -54,7 +51,7 @@ public class HttpStatusRangeParserTests
[InlineData(",,,", 9999, false)]
[InlineData(null, 399, true)]
public void HttpStatusRangeParser_ValidPattern_IsMatch(string pattern, int value, bool expectedResult)
public void HttpStatusRangeParser_ValidPattern_IsMatch(string? pattern, int value, bool expectedResult)
{
HttpStatusRangeParser.IsMatch(pattern, value).Should().Be(expectedResult);
}

View File

@@ -1,9 +1,7 @@
// Copyright © WireMock.Net
using System.Diagnostics.CodeAnalysis;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -6,7 +6,7 @@ using System.Linq.Dynamic.Core;
using System.Reflection;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NFluent;
using WireMock.Util;
using Xunit;
@@ -65,9 +65,9 @@ public class JsonUtilsTests
// Assert
var queryable = new[] { instance }.AsQueryable().Select(line);
bool result = queryable.Any("it == \"Test\"");
Check.That(result).IsTrue();
result.Should().BeTrue();
Check.That(line).IsEqualTo("string(it)");
line.Should().Be("string(it)");
}
[Fact]
@@ -192,4 +192,4 @@ public class JsonUtilsTests
"System.String get_C()"
});
}
}
}

View File

@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,10 +1,7 @@
// Copyright © WireMock.Net
using System.Collections.Generic;
using FluentAssertions;
using WireMock.Types;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,10 +1,7 @@
// Copyright © WireMock.Net
using System.Collections.Generic;
using System.Text.RegularExpressions;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,11 +1,7 @@
// Copyright © WireMock.Net
using System;
using CultureAwareTesting.xUnit;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -86,7 +82,7 @@ public class StringUtilsTests
}
}
[CulturedTheory("en-US")]
[CulturedTheory(["en-US"])]
[InlineData("123.1", 123.1, true)]
[InlineData("-456.1", -456.1, true)]
[InlineData("not a double", 0.0, false)] // Invalid case
@@ -230,7 +226,7 @@ public class StringUtilsTests
[InlineData("")]
[InlineData(null)]
[InlineData("x")]
public void StringUtils_TryParseQuotedString_With_InvalidStringLength_Returns_False(string input)
public void StringUtils_TryParseQuotedString_With_InvalidStringLength_Returns_False(string? input)
{
// Act
var valid = StringUtils.TryParseQuotedString(input, out _, out _);
@@ -255,7 +251,7 @@ public class StringUtilsTests
public void StringUtils_TryParseQuotedString_With_UnexpectedUnrecognizedEscapeSequence_Returns_False()
{
// Arrange
var input = new string(new[] { '"', '\\', 'u', '?', '"' });
var input = new string(['"', '\\', 'u', '?', '"']);
// Act
var valid = StringUtils.TryParseQuotedString(input, out _, out _);

View File

@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,12 +1,9 @@
// Copyright © WireMock.Net
using System.IO;
using AnyOfTypes;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Models;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;

View File

@@ -1,14 +1,7 @@
// Copyright © WireMock.Net
using System;
#if NET452
using Microsoft.Owin;
#else
using Microsoft.AspNetCore.Http;
#endif
using NFluent;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
@@ -24,8 +17,8 @@ public class UrlUtilsTests
var result = UrlUtils.Parse(uri, new PathString("/a"));
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
result.Url.ToString().Should().Be("https://localhost:1234/b?x=0");
result.AbsoluteUrl.ToString().Should().Be("https://localhost:1234/a/b?x=0");
}
[Fact]
@@ -38,8 +31,8 @@ public class UrlUtilsTests
var result = UrlUtils.Parse(uri, new PathString());
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/a/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
result.Url.ToString().Should().Be("https://localhost:1234/a/b?x=0");
result.AbsoluteUrl.ToString().Should().Be("https://localhost:1234/a/b?x=0");
}
[Fact]
@@ -52,7 +45,7 @@ public class UrlUtilsTests
var result = UrlUtils.Parse(uri, new PathString("/test"));
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/a/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
result.Url.ToString().Should().Be("https://localhost:1234/a/b?x=0");
result.AbsoluteUrl.ToString().Should().Be("https://localhost:1234/a/b?x=0");
}
}