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,8 +1,5 @@
// Copyright © WireMock.Net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using AnyOfTypes;
using Newtonsoft.Json;

View File

@@ -1,22 +1,16 @@
// Copyright © WireMock.Net
using System.Collections.Generic;
namespace WireMock.Net.Tests.Serialization;
namespace WireMock.Net.Tests.Serialization
public class CustomPathParamMatcherModel
{
public class CustomPathParamMatcherModel
public string Path { get; set; }
public Dictionary<string, string> PathParams { get; set; }
public CustomPathParamMatcherModel(string path, Dictionary<string, string> pathParams)
{
public string Path { get; set; }
public Dictionary<string, string> PathParams { get; set; }
public CustomPathParamMatcherModel()
{
}
public CustomPathParamMatcherModel(string path, Dictionary<string, string> pathParams)
{
Path = path;
PathParams = pathParams;
}
Path = path;
PathParams = pathParams;
}
}

View File

@@ -1,9 +1,5 @@
// Copyright © WireMock.Net
#if !(NET452 || NET461)
using System.Threading.Tasks;
using VerifyTests;
using VerifyXunit;
using WireMock.Logging;
using WireMock.Models;
using WireMock.Net.Tests.VerifyExtensions;
@@ -12,11 +8,9 @@ using WireMock.ResponseBuilders;
using WireMock.Serialization;
using WireMock.Types;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public class LogEntryMapperTests
{
private static readonly VerifySettings VerifySettings = new();
@@ -64,7 +58,7 @@ public class LogEntryMapperTests
var result = _sut.Map(logEntry);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -88,7 +82,7 @@ public class LogEntryMapperTests
var result = _sut.Map(logEntry);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -114,7 +108,7 @@ public class LogEntryMapperTests
var result = _sut.Map(logEntry);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -153,7 +147,6 @@ public class LogEntryMapperTests
var result = new LogEntryMapper(options).Map(logEntry);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
}
#endif
}

View File

@@ -1,21 +1,13 @@
// Copyright © WireMock.Net
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Threading.Tasks;
using FluentAssertions;
using VerifyTests;
using VerifyXunit;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Serialization;
using WireMock.Types;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public partial class MappingConverterTests
{
private static readonly VerifySettings VerifySettings = new();
@@ -41,7 +33,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code, VerifySettings);
return Verify(code, VerifySettings);
}
[Fact]
@@ -61,7 +53,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code, VerifySettings);
return Verify(code, VerifySettings);
}
[Fact]
@@ -81,7 +73,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code, VerifySettings);
return Verify(code, VerifySettings);
}
[Fact]
@@ -101,7 +93,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code, VerifySettings);
return Verify(code, VerifySettings);
}
private IMapping CreateMapping()
@@ -142,5 +134,4 @@ public partial class MappingConverterTests
data: null
).WithProbability(0.3);
}
}
#endif
}

View File

