Fixed issue #76 (#77)

#76
This commit is contained in:
Stef Heyenrath
2018-01-16 20:44:59 +01:00
committed by GitHub
parent 51bd9ec186
commit 97d80ada11
2 changed files with 50 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ namespace WireMock.Client
/// </summary>
/// <param name="mapping">MappingModel</param>
[Post("__admin/mappings")]
[Header("Content-Type", "application/json")]
Task<string> PostMappingAsync([Body] MappingModel mapping);
/// <summary>
@@ -137,6 +138,7 @@ namespace WireMock.Client
/// </summary>
/// <param name="model">The RequestModel</param>
[Post("__admin/requests/find")]
[Header("Content-Type", "application/json")]
Task<IList<LogEntryModel>> FindRequestsAsync([Body] RequestModel model);
/// <summary>

View File

@@ -0,0 +1,48 @@
using System.Linq;
using System.Threading.Tasks;
using NFluent;
using RestEase;
using WireMock.Admin.Mappings;
using WireMock.Client;
using WireMock.Server;
using Xunit;
namespace WireMock.Net.Tests
{
public class ClientTests
{
[Fact]
public async Task Client_IFluentMockServerAdmin_PostMappingAsync()
{
// Assign
var server = FluentMockServer.StartWithAdminInterface();
var api = RestClient.For<IFluentMockServerAdmin>(server.Urls[0]);
// Act
var model = new MappingModel
{
Request = new RequestModel
{
Path = "/1"
},
Response = new ResponseModel
{
Body = "txt",
StatusCode = 200
},
Priority = 500,
Title = "test"
};
string result = await api.PostMappingAsync(model);
// Assert
Check.That(result).IsNotNull();
var mapping = server.Mappings.Single(m => m.Priority == 500);
Check.That(mapping).IsNotNull();
Check.That(mapping.Title).Equals("test");
server.Stop();
}
}
}