This commit is contained in:
Stef Heyenrath
2026-07-19 09:59:27 +02:00
parent 8260dba641
commit f5eb01c580
8 changed files with 31 additions and 45 deletions
@@ -1,16 +1,16 @@
// Copyright © WireMock.Net
using JsonConverter.Newtonsoft.Json;
using JsonConverter.System.Text.Json;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using Moq;
using WireMock.Handlers;
using WireMock.Owin;
using WireMock.Owin.Mappers;
using WireMock.ResponseBuilders;
using WireMock.Types;
using WireMock.Util;
using WireMock.Owin;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using JsonConverter.Newtonsoft.Json;
using JsonConverter.System.Text.Json;
namespace WireMock.Net.Tests.Owin.Mappers;
@@ -40,11 +40,11 @@ public class OwinResponseMapperTests
_headers = new Mock<IHeaderDictionary>();
_headers.SetupAllProperties();
#if NET452
_headers.Setup(h => h.AppendValues(It.IsAny<string>(), It.IsAny<string[]>()));
#else
// Extension methods(here: HeaderDictionaryExtensions.Append) may not be used in setup / verification expressions.
#pragma warning disable ASP0019
_headers.Setup(h => h.Add(It.IsAny<string>(), It.IsAny<StringValues>()));
#endif
#pragma warning restore ASP0019
_responseMock = new Mock<HttpResponse>();
_responseMock.SetupAllProperties();
@@ -238,12 +238,8 @@ public class OwinResponseMapperTests
await _sut.MapAsync(responseMessage, _responseMock.Object);
// Assert
#if NET452
_headers.Verify(h => h.AppendValues("h", new string[] { "x", "y" }), Times.Once);
#else
var v = new StringValues();
_headers.Verify(h => h.TryGetValue("h", out v), Times.Once);
#endif
}
[Fact]
@@ -1,6 +1,5 @@
// Copyright © WireMock.Net
using WireMock.Matchers.Request;
using WireMock.RequestBuilders;
@@ -17,7 +16,7 @@ public class RequestBuilderUsingMethodTests
// Assert
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
matchers.Count.Should().Be(1);
(matchers[0] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("CONNECT");
matchers[0].Should().BeOfType<RequestMessageMethodMatcher>().Which.Methods.Should().ContainSingle("CONNECT");
}
[Fact]
@@ -29,7 +28,7 @@ public class RequestBuilderUsingMethodTests
// Assert
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
matchers.Count.Should().Be(1);
(matchers[0] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("OPTIONS");
matchers[0].Should().BeOfType<RequestMessageMethodMatcher>().Which.Methods.Should().ContainSingle("OPTIONS");
}
[Fact]
@@ -41,7 +40,7 @@ public class RequestBuilderUsingMethodTests
// Assert
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
matchers.Count.Should().Be(1);
(matchers[0] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("PATCH");
matchers[0].Should().BeOfType<RequestMessageMethodMatcher>().Which.Methods.Should().ContainSingle("PATCH");
}
[Fact]
@@ -53,7 +52,7 @@ public class RequestBuilderUsingMethodTests
// Assert
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
matchers.Count.Should().Be(1);
(matchers[0] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("TRACE");
matchers[0].Should().BeOfType<RequestMessageMethodMatcher>().Which.Methods.Should().ContainSingle("TRACE");
}
[Fact]