mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-24 01:08:28 +02:00
bug: Fix admin api client definition returning the wrong types (#65)
* bug: Fix admin api client definition returning the wrong types - IFluentMockServerAdmin get, find and get all requests should return a log entry model - Add tests for get and find using the rest ease api client * Fix Build status and rename tests
This commit is contained in:
committed by
Stef Heyenrath
parent
d39e9ef7fa
commit
208303729e
@@ -1,7 +1,7 @@
|
|||||||
# WireMock.Net
|
# WireMock.Net
|
||||||
A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) which mimics the functionality from the JAVA based http://WireMock.org
|
A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) which mimics the functionality from the JAVA based http://WireMock.org
|
||||||
|
|
||||||
[](https://ci.appveyor.com/project/WireMock-Net/wiremock-net)
|
[](https://ci.appveyor.com/project/StefH/wiremock-net)
|
||||||
[](https://codecov.io/gh/WireMock-Net/WireMock.Net)
|
[](https://codecov.io/gh/WireMock-Net/WireMock.Net)
|
||||||
[](https://coveralls.io/github/WireMock-Net/WireMock.Net?branch=master)
|
[](https://coveralls.io/github/WireMock-Net/WireMock.Net?branch=master)
|
||||||
[](https://github.com/WireMock-Net/WireMock.Net/issues)
|
[](https://github.com/WireMock-Net/WireMock.Net/issues)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Admin.Requests;
|
using WireMock.Admin.Requests;
|
||||||
using WireMock.Admin.Settings;
|
using WireMock.Admin.Settings;
|
||||||
|
using WireMock.Logging;
|
||||||
|
|
||||||
namespace WireMock.Client
|
namespace WireMock.Client
|
||||||
{
|
{
|
||||||
@@ -103,7 +104,7 @@ namespace WireMock.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>LogRequestModels</returns>
|
/// <returns>LogRequestModels</returns>
|
||||||
[Get("__admin/requests")]
|
[Get("__admin/requests")]
|
||||||
Task<IList<LogRequestModel>> GetRequestsAsync();
|
Task<IList<LogEntryModel>> GetRequestsAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete all requests.
|
/// Delete all requests.
|
||||||
@@ -123,7 +124,7 @@ namespace WireMock.Client
|
|||||||
/// <param name="guid">The Guid</param>
|
/// <param name="guid">The Guid</param>
|
||||||
/// <returns>MappingModel</returns>
|
/// <returns>MappingModel</returns>
|
||||||
[Get("__admin/requests/{guid}")]
|
[Get("__admin/requests/{guid}")]
|
||||||
Task<LogRequestModel> GetRequestAsync([Path] Guid guid);
|
Task<LogEntryModel> GetRequestAsync([Path] Guid guid);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a request based on the guid
|
/// Delete a request based on the guid
|
||||||
@@ -137,7 +138,7 @@ namespace WireMock.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The RequestModel</param>
|
/// <param name="model">The RequestModel</param>
|
||||||
[Post("__admin/requests/find")]
|
[Post("__admin/requests/find")]
|
||||||
Task<IList<LogRequestModel>> FindRequestsAsync([Body] RequestModel model);
|
Task<IList<LogEntryModel>> FindRequestsAsync([Body] RequestModel model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all scenarios
|
/// Get all scenarios
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ namespace WireMock.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = dict.OrderBy(x => x.Value.AverageTotalScore).Select(x => x.Key);
|
var result = dict.OrderBy(x => x.Value.AverageTotalScore).Select(x => x.Key).Select(ToLogEntryModel);
|
||||||
|
|
||||||
return ToJson(result);
|
return ToJson(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NFluent;
|
||||||
|
using RestEase;
|
||||||
|
using WireMock.Admin.Mappings;
|
||||||
|
using WireMock.Client;
|
||||||
|
using WireMock.Server;
|
||||||
|
using WireMock.Settings;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace WireMock.Net.Tests
|
||||||
|
{
|
||||||
|
public class FluentMockServerAdminRestClientTests : IDisposable
|
||||||
|
{
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_server?.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FluentMockServer _server;
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IFluentMockServerAdmin_FindRequestsAsync()
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
_server = FluentMockServer.Start(new FluentMockServerSettings { StartAdminInterface = true });
|
||||||
|
var serverUrl = "http://localhost:" + _server.Ports[0];
|
||||||
|
await new HttpClient().GetAsync(serverUrl + "/foo");
|
||||||
|
var api = RestClient.For<IFluentMockServerAdmin>(serverUrl);
|
||||||
|
|
||||||
|
// when
|
||||||
|
var requests = await api.FindRequestsAsync(new RequestModel { Methods = new[] { "get" } });
|
||||||
|
|
||||||
|
// then
|
||||||
|
Check.That(requests).HasSize(1);
|
||||||
|
var requestLogged = requests.First();
|
||||||
|
Check.That(requestLogged.Request.Method).IsEqualTo("get");
|
||||||
|
Check.That(requestLogged.Request.Body).IsNull();
|
||||||
|
Check.That(requestLogged.Request.Path).IsEqualTo("/foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IFluentMockServerAdmin_GetRequestsAsync()
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
_server = FluentMockServer.Start(new FluentMockServerSettings { StartAdminInterface = true });
|
||||||
|
var serverUrl = "http://localhost:" + _server.Ports[0];
|
||||||
|
await new HttpClient().GetAsync(serverUrl + "/foo");
|
||||||
|
var api = RestClient.For<IFluentMockServerAdmin>(serverUrl);
|
||||||
|
|
||||||
|
// when
|
||||||
|
var requests = await api.GetRequestsAsync();
|
||||||
|
|
||||||
|
// then
|
||||||
|
Check.That(requests).HasSize(1);
|
||||||
|
var requestLogged = requests.First();
|
||||||
|
Check.That(requestLogged.Request.Method).IsEqualTo("get");
|
||||||
|
Check.That(requestLogged.Request.Body).IsNull();
|
||||||
|
Check.That(requestLogged.Request.Path).IsEqualTo("/foo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user