Add WireMock.Net.WebApplication example (#75)

This commit is contained in:
Stef Heyenrath
2018-01-11 19:38:58 +01:00
committed by GitHub
parent da798a59aa
commit 51bd9ec186
19 changed files with 369 additions and 82 deletions

View File

@@ -132,13 +132,13 @@ namespace WireMock.Server
#region Proxy and Record
private HttpClient _httpClientForProxy;
private void InitProxyAndRecord(ProxyAndRecordSettings settings)
private void InitProxyAndRecord(IProxyAndRecordSettings settings)
{
_httpClientForProxy = HttpClientHelper.CreateHttpClient(settings.X509Certificate2ThumbprintOrSubjectName);
Given(Request.Create().WithPath("/*").UsingAnyVerb()).RespondWith(new ProxyAsyncResponseProvider(ProxyAndRecordAsync, settings));
}
private async Task<ResponseMessage> ProxyAndRecordAsync(RequestMessage requestMessage, ProxyAndRecordSettings settings)
private async Task<ResponseMessage> ProxyAndRecordAsync(RequestMessage requestMessage, IProxyAndRecordSettings settings)
{
var requestUri = new Uri(requestMessage.Url);
var proxyUri = new Uri(settings.Url);

View File

@@ -25,12 +25,15 @@ namespace WireMock.Server
private readonly IOwinSelfHost _httpServer;
private readonly WireMockMiddlewareOptions _options = new WireMockMiddlewareOptions();
/// <summary>
/// Gets a value indicating whether this server is started.
/// </summary>
[PublicAPI]
public bool IsStarted { get; }
/// <summary>
/// Gets the ports.
/// </summary>
/// <value>
/// The ports.
/// </value>
[PublicAPI]
public List<int> Ports { get; }
@@ -59,7 +62,7 @@ namespace WireMock.Server
/// <param name="settings">The FluentMockServerSettings.</param>
/// <returns>The <see cref="FluentMockServer"/>.</returns>
[PublicAPI]
public static FluentMockServer Start(FluentMockServerSettings settings)
public static FluentMockServer Start(IFluentMockServerSettings settings)
{
Check.NotNull(settings, nameof(settings));
@@ -150,7 +153,7 @@ namespace WireMock.Server
});
}
private FluentMockServer(FluentMockServerSettings settings)
private FluentMockServer(IFluentMockServerSettings settings)
{
if (settings.Urls != null)
{
@@ -170,6 +173,8 @@ namespace WireMock.Server
#else
_httpServer = new OwinSelfHost(_options, Urls);
#endif
IsStarted = _httpServer.IsStarted;
Ports = _httpServer.Ports;
_httpServer.StartAsync();