@@ -1,12 +1,5 @@
// Copyright © WireMock.Net
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using VerifyXunit;
using WireMock.Matchers;
using WireMock.Models;
using WireMock.RequestBuilders;
@@ -15,7 +8,6 @@ using WireMock.Serialization;
using WireMock.Settings;
using WireMock.Types;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
@@ -100,7 +92,7 @@ message HelloReply {
model.Webhook.Request.BodyAsJson.Should().BeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -177,7 +169,7 @@ message HelloReply {
model.Webhooks[1].Request.Body.Should().Be("2");
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -199,7 +191,7 @@ message HelloReply {
model.Description.Should().Be(description);
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -219,7 +211,7 @@ message HelloReply {
model.Response.UseTransformer.Should().BeTrue();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -250,7 +242,7 @@ message HelloReply {
model.TimeSettings.TTL.Should().Be(ttl);
// Verify
return Verifier.Verify(model, VerifySettings);
return Verify(model, VerifySettings);
}
[Fact]
@@ -296,7 +288,7 @@ message HelloReply {
model.Response.Delay.Should().Be(delay);
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -318,7 +310,7 @@ message HelloReply {
model.Response.MaximumRandomDelay.Should().Be(60_000);
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -341,7 +333,7 @@ message HelloReply {
model.Response.MaximumRandomDelay.Should().Be(maximumDelay);
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -362,7 +354,7 @@ message HelloReply {
model.Probability.Should().Be(0.4);
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -380,7 +372,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -412,7 +404,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -438,7 +430,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -459,7 +451,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
#if TRAILINGHEADERS
@@ -482,7 +474,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -503,7 +495,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
#endif
@@ -528,10 +520,9 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
#if GRAPHQL
[Fact]
public Task ToMappingModel_Request_WithBodyAsGraphQLSchema_ReturnsCorrectModel()
{
@@ -560,11 +551,9 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
#endif
#if PROTOBUF
[Fact]
public Task ToMappingModel_Request_WithBodyAsProtoBuf_ReturnsCorrectModel()
{
@@ -587,7 +576,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -614,7 +603,7 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
[Fact]
@@ -649,8 +638,6 @@ message HelloReply {
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
return Verify(model);
}
#endif
}
#endif
}

View File

@@ -1,10 +1,8 @@
// Copyright © WireMock.Net
using System;
using Moq;
using WireMock.Serialization;
using WireMock.Settings;
using Xunit;
namespace WireMock.Net.Tests.Serialization;

View File

@@ -1,11 +1,8 @@
// Copyright © WireMock.Net
using System;
using FluentAssertions;
using JsonConverter.Newtonsoft.Json;
using WireMock.Admin.Mappings;
using WireMock.Serialization;
using Xunit;
#if NET8_0_OR_GREATER
using JsonConverter.System.Text.Json;
#endif

View File

@@ -1,20 +1,15 @@
// Copyright © WireMock.Net
using System;
using System.Collections.Generic;
using AnyOfTypes;
using FluentAssertions;
using FluentAssertions.Execution;
using AwesomeAssertions.Execution;
using Moq;
using Newtonsoft.Json;
using NFluent;
using WireMock.Admin.Mappings;
using WireMock.Handlers;
using WireMock.Matchers;
using WireMock.Models;
using WireMock.Serialization;
using WireMock.Settings;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
@@ -56,13 +51,12 @@ public class MatcherMapperTests
var matcherMock2 = new Mock<IStringMatcher>();
// Act
var models = _sut.Map(new[] { matcherMock1.Object, matcherMock2.Object });
var models = _sut.Map([matcherMock1.Object, matcherMock2.Object]);
// Assert
models.Should().HaveCount(2);
}
#if MIMEKIT
[Fact]
public void MatcherMapper_Map_Matcher_MimePartMatcher()
{
@@ -94,7 +88,6 @@ public class MatcherMapperTests
model.ContentMatcher!.Name.Should().Be(nameof(ExactObjectMatcher));
model.ContentMatcher.Pattern.Should().Be(bytes);
}
#endif
[Fact]
public void MatcherMapper_Map_Matcher_IStringMatcher()
@@ -124,7 +117,7 @@ public class MatcherMapperTests
var matcherMock = new Mock<IStringMatcher>();
matcherMock.Setup(m => m.Name).Returns("test");
matcherMock.Setup(m => m.GetPatterns()).Returns(new AnyOf<string, StringPattern>[] { pattern });
matcherMock.Setup(m => m.GetPatterns()).Returns([pattern]);
// Act
var model = _sut.Map(matcherMock.Object)!;
@@ -171,7 +164,6 @@ public class MatcherMapperTests
model.XmlNamespaceMap.Should().BeEquivalentTo(xmlNamespaceMap);
}
#if GRAPHQL
[Fact]
public void MatcherMapper_Map_Matcher_GraphQLMatcher()
{
@@ -199,9 +191,7 @@ public class MatcherMapperTests
model.Pattern.Should().Be(testSchema);
model.CustomScalars.Should().BeEquivalentTo(customScalars);
}
#endif
#if PROTOBUF
[Fact]
public void MatcherMapper_Map_Matcher_ProtoBufMatcher()
{
@@ -280,7 +270,6 @@ message HelloReply {
model.ContentMatcher?.Name.Should().Be("JsonMatcher");
model.ContentMatcher?.Pattern.Should().Be(jsonPattern);
}
#endif
[Fact]
public void MatcherMapper_Map_MatcherModel_Null()
@@ -298,8 +287,11 @@ message HelloReply {
// Assign
var model = new MatcherModel { Name = "test" };
// Act and Assert
Check.ThatCode(() => _sut.Map(model)).Throws<NotSupportedException>();
// Act
Action act = () => _sut.Map(model);
// Assert
act.Should().Throw<NotSupportedException>();
}
//[Fact]
@@ -598,7 +590,6 @@ message HelloReply {
matcher.MatchBehaviour.Should().Be(MatchBehaviour.RejectOnMatch);
}
#if MIMEKIT
[Fact]
public void MatcherMapper_Map_MatcherModel_MimePartMatcher()
{
@@ -638,7 +629,6 @@ message HelloReply {
matcher.ContentTransferEncodingMatcher.Should().BeAssignableTo<RegexMatcher>().Which.GetPatterns().Should().ContainSingle("z");
matcher.ContentTypeMatcher.Should().BeAssignableTo<ContentTypeMatcher>().Which.GetPatterns().Should().ContainSingle("text/json");
}
#endif
[Fact]
public void MatcherMapper_Map_MatcherModel_XPathMatcher_WithXmlNamespaces_As_String()
@@ -649,10 +639,10 @@ message HelloReply {
{
Name = "XPathMatcher",
Pattern = pattern,
XmlNamespaceMap = new[]
{
XmlNamespaceMap =
[
new XmlNamespace { Prefix = "s", Uri = "http://schemas.xmlsoap.org/soap/envelope/" }
}
]
};
// Act
@@ -758,7 +748,7 @@ message HelloReply {
var matcher = (ExactMatcher)_sut.Map(model)!;
// Assert
Check.That(matcher.GetPatterns()).ContainsExactly("x", "y");
matcher.GetPatterns().Should().ContainInOrder("x", "y");
}
[Fact]
@@ -812,14 +802,14 @@ message HelloReply {
var model = new MatcherModel
{
Name = "ExactObjectMatcher",
Patterns = new object[] { "c3RlZg==" }
Patterns = ["c3RlZg=="]
};
// Act
var matcher = (ExactObjectMatcher)_sut.Map(model)!;
// Assert
Check.That((byte[])matcher.Value).ContainsExactly(115, 116, 101, 102);
((byte[])matcher.Value).Should().BeEquivalentTo(new byte[] { 115, 116, 101, 102 });
}
[Fact]
@@ -829,11 +819,14 @@ message HelloReply {
var model = new MatcherModel
{
Name = "ExactObjectMatcher",
Patterns = new object[] { "_" }
Patterns = ["_"]
};
// Act & Assert
Check.ThatCode(() => _sut.Map(model)).Throws<ArgumentException>();
// Act
Action act = () => _sut.Map(model);
// Assert
act.Should().Throw<ArgumentException>();
}
[Theory]
@@ -855,7 +848,7 @@ message HelloReply {
var matcher = (RegexMatcher)_sut.Map(model)!;
// Assert
Check.That(matcher.GetPatterns()).ContainsExactly("x", "y");
matcher.GetPatterns().Should().ContainInOrder("x", "y");
var result = matcher.IsMatch("X");
result.Score.Should().Be(expected);
@@ -880,7 +873,7 @@ message HelloReply {
var matcher = (WildcardMatcher)_sut.Map(model)!;
// Assert
Check.That(matcher.GetPatterns()).ContainsExactly("x", "y");
matcher.GetPatterns().Should().ContainInOrder("x", "y");
var result = matcher.IsMatch("X");
result.Score.Should().Be(expected);
@@ -936,7 +929,7 @@ message HelloReply {
var matcher = (SimMetricsMatcher)_sut.Map(model)!;
// Assert
Check.That(matcher.GetPatterns()).ContainsExactly("x");
matcher.GetPatterns().Should().ContainSingle("x");
}
[Fact]
@@ -953,7 +946,7 @@ message HelloReply {
var matcher = (SimMetricsMatcher)_sut.Map(model)!;
// Assert
Check.That(matcher.GetPatterns()).ContainsExactly("x");
matcher.GetPatterns().Should().ContainSingle("x");
}
[Fact]
@@ -967,7 +960,10 @@ message HelloReply {
};
// Act
Check.ThatCode(() => _sut.Map(model)).Throws<NotSupportedException>();
Action act = () => _sut.Map(model);
// Assert
act.Should().Throw<NotSupportedException>();
}
[Fact]
@@ -981,7 +977,10 @@ message HelloReply {
};
// Act
Check.ThatCode(() => _sut.Map(model)).Throws<NotSupportedException>();
Action act = () => _sut.Map(model);
// Assert
act.Should().Throw<NotSupportedException>();
}
[Fact]
@@ -1050,7 +1049,6 @@ message HelloReply {
}
}
#if GRAPHQL
[Fact]
public void MatcherMapper_Map_MatcherModel_GraphQLMatcher()
{
@@ -1083,9 +1081,7 @@ message HelloReply {
matcher.Name.Should().Be(nameof(GraphQLMatcher));
matcher.CustomScalars.Should().BeEquivalentTo(customScalars);
}
#endif
#if PROTOBUF
[Fact]
public void MatcherMapper_Map_MatcherModel_ProtoBufMatcher()
{
@@ -1132,5 +1128,4 @@ message HelloReply {
matcher.MessageType.Should().Be(messageType);
matcher.Matcher?.Value.Should().Be(jsonMatcherPattern);
}
#endif
}

View File

@@ -1,23 +1,15 @@
// Copyright © WireMock.Net
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using VerifyTests;
using VerifyXunit;
using WireMock.Matchers;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.RequestBuilders;
using WireMock.Serialization;
using WireMock.Settings;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public class ProxyMappingConverterTests
{
private static readonly VerifySettings VerifySettings = new();
@@ -79,7 +71,6 @@ public class ProxyMappingConverterTests
var model = _mappingConverter.ToMappingModel(proxyMapping);
// Verify
return Verifier.Verify(model, VerifySettings);
return Verify(model, VerifySettings);
}
}
#endif
}

View File

@@ -1,21 +1,14 @@
// Copyright © WireMock.Net
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System.Collections.Generic;
using System.Threading.Tasks;
using VerifyTests;
using VerifyXunit;
using WireMock.Admin.Mappings;
using WireMock.Models;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.Serialization;
using WireMock.Types;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public class WebhookMapperTests
{
private static readonly VerifySettings VerifySettings = new();
@@ -46,7 +39,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -71,7 +64,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -98,7 +91,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
[Fact]
@@ -130,7 +123,6 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(webhook);
// Verify
return Verifier.Verify(result, VerifySettings);
return Verify(result, VerifySettings);
}
}
#endif
}