mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 16:48:59 +01:00
Refactor (#208)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
||||
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
||||
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
|
||||
<UserSecretsId>efcf4a18-fd7c-4622-825d-336d65290599</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0'">
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace WireMock.Http
|
||||
// Call the URL
|
||||
var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
|
||||
|
||||
// Parse httpResponseMessage
|
||||
// Create ResponseMessage
|
||||
return await HttpResponseMessageHelper.Create(httpResponseMessage, requiredUri, originalUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace WireMock.HttpsCertificate
|
||||
@@ -26,6 +25,7 @@ namespace WireMock.HttpsCertificate
|
||||
throw new FileNotFoundException("No certificate found with specified Thumbprint or SubjectName.", thumbprintOrSubjectName);
|
||||
}
|
||||
}
|
||||
|
||||
// Use the first matching certificate.
|
||||
return matchingCertificates[0];
|
||||
}
|
||||
|
||||
@@ -65,6 +65,14 @@ namespace WireMock
|
||||
/// </summary>
|
||||
bool IsStartState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this mapping is an Admin Interface.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this mapping is an Admin Interface; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
bool IsAdminInterface { get; }
|
||||
|
||||
/// <summary>
|
||||
/// ResponseToAsync
|
||||
/// </summary>
|
||||
@@ -79,13 +87,5 @@ namespace WireMock
|
||||
/// <param name="nextState">The Next State.</param>
|
||||
/// <returns>The <see cref="RequestMatchResult"/>.</returns>
|
||||
RequestMatchResult GetRequestMatchResult(RequestMessage requestMessage, [CanBeNull] string nextState);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this mapping is an Admin Interface.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this mapping is an Admin Interface; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
bool IsAdminInterface { get; }
|
||||
}
|
||||
}
|
||||
@@ -14,55 +14,39 @@ namespace WireMock
|
||||
/// <inheritdoc cref="IMapping.Guid" />
|
||||
public Guid Guid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique title.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.Title" />
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The full filename path for this mapping (only defined for static mappings).
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.Path" />
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.Priority" />
|
||||
public int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Scenario.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.Scenario" />
|
||||
[CanBeNull]
|
||||
public string Scenario { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Execution state condition for the current mapping.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.ExecutionConditionState" />
|
||||
[CanBeNull]
|
||||
public string ExecutionConditionState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The next state which will be signaled after the current mapping execution.
|
||||
/// In case the value is null, state will not be changed.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.NextState" />
|
||||
[CanBeNull]
|
||||
public string NextState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Request matcher.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.RequestMatcher" />
|
||||
public IRequestMatcher RequestMatcher { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Provider.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.Provider" />
|
||||
public IResponseProvider Provider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is State started ?
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="IMapping.IsStartState" />
|
||||
public bool IsStartState => Scenario == null || Scenario != null && NextState != null && ExecutionConditionState == null;
|
||||
|
||||
/// <inheritdoc cref="IMapping.IsAdminInterface" />
|
||||
public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider || Provider is ProxyAsyncResponseProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Mapping"/> class.
|
||||
/// </summary>
|
||||
@@ -88,22 +72,13 @@ namespace WireMock
|
||||
NextState = nextState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The response to.
|
||||
/// </summary>
|
||||
/// <param name="requestMessage">The request message.</param>
|
||||
/// <returns>The <see cref="ResponseMessage"/>.</returns>
|
||||
/// <inheritdoc cref="IMapping.ResponseToAsync" />
|
||||
public async Task<ResponseMessage> ResponseToAsync(RequestMessage requestMessage)
|
||||
{
|
||||
return await Provider.ProvideResponseAsync(requestMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the RequestMatchResult based on the RequestMessage.
|
||||
/// </summary>
|
||||
/// <param name="requestMessage">The request message.</param>
|
||||
/// <param name="nextState">The Next State.</param>
|
||||
/// <returns>The <see cref="RequestMatchResult"/>.</returns>
|
||||
/// <inheritdoc cref="IMapping.GetRequestMatchResult" />
|
||||
public RequestMatchResult GetRequestMatchResult(RequestMessage requestMessage, [CanBeNull] string nextState)
|
||||
{
|
||||
var result = new RequestMatchResult();
|
||||
@@ -126,13 +101,5 @@ namespace WireMock
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this mapping is an Admin Interface.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this mapping is an Admin Interface; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider || Provider is ProxyAsyncResponseProvider;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user