Files
WireMock.Net/test/WireMock.Net.Tests/Serialization/ProxyMappingConverterTests.cs
Stef Heyenrath a292f28dda 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
2026-03-11 17:02:47 +01:00

76 lines
2.4 KiB
C#

// Copyright © WireMock.Net
using Moq;
using WireMock.Matchers;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.RequestBuilders;
using WireMock.Serialization;
using WireMock.Settings;
using WireMock.Util;
namespace WireMock.Net.Tests.Serialization;
public class ProxyMappingConverterTests
{
private static readonly VerifySettings VerifySettings = new();
static ProxyMappingConverterTests()
{
VerifySettings.Init();
}
private readonly WireMockServerSettings _settings = new();
private readonly MappingConverter _mappingConverter;
private readonly ProxyMappingConverter _sut;
public ProxyMappingConverterTests()
{
var guidUtilsMock = new Mock<IGuidUtils>();
guidUtilsMock.Setup(g => g.NewGuid()).Returns(Guid.Parse("ff55ac0a-fea9-4d7b-be74-5e483a2c1305"));
var dateTimeUtilsMock = new Mock<IDateTimeUtils>();
dateTimeUtilsMock.SetupGet(d => d.UtcNow).Returns(new DateTime(2022, 12, 4));
_mappingConverter = new MappingConverter(new MatcherMapper(_settings));
_sut = new ProxyMappingConverter(_settings, guidUtilsMock.Object, dateTimeUtilsMock.Object);
}
[Fact]
public Task ToMapping_UseDefinedRequestMatchers_True()
{
// Arrange
var proxyAndRecordSettings = new ProxyAndRecordSettings
{
UseDefinedRequestMatchers = true
};
var request = Request.Create()
.UsingPost()
.WithPath("/x")
.WithParam("p1", "p1-v")
.WithParam("p2", "p2-v")
.WithHeader("Content-Type", new ContentTypeMatcher("text/plain"))
.WithCookie("c", "x")
.WithBody(new RegexMatcher("<RequestType>Auth</RequestType>"));
var mappingMock = new Mock<IMapping>();
mappingMock.SetupGet(m => m.RequestMatcher).Returns(request);
mappingMock.SetupGet(m => m.Title).Returns("my title");
mappingMock.SetupGet(m => m.Description).Returns("my description");
var requestMessageMock = new Mock<IRequestMessage>();
var responseMessage = new ResponseMessage();
// Act
var proxyMapping = _sut.ToMapping(mappingMock.Object, proxyAndRecordSettings, requestMessageMock.Object, responseMessage)!;
// Assert
var model = _mappingConverter.ToMappingModel(proxyMapping);
// Verify
return Verify(model, VerifySettings);
}
}