From 85e51b62404a936cfff71b57213ce0a18e8e3c36 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Thu, 15 Jun 2017 11:05:03 +0200 Subject: [PATCH] IFluentMockServerAdmin : requests --- .../WireMock.Net.StandAlone.NETCoreApp.csproj | 3 +- src/WireMock.Net.Client/Program.cs | 21 +++++++++-- .../WireMock.Net.Client.csproj | 3 +- .../Client/IFluentMockServerAdmin.cs | 35 +++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj b/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj index 4053f066..a3d52cc2 100644 --- a/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj +++ b/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj @@ -2,7 +2,8 @@ Exe - netcoreapp1.1 + netcoreapp1.0 + 1.0.1 ../../WireMock.Net-Logo.ico diff --git a/src/WireMock.Net.Client/Program.cs b/src/WireMock.Net.Client/Program.cs index 93acddd2..09dbaedb 100644 --- a/src/WireMock.Net.Client/Program.cs +++ b/src/WireMock.Net.Client/Program.cs @@ -30,9 +30,24 @@ namespace WireMock.Net.Client var mappings = api.GetMappingsAsync().Result; Console.WriteLine($"mappings = {JsonConvert.SerializeObject(mappings)}"); - var guid = Guid.Parse("11111110-a633-40e8-a244-5cb80bc0ab66"); - var mapping = api.GetMappingAsync(guid).Result; - Console.WriteLine($"mapping = {JsonConvert.SerializeObject(mapping)}"); + try + { + var guid = Guid.Parse("11111110-a633-40e8-a244-5cb80bc0ab66"); + var mapping = api.GetMappingAsync(guid).Result; + Console.WriteLine($"mapping = {JsonConvert.SerializeObject(mapping)}"); + } + catch (Exception e) + { + } + + var request = api.GetRequestsAsync().Result; + Console.WriteLine($"request = {JsonConvert.SerializeObject(request)}"); + + string deleteRequestsAsync = api.DeleteRequestsAsync().Result; + Console.WriteLine($"deleteRequestsAsync = {deleteRequestsAsync}"); + + string resetRequestsAsync = api.ResetRequestsAsync().Result; + Console.WriteLine($"resetRequestsAsync = {resetRequestsAsync}"); Console.WriteLine("Press any key to quit"); Console.ReadKey(); diff --git a/src/WireMock.Net.Client/WireMock.Net.Client.csproj b/src/WireMock.Net.Client/WireMock.Net.Client.csproj index c5eba9a7..8f4721ec 100644 --- a/src/WireMock.Net.Client/WireMock.Net.Client.csproj +++ b/src/WireMock.Net.Client/WireMock.Net.Client.csproj @@ -2,7 +2,8 @@ Exe - netcoreapp1.1 + netcoreapp1.0 + 1.0.1 ../../WireMock.Net-Logo.ico diff --git a/src/WireMock.Net/Client/IFluentMockServerAdmin.cs b/src/WireMock.Net/Client/IFluentMockServerAdmin.cs index 17135896..4bfe56f8 100644 --- a/src/WireMock.Net/Client/IFluentMockServerAdmin.cs +++ b/src/WireMock.Net/Client/IFluentMockServerAdmin.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Net.Http.Headers; using System.Threading.Tasks; using WireMock.Admin.Mappings; +using WireMock.Admin.Requests; using WireMock.Admin.Settings; namespace WireMock.Client @@ -96,5 +97,39 @@ namespace WireMock.Client /// [Post("__admin/mappings/save")] Task SaveMappingAsync(); + + /// + /// Get the requests. + /// + /// LogRequestModels + [Get("__admin/requests")] + Task> GetRequestsAsync(); + + /// + /// Delete all requests. + /// + [Delete("__admin/requests")] + Task DeleteRequestsAsync(); + + /// + /// Delete (reset) all requests. + /// + [Post("__admin/requests/reset")] + Task ResetRequestsAsync(); + + /// + /// Get a request based on the guid + /// + /// The Guid + /// MappingModel + [Get("__admin/requests/{guid}")] + Task GetRequestAsync([Path] Guid guid); + + /// + /// Delete a request based on the guid + /// + /// The Guid + [Delete("__admin/requests/{guid}")] + Task DeleteRequestAsync([Path] Guid guid); } } \ No newline at end of file