mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-23 07:16:52 +02:00
x
This commit is contained in:
@@ -17,7 +17,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] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("CONNECT");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -29,7 +29,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] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("OPTIONS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -41,7 +41,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] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("PATCH");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -53,7 +53,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] as RequestMessageMethodMatcher).Methods.Should().ContainSingle("TRACE");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -109,8 +109,8 @@ public class ResponseWithHandlebarsJsonPathTests
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, Mock.Of<HttpContext>(), request, _settings);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson!);
|
||||
j["x"].Value<long>().Should().Be(99);
|
||||
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
|
||||
j["x"]?.Value<long>().Should().Be(99);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -163,7 +163,7 @@ public class ResponseWithHandlebarsJsonPathTests
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, Mock.Of<HttpContext>(), request, _settings);
|
||||
|
||||
// Assert
|
||||
response.Message.BodyData.BodyAsString.Should().Be($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
response.Message.BodyData!.BodyAsString.Should().Be($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -46,9 +46,9 @@ public class ResponseWithHandlebarsLinqTests
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, Mock.Of<HttpContext>(), request, _settings);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
|
||||
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
|
||||
j["x"].Should().NotBeNull();
|
||||
j["x"].ToString().Should().Be("/pathtest");
|
||||
j["x"]?.ToString().Should().Be("/pathtest");
|
||||
}
|
||||
|
||||
[Fact(Skip = "DynamicLinq")]
|
||||
@@ -76,9 +76,8 @@ public class ResponseWithHandlebarsLinqTests
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, Mock.Of<HttpContext>(), request, _settings);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
|
||||
j["x"].Should().NotBeNull();
|
||||
j["x"].ToString().Should().Be("Test_123");
|
||||
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
|
||||
j["x"].Should().NotBeNull().And.Subject.ToString().Should().Be("Test_123");
|
||||
}
|
||||
|
||||
[Fact(Skip = "DynamicLinq")]
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Moq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
@@ -69,9 +68,8 @@ public class ResponseWithHandlebarsXegerTests
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, Mock.Of<HttpContext>(), request, _settings);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
|
||||
j["Number"].Value<int>().Should().BeGreaterThan(1000).And.BeLessThan(9999);
|
||||
j["Postcode"].Value<string>().Should().NotBeEmpty();
|
||||
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
|
||||
j["Number"]?.Value<int>().Should().BeGreaterThan(1000).And.BeLessThan(9999);
|
||||
j["Postcode"]?.Value<string>().Should().NotBeEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,16 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public static class TestUtils
|
||||
{
|
||||
var field = obj.GetType().GetTypeInfo().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
return (T)field.GetValue(obj);
|
||||
return (T)field!.GetValue(obj)!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -27,8 +27,8 @@ public static class TestUtils
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
Type t = obj.GetType();
|
||||
FieldInfo fi = null;
|
||||
Type? t = obj.GetType();
|
||||
FieldInfo? fi = null;
|
||||
while (fi == null && t != null)
|
||||
{
|
||||
fi = t.GetField(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
Reference in New Issue
Block a user