Skip to content

Commit

Permalink
Fixed issue #76 (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Jan 16, 2018
1 parent 51bd9ec commit 97d80ad
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/WireMock.Net/Client/IFluentMockServerAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public interface IFluentMockServerAdmin
/// </summary>
/// <param name="mapping">MappingModel</param>
[Post("__admin/mappings")]
[Header("Content-Type", "application/json")]
Task<string> PostMappingAsync([Body] MappingModel mapping);

/// <summary>
Expand Down Expand Up @@ -137,6 +138,7 @@ public interface IFluentMockServerAdmin
/// </summary>
/// <param name="model">The RequestModel</param>
[Post("__admin/requests/find")]
[Header("Content-Type", "application/json")]
Task<IList<LogEntryModel>> FindRequestsAsync([Body] RequestModel model);

/// <summary>
Expand Down
48 changes: 48 additions & 0 deletions test/WireMock.Net.Tests/ClientTests.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit 97d80ad

Please sign in to comment.