mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-22 09:30:18 +01:00
Add WireMock.org RestClient (#631)
* wip... * x * . * . * . * r * 1.4.21-preview-02 * 1.4.21-preview-03 * . * usings * wip * . * ut * . * . * . * tests * . * comments * readme
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
@@ -51,7 +51,7 @@
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
<PackageReference Include="Moq" Version="4.16.0" />
|
||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||
<PackageReference Include="RestEase" Version="1.4.10" />
|
||||
<PackageReference Include="RestEase" Version="1.5.5" />
|
||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
@@ -72,6 +72,9 @@
|
||||
<None Update="responsebody.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="__admin\mappings.org\mapping1.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="__admin\mappings\00000002-ee28-4f29-ae63-1ac9b0802d86.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
31
test/WireMock.Net.Tests/WireMockServer.ImportWireMockOrg.cs
Normal file
31
test/WireMock.Net.Tests/WireMockServer.ImportWireMockOrg.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using WireMock.Server;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class WireMockServerImportWireMockOrgTests
|
||||
{
|
||||
// For for AppVeyor + OpenCover
|
||||
private string GetCurrentFolder()
|
||||
{
|
||||
return Directory.GetCurrentDirectory();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireMockServer_Admin_ReadStaticWireMockOrgMappingAndAddOrUpdate()
|
||||
{
|
||||
var server = WireMockServer.Start();
|
||||
string path = Path.Combine(GetCurrentFolder(), "__admin", "mappings.org", "mapping1.json");
|
||||
server.ReadStaticWireMockOrgMappingAndAddOrUpdate(path);
|
||||
|
||||
var mappings = server.Mappings.ToArray();
|
||||
|
||||
mappings.Should().HaveCount(1);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace WireMock.Net.Tests
|
||||
|
||||
// Assert
|
||||
var mappings = server.Mappings;
|
||||
Check.That(mappings.Count()).IsEqualTo(24);
|
||||
Check.That(mappings.Count()).IsEqualTo(25);
|
||||
Check.That(mappings.All(m => m.Priority == int.MinValue)).IsTrue();
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace WireMock.Net.Tests
|
||||
|
||||
// Assert
|
||||
var mappings = server.Mappings;
|
||||
Check.That(mappings.Count()).IsEqualTo(25);
|
||||
Check.That(mappings.Count(m => m.Priority == int.MinValue)).IsEqualTo(24);
|
||||
Check.That(mappings.Count()).IsEqualTo(26);
|
||||
Check.That(mappings.Count(m => m.Priority == int.MinValue)).IsEqualTo(25);
|
||||
Check.That(mappings.Count(m => m.Priority == 1000)).IsEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
38
test/WireMock.Net.Tests/__admin/mappings.org/mapping1.json
Normal file
38
test/WireMock.Net.Tests/__admin/mappings.org/mapping1.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"id": "ef53ea56-f118-4b3a-8c69-a9484851d99a",
|
||||
"name": "weatherforecast",
|
||||
"request": {
|
||||
"path": "/WeatherForecast/register-city",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"XXX": {
|
||||
"contains": "xml"
|
||||
}
|
||||
},
|
||||
"queryParameters": {
|
||||
"search_term": {
|
||||
"equalTo": "WireMock"
|
||||
}
|
||||
},
|
||||
"bodyPatterns": [
|
||||
{
|
||||
"equalToJson": {
|
||||
"cityName": "São Paulo",
|
||||
"cityCode": 5001
|
||||
},
|
||||
"ignoreArrayOrder": true,
|
||||
"ignoreExtraElements": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"body": "[{\"date\":\"2021-09-09T20:44:48.0992639-03:00\",\"temperatureC\":51,\"temperatureF\":123,\"summary\":\"Hot\"},{\"date\":\"2021-09-10T20:44:48.0992692-03:00\",\"temperatureC\":34,\"temperatureF\":93,\"summary\":\"Mild\"},{\"date\":\"2021-09-11T20:44:48.0992696-03:00\",\"temperatureC\":43,\"temperatureF\":109,\"summary\":\"Sweltering\"},{\"date\":\"2021-09-12T20:44:48.0992698-03:00\",\"temperatureC\":46,\"temperatureF\":114,\"summary\":\"Cool\"},{\"date\":\"2021-09-13T20:44:48.0992701-03:00\",\"temperatureC\":3,\"temperatureF\":37,\"summary\":\"Freezing\"}]",
|
||||
"headers": {
|
||||
"Content-Type": "application/json; charset=utf-8"
|
||||
}
|
||||
},
|
||||
"uuid": "ef53ea56-f118-4b3a-8c69-a9484851d99a",
|
||||
"persistent": true,
|
||||
"insertionIndex": 1
|
||||
}
|
||||
Reference in New Issue
Block a user