mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-07-13 08:12:45 +02:00
Added some RestEase interfaces
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26403.7
|
VisualStudioVersion = 15.0.26430.6
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF242EDF-7133-4277-9A0C-18744DE08707}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF242EDF-7133-4277-9A0C-18744DE08707}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -37,6 +37,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.NETCor
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Record.NETCoreApp", "examples\WireMock.Net.Console.Record.NETCoreApp\WireMock.Net.Console.Record.NETCoreApp.csproj", "{1995E414-F197-4AB4-90C2-68D806B5AF59}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Record.NETCoreApp", "examples\WireMock.Net.Console.Record.NETCoreApp\WireMock.Net.Console.Record.NETCoreApp.csproj", "{1995E414-F197-4AB4-90C2-68D806B5AF59}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Client", "src\WireMock.Net.Client\WireMock.Net.Client.csproj", "{058D4B6C-C03E-49D0-91DB-A535B058FA0D}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -71,6 +73,10 @@ Global
|
|||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -83,5 +89,6 @@ Global
|
|||||||
{14D7298C-2BE5-42C3-A3D5-9433E77218F9} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
{14D7298C-2BE5-42C3-A3D5-9433E77218F9} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{FE281639-B014-4C8A-96FA-141164A74713} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
||||||
|
{058D4B6C-C03E-49D0-91DB-A535B058FA0D} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using WireMock.Client;
|
||||||
|
|
||||||
|
namespace WireMock.Net.Client
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Create an implementation of the IFluentMockServerAdmin and pass in the base URL for the API.
|
||||||
|
var api = RestClient.For<IFluentMockServerAdmin>("http://localhost:9090");
|
||||||
|
|
||||||
|
// Set BASIC Auth
|
||||||
|
var value = Convert.ToBase64String(Encoding.ASCII.GetBytes("a:b"));
|
||||||
|
api.Authorization = new AuthenticationHeaderValue("Basic", value);
|
||||||
|
|
||||||
|
var settings1 = api.GetSettingsAsync().Result;
|
||||||
|
Console.WriteLine($"settings1 = {JsonConvert.SerializeObject(settings1)}");
|
||||||
|
|
||||||
|
settings1.GlobalProcessingDelay = 1077;
|
||||||
|
api.PostSettingsAsync(settings1).Wait();
|
||||||
|
|
||||||
|
var settings2 = api.GetSettingsAsync().Result;
|
||||||
|
Console.WriteLine($"settings2 = {JsonConvert.SerializeObject(settings2)}");
|
||||||
|
|
||||||
|
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)}");
|
||||||
|
|
||||||
|
Console.WriteLine("Press any key to quit");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
|
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
|
||||||
|
<PackageReference Include="RestEase" Version="1.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WireMock.Admin.Mappings;
|
||||||
|
using WireMock.Admin.Settings;
|
||||||
|
|
||||||
|
namespace WireMock.Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The RestEase interface which defines all admin commands.
|
||||||
|
/// </summary>
|
||||||
|
public interface IFluentMockServerAdmin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Authentication header
|
||||||
|
/// </summary>
|
||||||
|
[Header("Authorization")]
|
||||||
|
AuthenticationHeaderValue Authorization { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the settings.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>SettingsModel</returns>
|
||||||
|
[Get("__admin/settings")]
|
||||||
|
Task<SettingsModel> GetSettingsAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Post the settings
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settings">SettingsModel</param>
|
||||||
|
[Post("__admin/settings")]
|
||||||
|
Task PostSettingsAsync([Body] SettingsModel settings);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the mappings.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>MappingModels</returns>
|
||||||
|
[Get("__admin/mappings")]
|
||||||
|
Task<IList<MappingModel>> GetMappingsAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a mappings based on the guid
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="guid">The Guid</param>
|
||||||
|
/// <returns>MappingModel</returns>
|
||||||
|
[Get("__admin/mappings/{guid}")]
|
||||||
|
Task<MappingModel> GetMappingAsync([Path] Guid guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||||
<PackageReference Include="SimMetrics.Net" Version="1.0.3" />
|
<PackageReference Include="SimMetrics.Net" Version="1.0.3" />
|
||||||
<PackageReference Include="System.Net.Http" Version="4.3.2" />
|
<PackageReference Include="System.Net.Http" Version="4.3.2" />
|
||||||
|
<PackageReference Include="RestEase" Version="1.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
|
||||||
|
|||||||
Reference in New Issue
Block a user