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