mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-11 21:12:16 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15ece7ec09 | ||
|
|
f76ea1d8ec | ||
|
|
ea4ea95866 | ||
|
|
336cb7ccae | ||
|
|
13f87a1364 | ||
|
|
dd35cea44e | ||
|
|
11b39cf57c | ||
|
|
2c001f661d | ||
|
|
0b278dbbbb | ||
|
|
add3f662ba | ||
|
|
c0c07ea127 | ||
|
|
e20a90b615 | ||
|
|
9210957e55 | ||
|
|
c135854cbe | ||
|
|
54fe0823dc | ||
|
|
ef9baf3472 | ||
|
|
22f9647e88 | ||
|
|
d5fa385a46 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
|||||||
|
# 1.5.55 (22 May 2024)
|
||||||
|
- [#1107](https://github.com/WireMock-Net/WireMock.Net/pull/1107) - When only Port is provided, bind to * (Fixes #1100) [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|
||||||
|
# 1.5.54 (18 May 2024)
|
||||||
|
- [#1100](https://github.com/WireMock-Net/WireMock.Net/pull/1100) - Add support to bind to ip-address instead of only localhost [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#1104](https://github.com/WireMock-Net/WireMock.Net/pull/1104) - Use try..catch to set encoding in WireMockConsoleLogger [feature] contributed by [asherber](https://github.com/asherber)
|
||||||
|
|
||||||
|
# 1.5.53 (08 May 2024)
|
||||||
|
- [#1093](https://github.com/WireMock-Net/WireMock.Net/pull/1093) - Update Handlebars.Net [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#1101](https://github.com/WireMock-Net/WireMock.Net/pull/1101) - Fix MappingConverter to support Body with JsonMatcher [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#1095](https://github.com/WireMock-Net/WireMock.Net/issues/1095) - When using C# code generation WithBody() matcher is not generated for POST Request [bug]
|
||||||
|
|
||||||
|
# 1.5.52 (06 April 2024)
|
||||||
|
- [#1091](https://github.com/WireMock-Net/WireMock.Net/pull/1091) - Add RegEx support to JsonMatcher [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#1088](https://github.com/WireMock-Net/WireMock.Net/issues/1088) - Regex support for JsonMatcher [feature]
|
||||||
|
|
||||||
|
# 1.5.51 (20 March 2024)
|
||||||
|
- [#1085](https://github.com/WireMock-Net/WireMock.Net/pull/1085) - Fix FluentAssertions (actual body is not displayed in error message) [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#1084](https://github.com/WireMock-Net/WireMock.Net/issues/1084) - FluentAssertions - Actual body is not displayed in error message when using Json Body [bug]
|
||||||
|
|
||||||
# 1.5.50 (12 March 2024)
|
# 1.5.50 (12 March 2024)
|
||||||
- [#1080](https://github.com/WireMock-Net/WireMock.Net/pull/1080) - Fix FluentAssertions on Header(s) [bug] contributed by [StefH](https://github.com/StefH)
|
- [#1080](https://github.com/WireMock-Net/WireMock.Net/pull/1080) - Fix FluentAssertions on Header(s) [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
- [#1082](https://github.com/WireMock-Net/WireMock.Net/pull/1082) - Make WireMockAssertions extendable [feature] contributed by [StefH](https://github.com/StefH)
|
- [#1082](https://github.com/WireMock-Net/WireMock.Net/pull/1082) - Make WireMockAssertions extendable [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>1.5.50</VersionPrefix>
|
<VersionPrefix>1.5.55</VersionPrefix>
|
||||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||||
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
||||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
rem https://github.com/StefH/GitHubReleaseNotes
|
rem https://github.com/StefH/GitHubReleaseNotes
|
||||||
|
|
||||||
SET version=1.5.50
|
SET version=1.5.55
|
||||||
|
|
||||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate example --version %version% --token %GH_TOKEN%
|
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate example --version %version% --token %GH_TOKEN%
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
# 1.5.50 (12 March 2024)
|
# 1.5.55 (22 May 2024)
|
||||||
- #1080 Fix FluentAssertions on Header(s) [bug]
|
- #1107 When only Port is provided, bind to * (Fixes #1100) [bug]
|
||||||
- #1082 Make WireMockAssertions extendable [feature]
|
|
||||||
- #1074 FluentAssertions extensions do not filter headers correctly [bug]
|
|
||||||
- #1075 FluentAssertions extensions are not open for extension [feature]
|
|
||||||
|
|
||||||
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using MimeKit;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.RequestBuilders;
|
using WireMock.RequestBuilders;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
@@ -18,17 +20,90 @@ internal class Program
|
|||||||
Logger = new WireMockConsoleLogger(),
|
Logger = new WireMockConsoleLogger(),
|
||||||
});
|
});
|
||||||
|
|
||||||
server.Given(Request.Create().UsingPost().WithPath("/some/endpoint"))
|
server
|
||||||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created));
|
.Given(Request.Create()
|
||||||
|
.UsingPost()
|
||||||
|
.WithPath("/test")
|
||||||
|
)
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithBody(requestMessage => requestMessage.BodyAsMimeMessage != null ?
|
||||||
|
"BodyAsMimeMessage is present" :
|
||||||
|
"BodyAsMimeMessage is not present")
|
||||||
|
);
|
||||||
|
|
||||||
var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) };
|
server
|
||||||
var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint");
|
.Given(Request.Create()
|
||||||
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
|
.UsingPost()
|
||||||
|
.WithPath("/some/endpoint")
|
||||||
|
)
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithStatusCode(HttpStatusCode.Created)
|
||||||
|
);
|
||||||
|
|
||||||
|
var httpClient = server.CreateClient();
|
||||||
|
var content = new StringContent("abc", Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
await TestAsync(httpClient, content);
|
||||||
|
|
||||||
|
await TestNoMultiPartAsync(httpClient, content);
|
||||||
|
|
||||||
|
await TestMultiPartAsync(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task TestNoMultiPartAsync(HttpClient httpClient, StringContent content)
|
||||||
|
{
|
||||||
|
var response = await httpClient.PostAsync("/test", content);
|
||||||
|
|
||||||
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||||
|
(await response.Content.ReadAsStringAsync()).Should().Be("BodyAsMimeMessage is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task TestAsync(HttpClient httpClient, StringContent content)
|
||||||
|
{
|
||||||
|
var response = await httpClient.PostAsync("some/endpoint", content);
|
||||||
|
|
||||||
|
response.StatusCode.Should().Be(HttpStatusCode.Created);
|
||||||
|
(await response.Content.ReadAsStringAsync()).Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task TestMultiPartAsync(WireMockServer server)
|
||||||
|
{
|
||||||
|
var textPlainContent = "This is some plain text";
|
||||||
|
var textPlainContentType = "text/plain";
|
||||||
|
|
||||||
|
var textJson = "{ \"Key\" : \"Value\" }";
|
||||||
|
var textJsonContentType = "text/json";
|
||||||
|
|
||||||
|
var imagePngBytes = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAIAAAACAgMAAAAP2OW3AAAADFBMVEX/tID/vpH/pWX/sHidUyjlAAAADElEQVR4XmMQYNgAAADkAMHebX3mAAAAAElFTkSuQmCC");
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(
|
||||||
|
Request.Create()
|
||||||
|
.UsingPost()
|
||||||
|
.WithPath("/multipart")
|
||||||
|
)
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithBody(requestMessage => requestMessage.BodyAsMimeMessage is MimeMessage mm ?
|
||||||
|
"BodyAsMimeMessage is present: " + ((MimePart)mm.BodyParts.Last()).FileName :
|
||||||
|
"BodyAsMimeMessage is not present")
|
||||||
|
);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actual = await httpClient.PostAsync(requestUri, content);
|
var formDataContent = new MultipartFormDataContent
|
||||||
|
{
|
||||||
|
{ new StringContent(textPlainContent, Encoding.UTF8, textPlainContentType), "text" },
|
||||||
|
{ new StringContent(textJson, Encoding.UTF8, textJsonContentType), "json" }
|
||||||
|
};
|
||||||
|
|
||||||
// Assert
|
var fileContent = new ByteArrayContent(imagePngBytes);
|
||||||
actual.StatusCode.Should().Be(HttpStatusCode.Created);
|
fileContent.Headers.ContentType = new MediaTypeHeaderValue("image/png");
|
||||||
|
formDataContent.Add(fileContent, "somefile", "image.png");
|
||||||
|
|
||||||
|
var client = server.CreateClient();
|
||||||
|
|
||||||
|
var response = await client.PostAsync("/multipart", formDataContent);
|
||||||
|
|
||||||
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||||
|
(await response.Content.ReadAsStringAsync()).Should().Be("BodyAsMimeMessage is present: image.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.11.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||||
<PackageReference Include="WireMock.Net" Version="1.5.42" />
|
<PackageReference Include="WireMock.Net" Version="1.5.51" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
@@ -94,8 +95,48 @@ message HelloReply {
|
|||||||
fullName:String
|
fullName:String
|
||||||
}";
|
}";
|
||||||
|
|
||||||
|
private static void RunOnLocal()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var server = WireMockServer.Start(new WireMockServerSettings
|
||||||
|
{
|
||||||
|
Port = 9091,
|
||||||
|
StartAdminInterface = true,
|
||||||
|
Logger = new WireMockConsoleLogger()
|
||||||
|
});
|
||||||
|
System.Console.WriteLine(string.Join(", ", server.Urls));
|
||||||
|
|
||||||
|
var requestJson = new { PricingContext = new { Market = "USA" } };
|
||||||
|
var responseJson = new { Market = "{{JsonPath.SelectToken request.body \"$.PricingContext.Market\"}}" };
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
//.WithBody(new JsonMatcher(requestJson))
|
||||||
|
.WithBodyAsJson(requestJson)
|
||||||
|
.WithPath("/pricing")
|
||||||
|
.UsingPost()
|
||||||
|
)
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithHeader("Content-Type", "application/json")
|
||||||
|
.WithBodyAsJson(responseJson)
|
||||||
|
.WithTransformer(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
System.Console.WriteLine("Press any key to stop...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Run()
|
public static void Run()
|
||||||
{
|
{
|
||||||
|
RunOnLocal();
|
||||||
|
return;
|
||||||
|
|
||||||
var mappingBuilder = new MappingBuilder();
|
var mappingBuilder = new MappingBuilder();
|
||||||
mappingBuilder
|
mappingBuilder
|
||||||
.Given(Request
|
.Given(Request
|
||||||
@@ -188,7 +229,10 @@ message HelloReply {
|
|||||||
server.SetBasicAuthentication("a", "b");
|
server.SetBasicAuthentication("a", "b");
|
||||||
//server.SetAzureADAuthentication("6c2a4722-f3b9-4970-b8fc-fac41e29stef", "8587fde1-7824-42c7-8592-faf92b04stef");
|
//server.SetAzureADAuthentication("6c2a4722-f3b9-4970-b8fc-fac41e29stef", "8587fde1-7824-42c7-8592-faf92b04stef");
|
||||||
|
|
||||||
// server.AllowPartialMapping();
|
|
||||||
|
//var http = new HttpClient();
|
||||||
|
//var response = await http.GetAsync($"{_wireMockServer.Url}/pricing");
|
||||||
|
//var value = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
#if PROTOBUF
|
#if PROTOBUF
|
||||||
var protoBufJsonMatcher = new JsonPartialWildcardMatcher(new { name = "*" });
|
var protoBufJsonMatcher = new JsonPartialWildcardMatcher(new { name = "*" });
|
||||||
@@ -332,7 +376,6 @@ message HelloReply {
|
|||||||
.WithHeader("Content-Type", "text/plain")
|
.WithHeader("Content-Type", "text/plain")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
server
|
server
|
||||||
.Given(Request.Create()
|
.Given(Request.Create()
|
||||||
.UsingMethod("GET")
|
.UsingMethod("GET")
|
||||||
|
|||||||
@@ -39,17 +39,17 @@
|
|||||||
<Reference Include="AnyOf, Version=0.3.0.0, Culture=neutral, PublicKeyToken=b35e6abbb527c6b1, processorArchitecture=MSIL">
|
<Reference Include="AnyOf, Version=0.3.0.0, Culture=neutral, PublicKeyToken=b35e6abbb527c6b1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll</HintPath>
|
<HintPath>..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars, Version=2.1.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
<Reference Include="Handlebars, Version=2.1.6.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.2.1.4\lib\net452\Handlebars.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.2.1.6\lib\net451\Handlebars.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars.Net.Helpers, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="Handlebars.Net.Helpers, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.0\lib\net452\Handlebars.Net.Helpers.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.3\lib\net452\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.0\lib\net452\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.3\lib\net452\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
<HintPath>..\..\packages\log4net.2.0.17\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="AnyOf" version="0.3.0" targetFramework="net452" />
|
<package id="AnyOf" version="0.3.0" targetFramework="net452" />
|
||||||
<package id="Handlebars.Net" version="2.1.4" targetFramework="net452" />
|
<package id="Handlebars.Net" version="2.1.6" targetFramework="net452" />
|
||||||
<package id="Handlebars.Net.Helpers" version="2.4.0" targetFramework="net452" />
|
<package id="Handlebars.Net.Helpers" version="2.4.3" targetFramework="net452" />
|
||||||
<package id="Handlebars.Net.Helpers.Core" version="2.4.0" targetFramework="net452" />
|
<package id="Handlebars.Net.Helpers.Core" version="2.4.3" targetFramework="net452" />
|
||||||
<package id="log4net" version="2.0.15" targetFramework="net452" />
|
<package id="log4net" version="2.0.17" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="3.1.0" targetFramework="net452" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="3.1.0" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net452" />
|
||||||
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
|
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
|
||||||
|
|||||||
@@ -38,17 +38,17 @@
|
|||||||
<Reference Include="AnyOf, Version=0.3.0.0, Culture=neutral, PublicKeyToken=b35e6abbb527c6b1, processorArchitecture=MSIL">
|
<Reference Include="AnyOf, Version=0.3.0.0, Culture=neutral, PublicKeyToken=b35e6abbb527c6b1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll</HintPath>
|
<HintPath>..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars, Version=2.1.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
<Reference Include="Handlebars, Version=2.1.6.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.2.1.4\lib\net46\Handlebars.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.2.1.6\lib\net451\Handlebars.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars.Net.Helpers, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="Handlebars.Net.Helpers, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.0\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.3\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
<HintPath>..\..\packages\log4net.2.0.17\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="AnyOf" version="0.3.0" targetFramework="net461" />
|
<package id="AnyOf" version="0.3.0" targetFramework="net461" />
|
||||||
<package id="Handlebars.Net" version="2.1.4" targetFramework="net461" />
|
<package id="Handlebars.Net" version="2.1.6" targetFramework="net461" />
|
||||||
<package id="Handlebars.Net.Helpers" version="2.4.0" targetFramework="net461" />
|
<package id="Handlebars.Net.Helpers" version="2.4.3" targetFramework="net461" />
|
||||||
<package id="Handlebars.Net.Helpers.Core" version="2.4.0" targetFramework="net461" />
|
<package id="Handlebars.Net.Helpers.Core" version="2.4.3" targetFramework="net461" />
|
||||||
<package id="log4net" version="2.0.15" targetFramework="net461" />
|
<package id="log4net" version="2.0.17" targetFramework="net461" />
|
||||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net461" />
|
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net461" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
|
||||||
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
||||||
|
|||||||
@@ -46,32 +46,32 @@
|
|||||||
<Reference Include="Fare, Version=2.2.0.0, Culture=neutral, PublicKeyToken=ea68d375bf33a7c8, processorArchitecture=MSIL">
|
<Reference Include="Fare, Version=2.2.0.0, Culture=neutral, PublicKeyToken=ea68d375bf33a7c8, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Fare.2.2.1\lib\net35\Fare.dll</HintPath>
|
<HintPath>..\..\packages\Fare.2.2.1\lib\net35\Fare.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars, Version=2.1.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
<Reference Include="Handlebars, Version=2.1.6.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.2.1.4\lib\net46\Handlebars.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.2.1.6\lib\net451\Handlebars.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Handlebars.Net.Helpers, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="Handlebars.Net.Helpers, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.1.2\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.3\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.3\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.3\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.4.3.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.XPath.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.4.3\lib\net46\HandlebarsDotNet.Helpers.XPath.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
<Reference Include="Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Humanizer.Core.2.14.1\lib\netstandard2.0\Humanizer.dll</HintPath>
|
<HintPath>..\..\packages\Humanizer.Core.2.14.1\lib\netstandard2.0\Humanizer.dll</HintPath>
|
||||||
@@ -79,8 +79,8 @@
|
|||||||
<Reference Include="JmesPath.Net, Version=1.0.125.0, Culture=neutral, PublicKeyToken=b29d616b7f4faff0, processorArchitecture=MSIL">
|
<Reference Include="JmesPath.Net, Version=1.0.125.0, Culture=neutral, PublicKeyToken=b29d616b7f4faff0, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll</HintPath>
|
<HintPath>..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
<HintPath>..\..\packages\log4net.2.0.17\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
|
<HintPath>..\..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
|
||||||
@@ -307,8 +307,8 @@
|
|||||||
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.3.1.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
<Reference Include="System.Linq.Dynamic.Core, Version=1.3.14.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.3.1\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.3.14\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
|
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
|
||||||
<HintPath>..\..\packages/System.Memory.4.5.5/lib/net461/System.Memory.dll</HintPath>
|
<HintPath>..\..\packages/System.Memory.4.5.5/lib/net461/System.Memory.dll</HintPath>
|
||||||
@@ -358,11 +358,11 @@
|
|||||||
<Reference Include="TinyMapper, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="TinyMapper, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\TinyMapper.3.0.3\lib\net40\TinyMapper.dll</HintPath>
|
<HintPath>..\..\packages\TinyMapper.3.0.3\lib\net40\TinyMapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="XPath2, Version=1.1.4.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
<Reference Include="XPath2, Version=1.1.5.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\XPath2.1.1.4\lib\net452\XPath2.dll</HintPath>
|
<HintPath>..\..\packages\XPath2.1.1.5\lib\net452\XPath2.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="XPath2.Extensions, Version=1.1.4.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
<Reference Include="XPath2.Extensions, Version=1.1.5.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\XPath2.Extensions.1.1.4\lib\net452\XPath2.Extensions.dll</HintPath>
|
<HintPath>..\..\packages\XPath2.Extensions.1.1.5\lib\net452\XPath2.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="AnyOf" version="0.3.0" targetFramework="net472" />
|
<package id="AnyOf" version="0.3.0" targetFramework="net472" />
|
||||||
<package id="Fare" version="2.2.1" targetFramework="net472" />
|
<package id="Fare" version="2.2.1" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net" version="2.1.4" targetFramework="net472" />
|
<package id="Handlebars.Net" version="2.1.6" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.Core" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.Core" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.Humanizer" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.Humanizer" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.Json" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.Json" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.Random" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.Random" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.Xeger" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.Xeger" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Handlebars.Net.Helpers.XPath" version="2.4.1.2" targetFramework="net472" />
|
<package id="Handlebars.Net.Helpers.XPath" version="2.4.3" targetFramework="net472" />
|
||||||
<package id="Humanizer" version="2.14.1" targetFramework="net472" />
|
<package id="Humanizer" version="2.14.1" targetFramework="net472" />
|
||||||
<package id="Humanizer.Core" version="2.14.1" targetFramework="net472" />
|
<package id="Humanizer.Core" version="2.14.1" targetFramework="net472" />
|
||||||
<package id="Humanizer.Core.af" version="2.14.1" targetFramework="net472" />
|
<package id="Humanizer.Core.af" version="2.14.1" targetFramework="net472" />
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<package id="Humanizer.Core.zh-Hans" version="2.14.1" targetFramework="net472" />
|
<package id="Humanizer.Core.zh-Hans" version="2.14.1" targetFramework="net472" />
|
||||||
<package id="Humanizer.Core.zh-Hant" version="2.14.1" targetFramework="net472" />
|
<package id="Humanizer.Core.zh-Hant" version="2.14.1" targetFramework="net472" />
|
||||||
<package id="JmesPath.Net" version="1.0.125" targetFramework="net472" />
|
<package id="JmesPath.Net" version="1.0.125" targetFramework="net472" />
|
||||||
<package id="log4net" version="2.0.15" targetFramework="net472" />
|
<package id="log4net" version="2.0.17" targetFramework="net472" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.8" targetFramework="net472" />
|
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.8" targetFramework="net472" />
|
||||||
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
|
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
|
||||||
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net472" />
|
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" />
|
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" />
|
||||||
<package id="System.IdentityModel.Tokens.Jwt" version="6.34.0" targetFramework="net472" />
|
<package id="System.IdentityModel.Tokens.Jwt" version="6.34.0" targetFramework="net472" />
|
||||||
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net472" />
|
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net472" />
|
||||||
<package id="System.Linq.Dynamic.Core" version="1.3.1" targetFramework="net472" />
|
<package id="System.Linq.Dynamic.Core" version="1.3.14" targetFramework="net472" />
|
||||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
|
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
|
||||||
@@ -151,6 +151,6 @@
|
|||||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||||
<package id="TinyMapper" version="3.0.3" targetFramework="net472" />
|
<package id="TinyMapper" version="3.0.3" targetFramework="net472" />
|
||||||
<package id="XPath2" version="1.1.4" targetFramework="net472" />
|
<package id="XPath2" version="1.1.5" targetFramework="net472" />
|
||||||
<package id="XPath2.Extensions" version="1.1.4" targetFramework="net472" />
|
<package id="XPath2.Extensions" version="1.1.5" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -18,6 +18,5 @@ public class DynamicDataGeneration : WireMockOpenApiParserDynamicExampleValues
|
|||||||
Pattern = $"[0-9A-Z]{{{maxLength}}}"
|
Pattern = $"[0-9A-Z]{{{maxLength}}}"
|
||||||
}).Generate() ?? "example-string";
|
}).Generate() ?? "example-string";
|
||||||
}
|
}
|
||||||
set { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ public class MatcherModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? MatchOperator { get; set; }
|
public string? MatchOperator { get; set; }
|
||||||
|
|
||||||
#region JsonPartialMatcher and JsonPartialWildcardMatcher
|
#region JsonMatcher, JsonPartialMatcher and JsonPartialWildcardMatcher
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Support Regex.
|
/// Support Regex.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using AnyOfTypes;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using WireMock.Extensions;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Models;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
namespace WireMock.FluentAssertions;
|
namespace WireMock.FluentAssertions;
|
||||||
@@ -9,7 +14,7 @@ namespace WireMock.FluentAssertions;
|
|||||||
public partial class WireMockAssertions
|
public partial class WireMockAssertions
|
||||||
{
|
{
|
||||||
private const string MessageFormatNoCalls = "Expected {context:wiremockserver} to have been called using body {0}{reason}, but no calls were made.";
|
private const string MessageFormatNoCalls = "Expected {context:wiremockserver} to have been called using body {0}{reason}, but no calls were made.";
|
||||||
private const string MessageFormat = "Expected {context:wiremockserver} to have been called using body {0}{reason}, but didn't find it among the body {1}.";
|
private const string MessageFormat = "Expected {context:wiremockserver} to have been called using body {0}{reason}, but didn't find it among the body/bodies {1}.";
|
||||||
|
|
||||||
[CustomAssertion]
|
[CustomAssertion]
|
||||||
public AndConstraint<WireMockAssertions> WithBody(string body, string because = "", params object[] becauseArgs)
|
public AndConstraint<WireMockAssertions> WithBody(string body, string because = "", params object[] becauseArgs)
|
||||||
@@ -56,7 +61,7 @@ public partial class WireMockAssertions
|
|||||||
{
|
{
|
||||||
var (filter, condition) = BuildFilterAndCondition(r => r.BodyAsBytes, matcher);
|
var (filter, condition) = BuildFilterAndCondition(r => r.BodyAsBytes, matcher);
|
||||||
|
|
||||||
return ExecuteAssertionWithBodyAsBytesExactObjectMatcher(matcher, because, becauseArgs, condition, filter, r => r.BodyAsBytes);
|
return ExecuteAssertionWithBodyAsIObjectMatcher(matcher, because, becauseArgs, condition, filter, r => r.BodyAsBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AndConstraint<WireMockAssertions> ExecuteAssertionWithBodyStringMatcher(
|
private AndConstraint<WireMockAssertions> ExecuteAssertionWithBodyStringMatcher(
|
||||||
@@ -74,14 +79,14 @@ public partial class WireMockAssertions
|
|||||||
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
||||||
.FailWith(
|
.FailWith(
|
||||||
MessageFormatNoCalls,
|
MessageFormatNoCalls,
|
||||||
matcher.GetPatterns()
|
FormatBody(matcher.GetPatterns())
|
||||||
)
|
)
|
||||||
.Then
|
.Then
|
||||||
.ForCondition(condition)
|
.ForCondition(condition)
|
||||||
.FailWith(
|
.FailWith(
|
||||||
MessageFormat,
|
MessageFormat,
|
||||||
_ => matcher.GetPatterns(),
|
_ => FormatBody(matcher.GetPatterns()),
|
||||||
requests => requests.Select(expression)
|
requests => FormatBodies(requests.Select(expression))
|
||||||
);
|
);
|
||||||
|
|
||||||
FilterRequestMessages(filter);
|
FilterRequestMessages(filter);
|
||||||
@@ -104,14 +109,14 @@ public partial class WireMockAssertions
|
|||||||
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
||||||
.FailWith(
|
.FailWith(
|
||||||
MessageFormatNoCalls,
|
MessageFormatNoCalls,
|
||||||
matcher.Value
|
FormatBody(matcher.Value)
|
||||||
)
|
)
|
||||||
.Then
|
.Then
|
||||||
.ForCondition(condition)
|
.ForCondition(condition)
|
||||||
.FailWith(
|
.FailWith(
|
||||||
MessageFormat,
|
MessageFormat,
|
||||||
_ => matcher.Value,
|
_ => FormatBody(matcher.Value),
|
||||||
requests => requests.Select(expression)
|
requests => FormatBodies(requests.Select(expression))
|
||||||
);
|
);
|
||||||
|
|
||||||
FilterRequestMessages(filter);
|
FilterRequestMessages(filter);
|
||||||
@@ -119,33 +124,22 @@ public partial class WireMockAssertions
|
|||||||
return new AndConstraint<WireMockAssertions>(this);
|
return new AndConstraint<WireMockAssertions>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AndConstraint<WireMockAssertions> ExecuteAssertionWithBodyAsBytesExactObjectMatcher(
|
private static string? FormatBody(object? body)
|
||||||
ExactObjectMatcher matcher,
|
|
||||||
string because,
|
|
||||||
object[] becauseArgs,
|
|
||||||
Func<IReadOnlyList<IRequestMessage>, bool> condition,
|
|
||||||
Func<IReadOnlyList<IRequestMessage>, IReadOnlyList<IRequestMessage>> filter,
|
|
||||||
Func<IRequestMessage, object?> expression
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
Execute.Assertion
|
return body switch
|
||||||
.BecauseOf(because, becauseArgs)
|
{
|
||||||
.Given(() => RequestMessages)
|
null => null,
|
||||||
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
string str => str,
|
||||||
.FailWith(
|
AnyOf<string, StringPattern>[] stringPatterns => FormatBodies(stringPatterns.Select(p => p.GetPattern())),
|
||||||
MessageFormatNoCalls,
|
byte[] bytes => $"byte[{bytes.Length}] {{...}}",
|
||||||
matcher.Value
|
JToken jToken => jToken.ToString(Formatting.None),
|
||||||
)
|
_ => JToken.FromObject(body).ToString(Formatting.None)
|
||||||
.Then
|
};
|
||||||
.ForCondition(condition)
|
}
|
||||||
.FailWith(
|
|
||||||
MessageFormat,
|
|
||||||
_ => matcher.Value,
|
|
||||||
requests => requests.Select(expression)
|
|
||||||
);
|
|
||||||
|
|
||||||
FilterRequestMessages(filter);
|
private static string? FormatBodies(IEnumerable<object?> bodies)
|
||||||
|
{
|
||||||
return new AndConstraint<WireMockAssertions>(this);
|
var valueAsArray = bodies as object[] ?? bodies.ToArray();
|
||||||
|
return valueAsArray.Length == 1 ? FormatBody(valueAsArray.First()) : $"[ {string.Join(", ", valueAsArray.Select(FormatBody))} ]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,10 @@ public class WireMockOpenApiParserDynamicExampleValues : IWireMockOpenApiParserE
|
|||||||
public virtual double Double => RandomizerFactory.GetRandomizer(new FieldOptionsDouble()).Generate() ?? 4.2d;
|
public virtual double Double => RandomizerFactory.GetRandomizer(new FieldOptionsDouble()).Generate() ?? 4.2d;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual Func<DateTime> Date { get { return () => RandomizerFactory.GetRandomizer(new FieldOptionsDateTime()).Generate() ?? System.DateTime.UtcNow.Date; } }
|
public virtual Func<DateTime> Date => () => RandomizerFactory.GetRandomizer(new FieldOptionsDateTime()).Generate() ?? System.DateTime.UtcNow.Date;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual Func<DateTime> DateTime { get { return () => RandomizerFactory.GetRandomizer(new FieldOptionsDateTime()).Generate() ?? System.DateTime.UtcNow; } }
|
public virtual Func<DateTime> DateTime => () => RandomizerFactory.GetRandomizer(new FieldOptionsDateTime()).Generate() ?? System.DateTime.UtcNow;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual byte[] Bytes => RandomizerFactory.GetRandomizer(new FieldOptionsBytes()).Generate();
|
public virtual byte[] Bytes => RandomizerFactory.GetRandomizer(new FieldOptionsBytes()).Generate();
|
||||||
|
|||||||
@@ -5,18 +5,36 @@ using WireMock.Models;
|
|||||||
|
|
||||||
namespace WireMock.Extensions;
|
namespace WireMock.Extensions;
|
||||||
|
|
||||||
internal static class AnyOfExtensions
|
/// <summary>
|
||||||
|
/// Some extensions for AnyOf.
|
||||||
|
/// </summary>
|
||||||
|
public static class AnyOfExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the pattern.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">AnyOf type</param>
|
||||||
|
/// <returns>string value</returns>
|
||||||
public static string GetPattern(this AnyOf<string, StringPattern> value)
|
public static string GetPattern(this AnyOf<string, StringPattern> value)
|
||||||
{
|
{
|
||||||
return value.IsFirst ? value.First : value.Second.Pattern;
|
return value.IsFirst ? value.First : value.Second.Pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a string-patterns to AnyOf patterns.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="patterns">The string patterns</param>
|
||||||
|
/// <returns>The AnyOf patterns</returns>
|
||||||
public static AnyOf<string, StringPattern>[] ToAnyOfPatterns(this IEnumerable<string> patterns)
|
public static AnyOf<string, StringPattern>[] ToAnyOfPatterns(this IEnumerable<string> patterns)
|
||||||
{
|
{
|
||||||
return patterns.Select(p => p.ToAnyOfPattern()).ToArray();
|
return patterns.Select(p => p.ToAnyOfPattern()).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a string-pattern to AnyOf pattern.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern">The string pattern</param>
|
||||||
|
/// <returns>The AnyOf pattern</returns>
|
||||||
public static AnyOf<string, StringPattern> ToAnyOfPattern(this string pattern)
|
public static AnyOf<string, StringPattern> ToAnyOfPattern(this string pattern)
|
||||||
{
|
{
|
||||||
return new AnyOf<string, StringPattern>(pattern);
|
return new AnyOf<string, StringPattern>(pattern);
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ public class WireMockConsoleLogger : IWireMockLogger
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public WireMockConsoleLogger()
|
public WireMockConsoleLogger()
|
||||||
{
|
{
|
||||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
try
|
||||||
|
{
|
||||||
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Debug"/>
|
/// <see cref="IWireMockLogger.Debug"/>
|
||||||
|
|||||||
@@ -10,20 +10,15 @@ namespace WireMock.Matchers;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Support Regex
|
|
||||||
/// </summary>
|
|
||||||
public bool Regex { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="AbstractJsonPartialMatcher"/> class.
|
/// Initializes a new instance of the <see cref="AbstractJsonPartialMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The string value to check for equality.</param>
|
/// <param name="value">The string value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
/// <param name="regex">Support Regex.</param>
|
/// <param name="regex">Support Regex.</param>
|
||||||
protected AbstractJsonPartialMatcher(string value, bool ignoreCase = false, bool regex = false) : base(value, ignoreCase)
|
protected AbstractJsonPartialMatcher(string value, bool ignoreCase = false, bool regex = false) :
|
||||||
|
base(value, ignoreCase, regex)
|
||||||
{
|
{
|
||||||
Regex = regex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,9 +27,9 @@ public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
|||||||
/// <param name="value">The object value to check for equality.</param>
|
/// <param name="value">The object value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
/// <param name="regex">Support Regex.</param>
|
/// <param name="regex">Support Regex.</param>
|
||||||
protected AbstractJsonPartialMatcher(object value, bool ignoreCase = false, bool regex = false) : base(value, ignoreCase)
|
protected AbstractJsonPartialMatcher(object value, bool ignoreCase = false, bool regex = false) :
|
||||||
|
base(value, ignoreCase, regex)
|
||||||
{
|
{
|
||||||
Regex = regex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -44,15 +39,15 @@ public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
|||||||
/// <param name="value">The value to check for equality.</param>
|
/// <param name="value">The value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
/// <param name="regex">Support Regex.</param>
|
/// <param name="regex">Support Regex.</param>
|
||||||
protected AbstractJsonPartialMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false) : base(matchBehaviour, value, ignoreCase)
|
protected AbstractJsonPartialMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false) :
|
||||||
|
base(matchBehaviour, value, ignoreCase, regex)
|
||||||
{
|
{
|
||||||
Regex = regex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool IsMatch(JToken? value, JToken? input)
|
protected override bool IsMatch(JToken value, JToken? input)
|
||||||
{
|
{
|
||||||
if (value == null || value == input)
|
if (value == input)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -72,7 +67,7 @@ public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
|||||||
((value.Type == JTokenType.Guid && input.Type == JTokenType.String) ||
|
((value.Type == JTokenType.Guid && input.Type == JTokenType.String) ||
|
||||||
(value.Type == JTokenType.String && input.Type == JTokenType.Guid)))
|
(value.Type == JTokenType.String && input.Type == JTokenType.Guid)))
|
||||||
{
|
{
|
||||||
return IsMatch(value.ToString(), input.ToString());
|
return IsMatch(value.ToString().ToUpperInvariant(), input.ToString().ToUpperInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == null || value.Type != input.Type)
|
if (input == null || value.Type != input.Type)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
|
using JsonUtils = WireMock.Util.JsonUtils;
|
||||||
|
|
||||||
namespace WireMock.Matchers;
|
namespace WireMock.Matchers;
|
||||||
|
|
||||||
@@ -23,6 +25,11 @@ public class JsonMatcher : IJsonMatcher
|
|||||||
/// <inheritdoc cref="IIgnoreCaseMatcher.IgnoreCase"/>
|
/// <inheritdoc cref="IIgnoreCaseMatcher.IgnoreCase"/>
|
||||||
public bool IgnoreCase { get; }
|
public bool IgnoreCase { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Support Regex
|
||||||
|
/// </summary>
|
||||||
|
public bool Regex { get; }
|
||||||
|
|
||||||
private readonly JToken _valueAsJToken;
|
private readonly JToken _valueAsJToken;
|
||||||
private readonly Func<JToken, JToken> _jTokenConverter;
|
private readonly Func<JToken, JToken> _jTokenConverter;
|
||||||
|
|
||||||
@@ -31,7 +38,8 @@ public class JsonMatcher : IJsonMatcher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The string value to check for equality.</param>
|
/// <param name="value">The string value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
public JsonMatcher(string value, bool ignoreCase = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase)
|
/// <param name="regex">Support Regex.</param>
|
||||||
|
public JsonMatcher(string value, bool ignoreCase = false, bool regex = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +48,8 @@ public class JsonMatcher : IJsonMatcher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The object value to check for equality.</param>
|
/// <param name="value">The object value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
public JsonMatcher(object value, bool ignoreCase = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase)
|
/// <param name="regex">Support Regex.</param>
|
||||||
|
public JsonMatcher(object value, bool ignoreCase = false, bool regex = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,12 +59,14 @@ public class JsonMatcher : IJsonMatcher
|
|||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="value">The value to check for equality.</param>
|
/// <param name="value">The value to check for equality.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
|
||||||
public JsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false)
|
/// <param name="regex">Support Regex.</param>
|
||||||
|
public JsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false)
|
||||||
{
|
{
|
||||||
Guard.NotNull(value);
|
Guard.NotNull(value);
|
||||||
|
|
||||||
MatchBehaviour = matchBehaviour;
|
MatchBehaviour = matchBehaviour;
|
||||||
IgnoreCase = ignoreCase;
|
IgnoreCase = ignoreCase;
|
||||||
|
Regex = regex;
|
||||||
|
|
||||||
Value = value;
|
Value = value;
|
||||||
_valueAsJToken = JsonUtils.ConvertValueToJToken(value);
|
_valueAsJToken = JsonUtils.ConvertValueToJToken(value);
|
||||||
@@ -93,9 +104,79 @@ public class JsonMatcher : IJsonMatcher
|
|||||||
/// <param name="value">Matcher value</param>
|
/// <param name="value">Matcher value</param>
|
||||||
/// <param name="input">Input value</param>
|
/// <param name="input">Input value</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual bool IsMatch(JToken value, JToken input)
|
protected virtual bool IsMatch(JToken value, JToken? input)
|
||||||
{
|
{
|
||||||
return JToken.DeepEquals(value, input);
|
// If equal, return true.
|
||||||
|
if (input == value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If input is null, return false.
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If using Regex and the value is a string, use the MatchRegex method.
|
||||||
|
if (Regex && value.Type == JTokenType.String)
|
||||||
|
{
|
||||||
|
var valueAsString = value.ToString();
|
||||||
|
|
||||||
|
var (valid, result) = RegexUtils.MatchRegex(valueAsString, input.ToString());
|
||||||
|
if (valid)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the value is a Guid and the input is a string, or vice versa, convert them to strings and compare the string values.
|
||||||
|
if ((value.Type == JTokenType.Guid && input.Type == JTokenType.String) || (value.Type == JTokenType.String && input.Type == JTokenType.Guid))
|
||||||
|
{
|
||||||
|
return JToken.DeepEquals(value.ToString().ToUpperInvariant(), input.ToString().ToUpperInvariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (value.Type)
|
||||||
|
{
|
||||||
|
// If the value is an object, compare all properties.
|
||||||
|
case JTokenType.Object:
|
||||||
|
var valueProperties = value.ToObject<Dictionary<string, JToken>>() ?? new Dictionary<string, JToken>();
|
||||||
|
var inputProperties = input.ToObject<Dictionary<string, JToken>>() ?? new Dictionary<string, JToken>();
|
||||||
|
|
||||||
|
// If the number of properties is different, return false.
|
||||||
|
if (valueProperties.Count != inputProperties.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare all properties. The input must match all properties of the value.
|
||||||
|
foreach (var pair in valueProperties)
|
||||||
|
{
|
||||||
|
if (!IsMatch(pair.Value, inputProperties[pair.Key]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If the value is an array, compare all elements.
|
||||||
|
case JTokenType.Array:
|
||||||
|
var valueArray = value.ToObject<JToken[]>() ?? EmptyArray<JToken>.Value;
|
||||||
|
var inputArray = input.ToObject<JToken[]>() ?? EmptyArray<JToken>.Value;
|
||||||
|
|
||||||
|
// If the number of elements is different, return false.
|
||||||
|
if (valueArray.Length != inputArray.Length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !valueArray.Where((valueToken, index) => !IsMatch(valueToken, inputArray[index])).Any();
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Use JToken.DeepEquals() for all other types.
|
||||||
|
return JToken.DeepEquals(value, input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? ToUpper(string? input)
|
private static string? ToUpper(string? input)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#if USE_ASPNETCORE && !NETSTANDARD1_3
|
#if USE_ASPNETCORE && !NETSTANDARD1_3
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||||
@@ -25,7 +27,7 @@ namespace WireMock.Owin
|
|||||||
{
|
{
|
||||||
if (urlDetail.IsHttps)
|
if (urlDetail.IsHttps)
|
||||||
{
|
{
|
||||||
kestrelOptions.ListenAnyIP(urlDetail.Port, listenOptions =>
|
Listen(kestrelOptions, urlDetail, listenOptions =>
|
||||||
{
|
{
|
||||||
listenOptions.UseHttps(options =>
|
listenOptions.UseHttps(options =>
|
||||||
{
|
{
|
||||||
@@ -37,10 +39,11 @@ namespace WireMock.Owin
|
|||||||
wireMockMiddlewareOptions.X509ThumbprintOrSubjectName,
|
wireMockMiddlewareOptions.X509ThumbprintOrSubjectName,
|
||||||
wireMockMiddlewareOptions.X509CertificateFilePath,
|
wireMockMiddlewareOptions.X509CertificateFilePath,
|
||||||
wireMockMiddlewareOptions.X509CertificatePassword,
|
wireMockMiddlewareOptions.X509CertificatePassword,
|
||||||
urlDetail.Host);
|
urlDetail.Host
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
options.ClientCertificateMode = (ClientCertificateMode) wireMockMiddlewareOptions.ClientCertificateMode;
|
options.ClientCertificateMode = (ClientCertificateMode)wireMockMiddlewareOptions.ClientCertificateMode;
|
||||||
if (wireMockMiddlewareOptions.AcceptAnyClientCertificate)
|
if (wireMockMiddlewareOptions.AcceptAnyClientCertificate)
|
||||||
{
|
{
|
||||||
options.ClientCertificateValidation = (_, _, _) => true;
|
options.ClientCertificateValidation = (_, _, _) => true;
|
||||||
@@ -52,20 +55,41 @@ namespace WireMock.Owin
|
|||||||
listenOptions.Protocols = HttpProtocols.Http2;
|
listenOptions.Protocols = HttpProtocols.Http2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (urlDetail.IsHttp2)
|
|
||||||
|
if (urlDetail.IsHttp2)
|
||||||
{
|
{
|
||||||
kestrelOptions.ListenAnyIP(urlDetail.Port, listenOptions =>
|
Listen(kestrelOptions, urlDetail, listenOptions =>
|
||||||
{
|
{
|
||||||
listenOptions.Protocols = HttpProtocols.Http2;
|
listenOptions.Protocols = HttpProtocols.Http2;
|
||||||
});
|
});
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
Listen(kestrelOptions, urlDetail, _ => { });
|
||||||
kestrelOptions.ListenAnyIP(urlDetail.Port);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Listen(KestrelServerOptions kestrelOptions, HostUrlDetails urlDetail, Action<ListenOptions> configure)
|
||||||
|
{
|
||||||
|
// Listens on ::1 and 127.0.0.1 with the given port.
|
||||||
|
if (urlDetail is { Port: > 0, Host: "localhost" or "127.0.0.1" or "0.0.0.0" or "::1" })
|
||||||
|
{
|
||||||
|
kestrelOptions.ListenLocalhost(urlDetail.Port, configure);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to parse the host as a valid IP address and bind to the given IP address and port.
|
||||||
|
if (IPAddress.TryParse(urlDetail.Host, out var ipAddress))
|
||||||
|
{
|
||||||
|
kestrelOptions.Listen(ipAddress, urlDetail.Port, configure);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, listen on all IPs.
|
||||||
|
kestrelOptions.ListenAnyIP(urlDetail.Port, configure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class IWebHostBuilderExtensions
|
internal static class IWebHostBuilderExtensions
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace WireMock.Owin;
|
|||||||
|
|
||||||
internal class HostUrlOptions
|
internal class HostUrlOptions
|
||||||
{
|
{
|
||||||
private const string Localhost = "localhost";
|
private const string Star = "*";
|
||||||
|
|
||||||
public ICollection<string>? Urls { get; set; }
|
public ICollection<string>? Urls { get; set; }
|
||||||
|
|
||||||
@@ -25,16 +25,16 @@ internal class HostUrlOptions
|
|||||||
{
|
{
|
||||||
var port = Port > 0 ? Port.Value : FindFreeTcpPort();
|
var port = Port > 0 ? Port.Value : FindFreeTcpPort();
|
||||||
var scheme = HostingScheme == HostingScheme.Https ? "https" : "http";
|
var scheme = HostingScheme == HostingScheme.Https ? "https" : "http";
|
||||||
list.Add(new HostUrlDetails { IsHttps = HostingScheme == HostingScheme.Https, IsHttp2 = UseHttp2 == true, Url = $"{scheme}://{Localhost}:{port}", Scheme = scheme, Host = Localhost, Port = port });
|
list.Add(new HostUrlDetails { IsHttps = HostingScheme == HostingScheme.Https, IsHttp2 = UseHttp2 == true, Url = $"{scheme}://{Star}:{port}", Scheme = scheme, Host = Star, Port = port });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HostingScheme == HostingScheme.HttpAndHttps)
|
if (HostingScheme == HostingScheme.HttpAndHttps)
|
||||||
{
|
{
|
||||||
var httpPort = Port > 0 ? Port.Value : FindFreeTcpPort();
|
var httpPort = Port > 0 ? Port.Value : FindFreeTcpPort();
|
||||||
list.Add(new HostUrlDetails { IsHttps = false, IsHttp2 = UseHttp2 == true, Url = $"http://{Localhost}:{httpPort}", Scheme = "http", Host = Localhost, Port = httpPort });
|
list.Add(new HostUrlDetails { IsHttps = false, IsHttp2 = UseHttp2 == true, Url = $"http://{Star}:{httpPort}", Scheme = "http", Host = Star, Port = httpPort });
|
||||||
|
|
||||||
var httpsPort = FindFreeTcpPort(); // In this scenario, always get a free port for https.
|
var httpsPort = FindFreeTcpPort(); // In this scenario, always get a free port for https.
|
||||||
list.Add(new HostUrlDetails { IsHttps = true, IsHttp2 = UseHttp2 == true, Url = $"https://{Localhost}:{httpsPort}", Scheme = "https", Host = Localhost, Port = httpsPort });
|
list.Add(new HostUrlDetails { IsHttps = true, IsHttp2 = UseHttp2 == true, Url = $"https://{Star}:{httpsPort}", Scheme = "https", Host = Star, Port = httpsPort });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -51,23 +51,13 @@ public interface IBodyRequestBuilder : IProtoBufRequestBuilder
|
|||||||
IRequestBuilder WithBody(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
IRequestBuilder WithBody(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithBody : Body as a string response based on a object (which will be converted to a JSON string using NewtonSoft.Json).
|
/// WithBodyAsJson: A <see cref="JsonMatcher"/> will be used to match this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">The body.</param>
|
/// <param name="body">The body.</param>
|
||||||
/// <param name="matchBehaviour">The match behaviour [default is AcceptOnMatch].</param>
|
/// <param name="matchBehaviour">The match behaviour [default is AcceptOnMatch].</param>
|
||||||
/// <returns>A <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>A <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithBodyAsJson(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
IRequestBuilder WithBodyAsJson(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithBody : Body as a string response based on a object (which will be converted to a JSON string using the <see cref="IJsonConverter"/>).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="body">The body.</param>
|
|
||||||
/// <param name="converter">The JsonConverter.</param>
|
|
||||||
/// <param name="options">The <see cref="JsonConverterOptions"/> [optional].</param>
|
|
||||||
/// <param name="matchBehaviour">The match behaviour [default is AcceptOnMatch].</param>
|
|
||||||
/// <returns>A <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithBodyAsJson(object body, IJsonConverter converter, JsonConverterOptions? options = null, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithBody: func (string)
|
/// WithBody: func (string)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using JsonConverter.Abstractions;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
using WireMock.Matchers.Request;
|
using WireMock.Matchers.Request;
|
||||||
@@ -37,19 +35,7 @@ public partial class Request
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IRequestBuilder WithBodyAsJson(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
public IRequestBuilder WithBodyAsJson(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
{
|
{
|
||||||
var bodyAsJsonString = JsonConvert.SerializeObject(body);
|
return WithBody(new IMatcher[] { new JsonMatcher(matchBehaviour, body) });
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, bodyAsJsonString));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public IRequestBuilder WithBodyAsJson(object body, IJsonConverter converter, JsonConverterOptions? options = null, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
Guard.NotNull(converter);
|
|
||||||
|
|
||||||
var bodyAsJsonString = converter.Serialize(body, options);
|
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, bodyAsJsonString));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -143,25 +143,21 @@ internal class MappingConverter
|
|||||||
|
|
||||||
if (requestMessageBodyMatcher is { Matchers: { } })
|
if (requestMessageBodyMatcher is { Matchers: { } })
|
||||||
{
|
{
|
||||||
if (requestMessageBodyMatcher.Matchers.OfType<WildcardMatcher>().FirstOrDefault() is { } wildcardMatcher && wildcardMatcher.GetPatterns().Any())
|
var firstMatcher = requestMessageBodyMatcher.Matchers.FirstOrDefault();
|
||||||
|
|
||||||
|
if (firstMatcher is WildcardMatcher wildcardMatcher && wildcardMatcher.GetPatterns().Any())
|
||||||
{
|
{
|
||||||
sb.AppendLine($" .WithBody({GetString(wildcardMatcher)})");
|
sb.AppendLine($" .WithBody({GetString(wildcardMatcher)})");
|
||||||
}
|
}
|
||||||
else if (requestMessageBodyMatcher.Matchers.OfType<JsonPartialMatcher>().FirstOrDefault() is { Value: { } } jsonPartialMatcher)
|
|
||||||
|
if (firstMatcher is JsonMatcher jsonMatcher)
|
||||||
{
|
{
|
||||||
sb.AppendLine(@$" .WithBody(new JsonPartialMatcher(
|
var matcherType = jsonMatcher.GetType().Name;
|
||||||
value: {ToCSharpStringLiteral(jsonPartialMatcher.Value.ToString())},
|
sb.AppendLine($" .WithBody(new {matcherType}(");
|
||||||
ignoreCase: {ToCSharpBooleanLiteral(jsonPartialMatcher.IgnoreCase)},
|
sb.AppendLine($" value: {ConvertToAnonymousObjectDefinition(jsonMatcher.Value, 3)},");
|
||||||
regex: {ToCSharpBooleanLiteral(jsonPartialMatcher.Regex)}
|
sb.AppendLine($" ignoreCase: {ToCSharpBooleanLiteral(jsonMatcher.IgnoreCase)},");
|
||||||
))");
|
sb.AppendLine($" regex: {ToCSharpBooleanLiteral(jsonMatcher.Regex)}");
|
||||||
}
|
sb.AppendLine(@" ))");
|
||||||
else if (requestMessageBodyMatcher.Matchers.OfType<JsonPartialWildcardMatcher>().FirstOrDefault() is { Value: { } } jsonPartialWildcardMatcher)
|
|
||||||
{
|
|
||||||
sb.AppendLine(@$" .WithBody(new JsonPartialWildcardMatcher(
|
|
||||||
value: {ToCSharpStringLiteral(jsonPartialWildcardMatcher.Value.ToString())},
|
|
||||||
ignoreCase: {ToCSharpBooleanLiteral(jsonPartialWildcardMatcher.IgnoreCase)},
|
|
||||||
regex: {ToCSharpBooleanLiteral(jsonPartialWildcardMatcher.Regex)}
|
|
||||||
))");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ internal class MatcherMapper
|
|||||||
|
|
||||||
case nameof(JsonMatcher):
|
case nameof(JsonMatcher):
|
||||||
var valueForJsonMatcher = matcherModel.Pattern ?? matcherModel.Patterns;
|
var valueForJsonMatcher = matcherModel.Pattern ?? matcherModel.Patterns;
|
||||||
return new JsonMatcher(matchBehaviour, valueForJsonMatcher!, ignoreCase);
|
return new JsonMatcher(matchBehaviour, valueForJsonMatcher!, ignoreCase, useRegex);
|
||||||
|
|
||||||
case nameof(JsonPartialMatcher):
|
case nameof(JsonPartialMatcher):
|
||||||
var valueForJsonPartialMatcher = matcherModel.Pattern ?? matcherModel.Patterns;
|
var valueForJsonPartialMatcher = matcherModel.Pattern ?? matcherModel.Patterns;
|
||||||
@@ -152,12 +152,8 @@ internal class MatcherMapper
|
|||||||
|
|
||||||
switch (matcher)
|
switch (matcher)
|
||||||
{
|
{
|
||||||
case JsonPartialMatcher jsonPartialMatcher:
|
case JsonMatcher jsonMatcher:
|
||||||
model.Regex = jsonPartialMatcher.Regex;
|
model.Regex = jsonMatcher.Regex;
|
||||||
break;
|
|
||||||
|
|
||||||
case JsonPartialWildcardMatcher jsonPartialWildcardMatcher:
|
|
||||||
model.Regex = jsonPartialWildcardMatcher.Regex;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XPathMatcher xpathMatcher:
|
case XPathMatcher xpathMatcher:
|
||||||
|
|||||||
@@ -344,15 +344,13 @@ public partial class WireMockServer
|
|||||||
|
|
||||||
private static MappingConverterType GetMappingConverterType(IRequestMessage requestMessage)
|
private static MappingConverterType GetMappingConverterType(IRequestMessage requestMessage)
|
||||||
{
|
{
|
||||||
var mappingConverterType = MappingConverterType.Server;
|
|
||||||
|
|
||||||
if (requestMessage.QueryIgnoreCase?.TryGetValue(nameof(MappingConverterType), out var values) == true &&
|
if (requestMessage.QueryIgnoreCase?.TryGetValue(nameof(MappingConverterType), out var values) == true &&
|
||||||
Enum.TryParse(values.FirstOrDefault(), true, out MappingConverterType parsed))
|
Enum.TryParse(values.FirstOrDefault(), true, out MappingConverterType parsed))
|
||||||
{
|
{
|
||||||
mappingConverterType = parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mappingConverterType;
|
return MappingConverterType.Server;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMapping? FindMappingByGuid(IRequestMessage requestMessage)
|
private IMapping? FindMappingByGuid(IRequestMessage requestMessage)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace WireMock.Util;
|
|||||||
|
|
||||||
internal static class CSharpFormatter
|
internal static class CSharpFormatter
|
||||||
{
|
{
|
||||||
|
private const string Null = "null";
|
||||||
|
|
||||||
#region Reserved Keywords
|
#region Reserved Keywords
|
||||||
private static readonly HashSet<string> CSharpReservedKeywords = new(new[]
|
private static readonly HashSet<string> CSharpReservedKeywords = new(new[]
|
||||||
{
|
{
|
||||||
@@ -92,17 +94,15 @@ internal static class CSharpFormatter
|
|||||||
"while"
|
"while"
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private const string Null = "null";
|
public static object ConvertToAnonymousObjectDefinition(object jsonBody, int ind = 2)
|
||||||
|
|
||||||
public static object ConvertToAnonymousObjectDefinition(object jsonBody)
|
|
||||||
{
|
{
|
||||||
var serializedBody = JsonConvert.SerializeObject(jsonBody);
|
var serializedBody = JsonConvert.SerializeObject(jsonBody);
|
||||||
using var jsonReader = new JsonTextReader(new StringReader(serializedBody));
|
using var jsonReader = new JsonTextReader(new StringReader(serializedBody));
|
||||||
jsonReader.DateParseHandling = DateParseHandling.None;
|
jsonReader.DateParseHandling = DateParseHandling.None;
|
||||||
var deserializedBody = JObject.Load(jsonReader);
|
var deserializedBody = JObject.Load(jsonReader);
|
||||||
|
|
||||||
return ConvertJsonToAnonymousObjectDefinition(deserializedBody, 2);
|
return ConvertJsonToAnonymousObjectDefinition(deserializedBody, ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ConvertJsonToAnonymousObjectDefinition(JToken token, int ind = 0)
|
public static string ConvertJsonToAnonymousObjectDefinition(JToken token, int ind = 0)
|
||||||
|
|||||||
@@ -72,7 +72,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
|
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
|
||||||
<PackageReference Include="XPath2.Extensions" Version="1.1.4" />
|
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.34.0" />
|
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.34.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -182,13 +181,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.2.1" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.1.4" />
|
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,11 +1,49 @@
|
|||||||
var server = WireMockServer.Start();
|
var server = WireMockServer.Start();
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("POST")
|
||||||
|
.WithPath("/users/post1")
|
||||||
|
.WithBody(new JsonMatcher(
|
||||||
|
value: new
|
||||||
|
{
|
||||||
|
city = "Amsterdam",
|
||||||
|
country = "The Netherlands"
|
||||||
|
},
|
||||||
|
ignoreCase: false,
|
||||||
|
regex: false
|
||||||
|
))
|
||||||
|
)
|
||||||
|
.WithGuid("90356dba-b36c-469a-a17e-669cd84f1f05")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
);
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("POST")
|
||||||
|
.WithPath("/users/post2")
|
||||||
|
.WithBody(new JsonPartialMatcher(
|
||||||
|
value: new
|
||||||
|
{
|
||||||
|
city = "City",
|
||||||
|
country = "Country"
|
||||||
|
},
|
||||||
|
ignoreCase: false,
|
||||||
|
regex: false
|
||||||
|
))
|
||||||
|
)
|
||||||
|
.WithGuid("1b731398-4a5b-457f-a6e3-d65e541c428f")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithBody(@"Line1
|
||||||
|
Some ""value"" in Line2")
|
||||||
|
);
|
||||||
|
|
||||||
server
|
server
|
||||||
.Given(Request.Create()
|
.Given(Request.Create()
|
||||||
.UsingMethod("GET")
|
.UsingMethod("GET")
|
||||||
.WithPath("/foo1")
|
.WithPath("/foo1")
|
||||||
.WithParam("p1", "xyz")
|
.WithParam("p1", "xyz")
|
||||||
)
|
)
|
||||||
.WithGuid("90356dba-b36c-469a-a17e-669cd84f1f05")
|
.WithGuid("f74fd144-df53-404f-8e35-da22a640bd5f")
|
||||||
.RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
.WithStatusCode(200)
|
.WithStatusCode(200)
|
||||||
.WithBody("1")
|
.WithBody("1")
|
||||||
@@ -18,7 +56,7 @@ server
|
|||||||
.WithParam("p2", "abc")
|
.WithParam("p2", "abc")
|
||||||
.WithHeader("h1", "W/\"234f2q3r\"", true)
|
.WithHeader("h1", "W/\"234f2q3r\"", true)
|
||||||
)
|
)
|
||||||
.WithGuid("1b731398-4a5b-457f-a6e3-d65e541c428f")
|
.WithGuid("4126dec8-470b-4eff-93bb-c24f83b8b1fd")
|
||||||
.RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
.WithStatusCode("201")
|
.WithStatusCode("201")
|
||||||
.WithHeader("hk", "hv")
|
.WithHeader("hk", "hv")
|
||||||
@@ -31,7 +69,7 @@ server
|
|||||||
.UsingMethod("DELETE")
|
.UsingMethod("DELETE")
|
||||||
.WithUrl("https://localhost/test")
|
.WithUrl("https://localhost/test")
|
||||||
)
|
)
|
||||||
.WithGuid("f74fd144-df53-404f-8e35-da22a640bd5f")
|
.WithGuid("c9929240-7ae8-4a5d-8ed8-0913479f6eeb")
|
||||||
.RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
.WithStatusCode(208)
|
.WithStatusCode(208)
|
||||||
.WithBodyAsJson(new
|
.WithBodyAsJson(new
|
||||||
@@ -70,20 +108,3 @@ text
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
server
|
|
||||||
.Given(Request.Create()
|
|
||||||
.UsingMethod("POST")
|
|
||||||
.WithPath("/foo3")
|
|
||||||
.WithBody(new JsonPartialMatcher(
|
|
||||||
value: "{ a = 1, b = 2 }",
|
|
||||||
ignoreCase: false,
|
|
||||||
regex: false
|
|
||||||
))
|
|
||||||
)
|
|
||||||
.WithGuid("4126dec8-470b-4eff-93bb-c24f83b8b1fd")
|
|
||||||
.RespondWith(Response.Create()
|
|
||||||
.WithStatusCode(200)
|
|
||||||
.WithBody(@"Line1
|
|
||||||
Some ""value"" in Line2")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ public partial class WireMockAdminApiTests
|
|||||||
|
|
||||||
server.Stop();
|
server.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task IWireMockAdminApi_GetRequestsAsync_Json()
|
public async Task IWireMockAdminApi_GetRequestsAsync_Json()
|
||||||
{
|
{
|
||||||
@@ -862,8 +862,37 @@ public partial class WireMockAdminApiTests
|
|||||||
var guid2 = Guid.Parse("1b731398-4a5b-457f-a6e3-d65e541c428f");
|
var guid2 = Guid.Parse("1b731398-4a5b-457f-a6e3-d65e541c428f");
|
||||||
var guid3 = Guid.Parse("f74fd144-df53-404f-8e35-da22a640bd5f");
|
var guid3 = Guid.Parse("f74fd144-df53-404f-8e35-da22a640bd5f");
|
||||||
var guid4 = Guid.Parse("4126DEC8-470B-4EFF-93BB-C24F83B8B1FD");
|
var guid4 = Guid.Parse("4126DEC8-470B-4EFF-93BB-C24F83B8B1FD");
|
||||||
|
var guid5 = Guid.Parse("c9929240-7ae8-4a5d-8ed8-0913479f6eeb");
|
||||||
var server = WireMockServer.StartWithAdminInterface();
|
var server = WireMockServer.StartWithAdminInterface();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(
|
||||||
|
Request.Create()
|
||||||
|
.WithPath("/users/post1")
|
||||||
|
.UsingPost()
|
||||||
|
.WithBody(new JsonMatcher(new
|
||||||
|
{
|
||||||
|
city = "Amsterdam",
|
||||||
|
country = "The Netherlands"
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
.WithGuid(guid1)
|
||||||
|
.RespondWith(Response.Create());
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(
|
||||||
|
Request.Create()
|
||||||
|
.WithPath("/users/post2")
|
||||||
|
.UsingPost()
|
||||||
|
.WithBody(new JsonPartialMatcher(new
|
||||||
|
{
|
||||||
|
city = "City",
|
||||||
|
country = "Country"
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
.WithGuid(guid2)
|
||||||
|
.RespondWith(Response.Create().WithBody("Line1\r\nSome \"value\" in Line2"));
|
||||||
|
|
||||||
server
|
server
|
||||||
.Given(
|
.Given(
|
||||||
Request.Create()
|
Request.Create()
|
||||||
@@ -871,7 +900,7 @@ public partial class WireMockAdminApiTests
|
|||||||
.WithParam("p1", "xyz")
|
.WithParam("p1", "xyz")
|
||||||
.UsingGet()
|
.UsingGet()
|
||||||
)
|
)
|
||||||
.WithGuid(guid1)
|
.WithGuid(guid3)
|
||||||
.RespondWith(
|
.RespondWith(
|
||||||
Response.Create()
|
Response.Create()
|
||||||
.WithStatusCode(200)
|
.WithStatusCode(200)
|
||||||
@@ -886,7 +915,7 @@ public partial class WireMockAdminApiTests
|
|||||||
.WithHeader("h1", "W/\"234f2q3r\"")
|
.WithHeader("h1", "W/\"234f2q3r\"")
|
||||||
.UsingPost()
|
.UsingPost()
|
||||||
)
|
)
|
||||||
.WithGuid(guid2)
|
.WithGuid(guid4)
|
||||||
.RespondWith(
|
.RespondWith(
|
||||||
Response.Create()
|
Response.Create()
|
||||||
.WithStatusCode("201")
|
.WithStatusCode("201")
|
||||||
@@ -901,36 +930,43 @@ public partial class WireMockAdminApiTests
|
|||||||
.WithUrl("https://localhost/test")
|
.WithUrl("https://localhost/test")
|
||||||
.UsingDelete()
|
.UsingDelete()
|
||||||
)
|
)
|
||||||
.WithGuid(guid3)
|
.WithGuid(guid5)
|
||||||
.RespondWith(
|
.RespondWith(
|
||||||
Response.Create()
|
Response.Create()
|
||||||
.WithStatusCode(HttpStatusCode.AlreadyReported)
|
.WithStatusCode(HttpStatusCode.AlreadyReported)
|
||||||
.WithBodyAsJson(new { @as = 1, b = 1.2, d = true, e = false, f = new[] { 1, 2, 3, 4 }, g = new { z1 = 1, z2 = 2, z3 = new[] { "a", "b", "c" }, z4 = new[] { new { a = 1, b = 2 }, new { a = 2, b = 3 } } }, date_field = new DateTime(2023, 05, 08, 11, 20, 19), string_field_with_date = "2021-03-13T21:04:00Z", multiline_text = @"This
|
.WithBodyAsJson(new
|
||||||
|
{
|
||||||
|
@as = 1,
|
||||||
|
b = 1.2,
|
||||||
|
d = true,
|
||||||
|
e = false,
|
||||||
|
f = new[] { 1, 2, 3, 4 },
|
||||||
|
g = new
|
||||||
|
{
|
||||||
|
z1 = 1,
|
||||||
|
z2 = 2,
|
||||||
|
z3 = new[] { "a", "b", "c" },
|
||||||
|
z4 = new[]
|
||||||
|
{
|
||||||
|
new { a = 1, b = 2 },
|
||||||
|
new { a = 2, b = 3 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
date_field = new DateTime(2023, 05, 08, 11, 20, 19),
|
||||||
|
string_field_with_date = "2021-03-13T21:04:00Z",
|
||||||
|
multiline_text = @"This
|
||||||
is
|
is
|
||||||
multiline
|
multiline
|
||||||
text
|
text
|
||||||
" })
|
"
|
||||||
);
|
})
|
||||||
|
|
||||||
server
|
|
||||||
.Given(
|
|
||||||
Request.Create()
|
|
||||||
.WithPath("/foo3")
|
|
||||||
.WithBody(new JsonPartialMatcher(new { a = 1, b = 2 }))
|
|
||||||
.UsingPost()
|
|
||||||
)
|
|
||||||
.WithGuid(guid4)
|
|
||||||
.RespondWith(
|
|
||||||
Response.Create()
|
|
||||||
.WithStatusCode(200)
|
|
||||||
.WithBody("Line1\r\nSome \"value\" in Line2")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var api = RestClient.For<IWireMockAdminApi>(server.Url);
|
var api = RestClient.For<IWireMockAdminApi>(server.Url);
|
||||||
|
|
||||||
var mappings = await api.GetMappingsAsync().ConfigureAwait(false);
|
var mappings = await api.GetMappingsAsync().ConfigureAwait(false);
|
||||||
mappings.Should().HaveCount(4);
|
mappings.Should().HaveCount(5);
|
||||||
|
|
||||||
var code = await api.GetMappingsCodeAsync().ConfigureAwait(false);
|
var code = await api.GetMappingsCodeAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
|||||||
@@ -702,7 +702,11 @@ public class WireMockAssertionsTests : IDisposable
|
|||||||
// Act
|
// Act
|
||||||
var httpClient = new HttpClient();
|
var httpClient = new HttpClient();
|
||||||
|
|
||||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent(@"{ ""x"": ""y"" }"));
|
var requestBody = new
|
||||||
|
{
|
||||||
|
x = "y"
|
||||||
|
};
|
||||||
|
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
server
|
server
|
||||||
@@ -740,6 +744,103 @@ public class WireMockAssertionsTests : IDisposable
|
|||||||
server.Stop();
|
server.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WithBodyAsJson_When_NoMatch_ShouldHaveCorrectErrorMessage()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create().WithPath("/a").UsingPost())
|
||||||
|
.RespondWith(Response.Create().WithBody("A response"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
|
||||||
|
var requestBody = new
|
||||||
|
{
|
||||||
|
x = "123"
|
||||||
|
};
|
||||||
|
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Action act = () => server
|
||||||
|
.Should()
|
||||||
|
.HaveReceived(1)
|
||||||
|
.Calls()
|
||||||
|
.WithBodyAsJson(new { x = "y" })
|
||||||
|
.And
|
||||||
|
.UsingPost();
|
||||||
|
|
||||||
|
act.Should()
|
||||||
|
.Throw<Exception>()
|
||||||
|
.WithMessage("""Expected wiremockserver to have been called using body "{"x":"y"}", but didn't find it among the body/bodies "{"x":"123"}".""");
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WithBodyAsString_When_NoMatch_ShouldHaveCorrectErrorMessage()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create().WithPath("/a").UsingPost())
|
||||||
|
.RespondWith(Response.Create().WithBody("A response"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
|
||||||
|
await httpClient.PostAsync($"{server.Url}/a", new StringContent("123"));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Action act = () => server
|
||||||
|
.Should()
|
||||||
|
.HaveReceived(1)
|
||||||
|
.Calls()
|
||||||
|
.WithBody("abc")
|
||||||
|
.And
|
||||||
|
.UsingPost();
|
||||||
|
|
||||||
|
act.Should()
|
||||||
|
.Throw<Exception>()
|
||||||
|
.WithMessage("""Expected wiremockserver to have been called using body "abc", but didn't find it among the body/bodies "123".""");
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WithBodyAsBytes_When_NoMatch_ShouldHaveCorrectErrorMessage()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create().WithPath("/a").UsingPost())
|
||||||
|
.RespondWith(Response.Create().WithBody("A response"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
|
||||||
|
await httpClient.PostAsync($"{server.Url}/a", new ByteArrayContent(new byte[] { 5 }));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Action act = () => server
|
||||||
|
.Should()
|
||||||
|
.HaveReceived(1)
|
||||||
|
.Calls()
|
||||||
|
.WithBodyAsBytes(new byte[] { 1 })
|
||||||
|
.And
|
||||||
|
.UsingPost();
|
||||||
|
|
||||||
|
act.Should()
|
||||||
|
.Throw<Exception>()
|
||||||
|
.WithMessage("""Expected wiremockserver to have been called using body "byte[1] {...}", but didn't find it among the body/bodies "byte[1] {...}".""");
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task HaveReceived1Call_WithBodyAsBytes()
|
public async Task HaveReceived1Call_WithBodyAsBytes()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using NFluent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using NFluent;
|
||||||
using WireMock.Http;
|
using WireMock.Http;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
|
|||||||
@@ -31,5 +31,35 @@
|
|||||||
BodyDestination: SameAsSource,
|
BodyDestination: SameAsSource,
|
||||||
Body: { msg: "Hello world!"}
|
Body: { msg: "Hello world!"}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Guid: Guid_2,
|
||||||
|
UpdatedAt: 2023-01-14 15:16:17,
|
||||||
|
Request: {
|
||||||
|
Path: {
|
||||||
|
Matchers: [
|
||||||
|
{
|
||||||
|
Name: WildcardMatcher,
|
||||||
|
Pattern: /users/post2,
|
||||||
|
IgnoreCase: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
Methods: [
|
||||||
|
POST
|
||||||
|
],
|
||||||
|
Body: {
|
||||||
|
Matcher: {
|
||||||
|
Name: JsonMatcher,
|
||||||
|
Pattern: {
|
||||||
|
city: Amsterdam,
|
||||||
|
country: The Netherlands
|
||||||
|
},
|
||||||
|
IgnoreCase: false,
|
||||||
|
Regex: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Response: {}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
var builder = new MappingBuilder();
|
||||||
|
builder
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("GET")
|
||||||
|
.WithPath("/foo")
|
||||||
|
.WithParam("test", "it.Length < 10")
|
||||||
|
)
|
||||||
|
.WithGuid("41372914-1838-4c67-916b-b9aacdd096ce")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithBody("{ msg: \"Hello world!\"}")
|
||||||
|
);
|
||||||
|
|
||||||
|
builder
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("POST")
|
||||||
|
.WithPath("/users/post2")
|
||||||
|
.WithBody(new JsonMatcher(
|
||||||
|
value: new
|
||||||
|
{
|
||||||
|
city = "Amsterdam",
|
||||||
|
country = "The Netherlands"
|
||||||
|
},
|
||||||
|
ignoreCase: false,
|
||||||
|
regex: false
|
||||||
|
))
|
||||||
|
)
|
||||||
|
.WithGuid("98fae52e-76df-47d9-876f-2ee32e931d9b")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
);
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
var server = WireMockServer.Start();
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("GET")
|
||||||
|
.WithPath("/foo")
|
||||||
|
.WithParam("test", "it.Length < 10")
|
||||||
|
)
|
||||||
|
.WithGuid("41372914-1838-4c67-916b-b9aacdd096ce")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithBody("{ msg: \"Hello world!\"}")
|
||||||
|
);
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.UsingMethod("POST")
|
||||||
|
.WithPath("/users/post2")
|
||||||
|
.WithBody(new JsonMatcher(
|
||||||
|
value: new
|
||||||
|
{
|
||||||
|
city = "Amsterdam",
|
||||||
|
country = "The Netherlands"
|
||||||
|
},
|
||||||
|
ignoreCase: false,
|
||||||
|
regex: false
|
||||||
|
))
|
||||||
|
)
|
||||||
|
.WithGuid("98fae52e-76df-47d9-876f-2ee32e931d9b")
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
);
|
||||||
|
|
||||||
@@ -31,5 +31,34 @@
|
|||||||
BodyDestination: SameAsSource,
|
BodyDestination: SameAsSource,
|
||||||
Body: { msg: "Hello world!"}
|
Body: { msg: "Hello world!"}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Guid: Guid_2,
|
||||||
|
UpdatedAt: 2023-01-14T15:16:17,
|
||||||
|
Request: {
|
||||||
|
Path: {
|
||||||
|
Matchers: [
|
||||||
|
{
|
||||||
|
Name: WildcardMatcher,
|
||||||
|
Pattern: /users/post2,
|
||||||
|
IgnoreCase: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
Methods: [
|
||||||
|
POST
|
||||||
|
],
|
||||||
|
Body: {
|
||||||
|
Matcher: {
|
||||||
|
Name: JsonMatcher,
|
||||||
|
Pattern: {
|
||||||
|
city: Amsterdam,
|
||||||
|
country: The Netherlands
|
||||||
|
},
|
||||||
|
IgnoreCase: false,
|
||||||
|
Regex: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -13,6 +13,7 @@ using WireMock.RequestBuilders;
|
|||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Serialization;
|
using WireMock.Serialization;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -73,6 +74,25 @@ public class MappingBuilderTests
|
|||||||
.RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
.WithBody(@"{ msg: ""Hello world!""}")
|
.WithBody(@"{ msg: ""Hello world!""}")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_sut.Given(Request.Create()
|
||||||
|
.WithPath("/users/post1")
|
||||||
|
.UsingPost()
|
||||||
|
.WithBodyAsJson(new
|
||||||
|
{
|
||||||
|
Request = "Hello?"
|
||||||
|
})
|
||||||
|
).RespondWith(Response.Create());
|
||||||
|
|
||||||
|
_sut.Given(Request.Create()
|
||||||
|
.WithPath("/users/post2")
|
||||||
|
.UsingPost()
|
||||||
|
.WithBody(new JsonMatcher(new
|
||||||
|
{
|
||||||
|
city = "Amsterdam",
|
||||||
|
country = "The Netherlands"
|
||||||
|
}))
|
||||||
|
).RespondWith(Response.Create());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -95,6 +115,26 @@ public class MappingBuilderTests
|
|||||||
return Verifier.VerifyJson(json, VerifySettings);
|
return Verifier.VerifyJson(json, VerifySettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task ToCSharpCode_Server()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var code = _sut.ToCSharpCode(MappingConverterType.Server);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
return Verifier.Verify(code, VerifySettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task ToCSharpCode_Builder()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var code = _sut.ToCSharpCode(MappingConverterType.Builder);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
return Verifier.Verify(code, VerifySettings);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SaveMappingsToFile_FolderExists_IsFalse()
|
public void SaveMappingsToFile_FolderExists_IsFalse()
|
||||||
{
|
{
|
||||||
@@ -141,9 +181,9 @@ public class MappingBuilderTests
|
|||||||
_sut.SaveMappingsToFolder(null);
|
_sut.SaveMappingsToFolder(null);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Once);
|
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Exactly(2));
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(mappingFolder), Times.Once);
|
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(mappingFolder), Times.Exactly(2));
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
|
||||||
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,8 +199,8 @@ public class MappingBuilderTests
|
|||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Never);
|
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Never);
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(path), Times.Once);
|
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(path), Times.Exactly(2));
|
||||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
|
||||||
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class JsonMatcherTests
|
|||||||
var matcher = new JsonMatcher("{}");
|
var matcher = new JsonMatcher("{}");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
string name = matcher.Name;
|
var name = matcher.Name;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(name).Equals("JsonMatcher");
|
Check.That(name).Equals("JsonMatcher");
|
||||||
@@ -53,7 +53,7 @@ public class JsonMatcherTests
|
|||||||
var matcher = new JsonMatcher("{}");
|
var matcher = new JsonMatcher("{}");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
object value = matcher.Value;
|
var value = matcher.Value;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(value).Equals("{}");
|
Check.That(value).Equals("{}");
|
||||||
@@ -90,7 +90,7 @@ public class JsonMatcherTests
|
|||||||
// Act
|
// Act
|
||||||
var result = matcher.IsMatch(new MemoryStream());
|
var result = matcher.IsMatch(new MemoryStream());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
result.Score.Should().Be(MatchScores.Mismatch);
|
result.Score.Should().Be(MatchScores.Mismatch);
|
||||||
result.Exception.Should().BeAssignableTo<JsonException>();
|
result.Exception.Should().BeAssignableTo<JsonException>();
|
||||||
}
|
}
|
||||||
@@ -102,10 +102,10 @@ public class JsonMatcherTests
|
|||||||
var bytes = EmptyArray<byte>.Value;
|
var bytes = EmptyArray<byte>.Value;
|
||||||
var matcher = new JsonMatcher("");
|
var matcher = new JsonMatcher("");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
double match = matcher.IsMatch(bytes).Score;
|
var match = matcher.IsMatch(bytes).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(match).IsEqualTo(0);
|
Check.That(match).IsEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +116,10 @@ public class JsonMatcherTests
|
|||||||
string? s = null;
|
string? s = null;
|
||||||
var matcher = new JsonMatcher("");
|
var matcher = new JsonMatcher("");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
double match = matcher.IsMatch(s).Score;
|
var match = matcher.IsMatch(s).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(match).IsEqualTo(0);
|
Check.That(match).IsEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,215 +130,399 @@ public class JsonMatcherTests
|
|||||||
object? o = null;
|
object? o = null;
|
||||||
var matcher = new JsonMatcher("");
|
var matcher = new JsonMatcher("");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
double match = matcher.IsMatch(o).Score;
|
var match = matcher.IsMatch(o).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(match).IsEqualTo(0);
|
Check.That(match).IsEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JArray()
|
public void JsonMatcher_IsMatch_JArray()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new[] { "x", "y" });
|
var matcher = new JsonMatcher(new[] { "x", "y" });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jArray = new JArray
|
var jArray = new JArray
|
||||||
{
|
{
|
||||||
"x",
|
"x",
|
||||||
"y"
|
"y"
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jArray).Score;
|
var match = matcher.IsMatch(jArray).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JObject()
|
public void JsonMatcher_IsMatch_JObject_ShouldMatch()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });
|
var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "Id", new JValue(1) },
|
{ "Id", new JValue(1) },
|
||||||
{ "Name", new JValue("Test") }
|
{ "Name", new JValue("Test") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_JObject_ShouldNotMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(1) },
|
||||||
|
{ "Name", new JValue("Test") },
|
||||||
|
{ "Other", new JValue("abc") }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(MatchScores.Mismatch, score);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObject()
|
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObject()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new { id = 1, Name = "test" }, true);
|
var matcher = new JsonMatcher(new { id = 1, Name = "test" }, true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "Id", new JValue(1) },
|
{ "Id", new JValue(1) },
|
||||||
{ "NaMe", new JValue("Test") }
|
{ "NaMe", new JValue("Test") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JObjectParsed()
|
public void JsonMatcher_IsMatch_JObjectParsed()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });
|
var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
var jObject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObjectParsed()
|
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObjectParsed()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new { Id = 1, Name = "TESt" }, true);
|
var matcher = new JsonMatcher(new { Id = 1, Name = "TESt" }, true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
var jObject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JArrayAsString()
|
public void JsonMatcher_IsMatch_JArrayAsString()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher("[ \"x\", \"y\" ]");
|
var matcher = new JsonMatcher("[ \"x\", \"y\" ]");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jArray = new JArray
|
var jArray = new JArray
|
||||||
{
|
{
|
||||||
"x",
|
"x",
|
||||||
"y"
|
"y"
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jArray).Score;
|
var match = matcher.IsMatch(jArray).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JObjectAsString()
|
public void JsonMatcher_IsMatch_JObjectAsString()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "Id", new JValue(1) },
|
{ "Id", new JValue(1) },
|
||||||
{ "Name", new JValue("Test") }
|
{ "Name", new JValue("Test") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObjectAsString()
|
public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObjectAsString()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"test\" }", true);
|
var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"test\" }", true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "Id", new JValue(1) },
|
{ "Id", new JValue(1) },
|
||||||
{ "Name", new JValue("Test") }
|
{ "Name", new JValue("Test") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JObjectAsString_RejectOnMatch()
|
public void JsonMatcher_IsMatch_JObjectAsString_RejectOnMatch()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(MatchBehaviour.RejectOnMatch, "{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
var matcher = new JsonMatcher(MatchBehaviour.RejectOnMatch, "{ \"Id\" : 1, \"Name\" : \"Test\" }");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "Id", new JValue(1) },
|
{ "Id", new JValue(1) },
|
||||||
{ "Name", new JValue("Test") }
|
{ "Name", new JValue("Test") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(0.0, match);
|
Assert.Equal(0.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_JObjectWithDateTimeOffsetAsString()
|
public void JsonMatcher_IsMatch_JObjectWithDateTimeOffsetAsString()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher("{ \"preferredAt\" : \"2019-11-21T10:32:53.2210009+00:00\" }");
|
var matcher = new JsonMatcher("{ \"preferredAt\" : \"2019-11-21T10:32:53.2210009+00:00\" }");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "preferredAt", new JValue("2019-11-21T10:32:53.2210009+00:00") }
|
{ "preferredAt", new JValue("2019-11-21T10:32:53.2210009+00:00") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1.0, match);
|
Assert.Equal(1.0, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_NormalEnum()
|
public void JsonMatcher_IsMatch_NormalEnum()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new Test1 { NormalEnum = NormalEnum.Abc});
|
var matcher = new JsonMatcher(new Test1 { NormalEnum = NormalEnum.Abc });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "NormalEnum", new JValue(0) }
|
{ "NormalEnum", new JValue(0) }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
match.Should().Be(1.0);
|
match.Should().Be(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonMatcher_IsMatch_EnumWithJsonConverter()
|
public void JsonMatcher_IsMatch_EnumWithJsonConverter()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var matcher = new JsonMatcher(new Test2 { EnumWithJsonConverter = EnumWithJsonConverter.Type1 });
|
var matcher = new JsonMatcher(new Test2 { EnumWithJsonConverter = EnumWithJsonConverter.Type1 });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jObject = new JObject
|
var jObject = new JObject
|
||||||
{
|
{
|
||||||
{ "EnumWithJsonConverter", new JValue("Type1") }
|
{ "EnumWithJsonConverter", new JValue("Type1") }
|
||||||
};
|
};
|
||||||
double match = matcher.IsMatch(jObject).Score;
|
var match = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
match.Should().Be(1.0);
|
match.Should().Be(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_WithRegexTrue_ShouldMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new { Id = "^\\d+$", Name = "Test" }, regex: true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(42) },
|
||||||
|
{ "Name", new JValue("Test") }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(1.0, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_WithRegexTrue_Complex_ShouldMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new
|
||||||
|
{
|
||||||
|
Complex = new
|
||||||
|
{
|
||||||
|
Id = "^\\d+$",
|
||||||
|
Name = ".*"
|
||||||
|
}
|
||||||
|
}, regex: true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"Complex", new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(42) },
|
||||||
|
{ "Name", new JValue("Test") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(1.0, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_WithRegexTrue_Complex_ShouldNotMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new
|
||||||
|
{
|
||||||
|
Complex = new
|
||||||
|
{
|
||||||
|
Id = "^\\d+$",
|
||||||
|
Name = ".*"
|
||||||
|
}
|
||||||
|
}, regex: true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"Complex", new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(42) },
|
||||||
|
{ "Name", new JValue("Test") },
|
||||||
|
{ "Other", new JValue("Other") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(MatchScores.Mismatch, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_WithRegexTrue_Array_ShouldMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new
|
||||||
|
{
|
||||||
|
Array = new[]
|
||||||
|
{
|
||||||
|
"^\\d+$",
|
||||||
|
".*"
|
||||||
|
}
|
||||||
|
}, regex: true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Array", new JArray("42", "test") }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(1.0, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_WithRegexTrue_Array_ShouldNotMatch()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var matcher = new JsonMatcher(new
|
||||||
|
{
|
||||||
|
Array = new[]
|
||||||
|
{
|
||||||
|
"^\\d+$",
|
||||||
|
".*"
|
||||||
|
}
|
||||||
|
}, regex: true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Array", new JArray("42", "test", "other") }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(MatchScores.Mismatch, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_GuidAndString()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
var idAsString = id.ToString();
|
||||||
|
var matcher = new JsonMatcher(new { Id = id });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(idAsString) }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(1.0, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonMatcher_IsMatch_StringAndGuid()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
var idAsString = id.ToString();
|
||||||
|
var matcher = new JsonMatcher(new { Id = idAsString });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var jObject = new JObject
|
||||||
|
{
|
||||||
|
{ "Id", new JValue(id) }
|
||||||
|
};
|
||||||
|
var score = matcher.IsMatch(jObject).Score;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(1.0, score);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace WireMock.Net.Tests.Owin;
|
|||||||
public class HostUrlOptionsTests
|
public class HostUrlOptionsTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetDetails_WithNoUrlsAndHttpScheme_ShouldReturnCorrectDetails()
|
public void GetDetails_WithHostingSchemeHttpAndPort_ShouldReturnCorrectDetails()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var options = new HostUrlOptions
|
var options = new HostUrlOptions
|
||||||
@@ -28,14 +28,14 @@ public class HostUrlOptionsTests
|
|||||||
var detail = details.Single();
|
var detail = details.Single();
|
||||||
detail.Should().Match<HostUrlDetails>(d =>
|
detail.Should().Match<HostUrlDetails>(d =>
|
||||||
d.Scheme == "http" &&
|
d.Scheme == "http" &&
|
||||||
d.Host == "localhost" &&
|
d.Host == "*" &&
|
||||||
d.Port == 8080 &&
|
d.Port == 8080 &&
|
||||||
d.IsHttps == false
|
d.IsHttps == false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetDetails_WithNoUrlsAndHttpsScheme_ShouldReturnCorrectDetails()
|
public void GetDetails_WithHostingSchemeHttpsAndPort_ShouldReturnCorrectDetails()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var options = new HostUrlOptions
|
var options = new HostUrlOptions
|
||||||
@@ -52,7 +52,7 @@ public class HostUrlOptionsTests
|
|||||||
var detail = details.Single();
|
var detail = details.Single();
|
||||||
detail.Should().Match<HostUrlDetails>(d =>
|
detail.Should().Match<HostUrlDetails>(d =>
|
||||||
d.Scheme == "https" &&
|
d.Scheme == "https" &&
|
||||||
d.Host == "localhost" &&
|
d.Host == "*" &&
|
||||||
d.Port == 8081 &&
|
d.Port == 8081 &&
|
||||||
d.IsHttps == true
|
d.IsHttps == true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ using FluentAssertions;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JsonConverter.Abstractions;
|
|
||||||
using Moq;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
@@ -293,7 +291,7 @@ public class RequestBuilderWithBodyTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Request_WithBodyAsJson_Object_JsonPathMatcher_true()
|
public void Request_WithBody_Object_JsonPathMatcher_true()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..things[?(@.name == 'RequiredThing')]"));
|
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..things[?(@.name == 'RequiredThing')]"));
|
||||||
@@ -316,7 +314,7 @@ public class RequestBuilderWithBodyTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Request_WithBodyAsJson_Array_JsonPathMatcher_1()
|
public void Request_WithBody_Array_JsonPathMatcher_1()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..books[?(@.price < 10)]"));
|
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..books[?(@.price < 10)]"));
|
||||||
@@ -339,7 +337,7 @@ public class RequestBuilderWithBodyTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Request_WithBodyAsJson_Array_JsonPathMatcher_2()
|
public void Request_WithBody_Array_JsonPathMatcher_2()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..[?(@.Id == 1)]"));
|
var spec = Request.Create().UsingAnyMethod().WithBody(new JsonPathMatcher("$..[?(@.Id == 1)]"));
|
||||||
@@ -363,7 +361,7 @@ public class RequestBuilderWithBodyTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Request_WithBodyAsObject_ExactObjectMatcher_true()
|
public void Request_WithBody_ExactObjectMatcher_true()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
object body = DateTime.MinValue;
|
object body = DateTime.MinValue;
|
||||||
@@ -384,7 +382,7 @@ public class RequestBuilderWithBodyTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Request_WithBodyAsJson_UsingObject()
|
public void Request_WithBodyAsJson_UsingObject_UsesJsonMatcher()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
object body = new
|
object body = new
|
||||||
@@ -395,34 +393,8 @@ public class RequestBuilderWithBodyTests
|
|||||||
|
|
||||||
var bodyData = new BodyData
|
var bodyData = new BodyData
|
||||||
{
|
{
|
||||||
BodyAsString = JsonConvert.SerializeObject(body),
|
BodyAsJson = body,
|
||||||
DetectedBodyType = BodyType.String
|
DetectedBodyType = BodyType.Json
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, bodyData);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var requestMatchResult = new RequestMatchResult();
|
|
||||||
Check.That(requestBuilder.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void Request_WithBodyAsJson_WithIJsonConverter_UsingObject()
|
|
||||||
{
|
|
||||||
// Assign
|
|
||||||
var jsonConverterMock = new Mock<IJsonConverter>();
|
|
||||||
jsonConverterMock.Setup(j => j.Serialize(It.IsAny<object>(), It.IsAny<JsonConverterOptions>())).Returns("test");
|
|
||||||
object body = new
|
|
||||||
{
|
|
||||||
Any = "key"
|
|
||||||
};
|
|
||||||
var requestBuilder = Request.Create().UsingAnyMethod().WithBodyAsJson(body, jsonConverterMock.Object);
|
|
||||||
|
|
||||||
var bodyData = new BodyData
|
|
||||||
{
|
|
||||||
BodyAsString = "test",
|
|
||||||
DetectedBodyType = BodyType.String
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -354,7 +355,7 @@ public class ResponseWithHandlebarsJsonPathTests
|
|||||||
public async Task Response_ProvideResponse_Transformer_WithBodyAsFile_JsonPath()
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsFile_JsonPath()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string jsonString = "{ \"MyUniqueNumber\": \"1\" }";
|
const string jsonString = "{ \"MyUniqueNumber\": \"1\" }";
|
||||||
var bodyData = new BodyData
|
var bodyData = new BodyData
|
||||||
{
|
{
|
||||||
BodyAsString = jsonString,
|
BodyAsString = jsonString,
|
||||||
@@ -365,15 +366,17 @@ public class ResponseWithHandlebarsJsonPathTests
|
|||||||
};
|
};
|
||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, bodyData);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, bodyData);
|
||||||
|
|
||||||
string jsonPath = "\"$.MyUniqueNumber\"";
|
|
||||||
var responseBuilder = Response.Create()
|
var responseBuilder = Response.Create()
|
||||||
.WithTransformer()
|
.WithTransformer()
|
||||||
.WithBodyFromFile(@"c:\\{{JsonPath.SelectToken request.body " + jsonPath + "}}\\test.json"); // why use a \\ here ?
|
|
||||||
|
// We need to use `c:\\\\` here because when just using `c:\\\`, the `\\` it will be interpreted as an escape character to skip / exclude / escape the whole {{}} expression.
|
||||||
|
// See https://handlebarsjs.com/guide/expressions.html#escaping-handlebars-expressions
|
||||||
|
.WithBodyFromFile("c:\\\\{{JsonPath.SelectToken request.body \"$.MyUniqueNumber\" }}\\test.json");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
|
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(response.Message.BodyData.BodyAsFile).Equals(@"c:\1\test.json");
|
response.Message.BodyData?.BodyAsFile.Should().Be(@"c:\1\test.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
Pattern: {
|
Pattern: {
|
||||||
name: stef
|
name: stef
|
||||||
},
|
},
|
||||||
IgnoreCase: false
|
IgnoreCase: false,
|
||||||
|
Regex: false
|
||||||
},
|
},
|
||||||
ProtoBufMessageType: greet.HelloRequest
|
ProtoBufMessageType: greet.HelloRequest
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ message HelloReply {
|
|||||||
Pattern: {
|
Pattern: {
|
||||||
name: stef
|
name: stef
|
||||||
},
|
},
|
||||||
IgnoreCase: false
|
IgnoreCase: false,
|
||||||
|
Regex: false
|
||||||
},
|
},
|
||||||
ProtoBufMessageType: greet.HelloRequest
|
ProtoBufMessageType: greet.HelloRequest
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -499,4 +499,24 @@ public class WireMockServerAdminTests
|
|||||||
Check.That(response.StatusCode).Equals(HttpStatusCode.OK);
|
Check.That(response.StatusCode).Equals(HttpStatusCode.OK);
|
||||||
Check.That(await response.Content.ReadAsStringAsync().ConfigureAwait(false)).Equals($"{{\"Status\":\"Mappings deleted. Affected GUIDs: [{guid1}, {guid2}]\"}}");
|
Check.That(await response.Content.ReadAsStringAsync().ConfigureAwait(false)).Equals($"{{\"Status\":\"Mappings deleted. Affected GUIDs: [{guid1}, {guid2}]\"}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Admin_()
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server.CreateClient();
|
||||||
|
|
||||||
|
// when
|
||||||
|
await new HttpClient().GetAsync("http://localhost:" + server.Ports[0] + "/foo").ConfigureAwait(false);
|
||||||
|
|
||||||
|
// then
|
||||||
|
Check.That(server.LogEntries).HasSize(1);
|
||||||
|
var requestLogged = server.LogEntries.First();
|
||||||
|
Check.That(requestLogged.RequestMessage.Method).IsEqualTo("GET");
|
||||||
|
Check.That(requestLogged.RequestMessage.BodyData).IsNull();
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user