Skip to content

Commit

Permalink
Remove interface for all Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Mar 9, 2022
1 parent 3087ce5 commit 42882c8
Show file tree
Hide file tree
Showing 34 changed files with 238 additions and 511 deletions.
6 changes: 3 additions & 3 deletions src/WireMock.Net.StandAlone/StandAloneApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public static class StandAloneApp
private static readonly string Version = typeof(StandAloneApp).GetTypeInfo().Assembly.GetName().Version.ToString();

/// <summary>
/// Start WireMock.Net standalone Server based on the IWireMockServerSettings.
/// Start WireMock.Net standalone Server based on the WireMockServerSettings.
/// </summary>
/// <param name="settings">The IWireMockServerSettings</param>
/// <param name="settings">The WireMockServerSettings</param>
[PublicAPI]
public static WireMockServer Start([NotNull] IWireMockServerSettings settings)
public static WireMockServer Start([NotNull] WireMockServerSettings settings)
{
Guard.NotNull(settings, nameof(settings));

Expand Down
2 changes: 1 addition & 1 deletion src/WireMock.Net/Http/HttpClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace WireMock.Http
{
internal static class HttpClientBuilder
{
public static HttpClient Build(IHttpClientSettings settings)
public static HttpClient Build(HttpClientSettings settings)
{
#if NETSTANDARD || NETCOREAPP3_1 || NET5_0 || NET6_0
var handler = new HttpClientHandler
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Http/WebhookSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ internal class WebhookSender
{
private const string ClientIp = "::1";

private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;

public WebhookSender(IWireMockServerSettings settings)
public WebhookSender(WireMockServerSettings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
}
Expand Down
6 changes: 3 additions & 3 deletions src/WireMock.Net/IMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public interface IMapping
/// <summary>
/// The WireMockServerSettings.
/// </summary>
IWireMockServerSettings Settings { get; }
WireMockServerSettings Settings { get; }

/// <summary>
/// Is State started ?
/// </summary>
Expand All @@ -90,7 +90,7 @@ public interface IMapping
/// <c>true</c> if this mapping is an Admin Interface; otherwise, <c>false</c>.
/// </value>
bool IsAdminInterface { get; }

/// <summary>
/// Gets a value indicating whether this mapping to be logged.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Mapping : IMapping
public IResponseProvider Provider { get; }

/// <inheritdoc />
public IWireMockServerSettings Settings { get; }
public WireMockServerSettings Settings { get; }

/// <inheritdoc />
public bool IsStartState => Scenario == null || Scenario != null && NextState != null && ExecutionConditionState == null;
Expand Down Expand Up @@ -81,7 +81,7 @@ public Mapping(
Guid guid,
[CanBeNull] string title,
[CanBeNull] string path,
[NotNull] IWireMockServerSettings settings,
[NotNull] WireMockServerSettings settings,
[NotNull] IRequestMatcher requestMatcher,
[NotNull] IResponseProvider provider,
int priority,
Expand Down
8 changes: 4 additions & 4 deletions src/WireMock.Net/Proxy/ProxyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace WireMock.Proxy
{
internal class ProxyHelper
{
private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;

public ProxyHelper([NotNull] IWireMockServerSettings settings)
public ProxyHelper([NotNull] WireMockServerSettings settings)
{
_settings = Guard.NotNull(settings, nameof(settings));
}

public async Task<(ResponseMessage Message, IMapping Mapping)> SendAsync(
[NotNull] IProxyAndRecordSettings proxyAndRecordSettings,
[NotNull] ProxyAndRecordSettings proxyAndRecordSettings,
[NotNull] HttpClient client,
[NotNull] RequestMessage requestMessage,
[NotNull] string url)
Expand Down Expand Up @@ -59,7 +59,7 @@ public ProxyHelper([NotNull] IWireMockServerSettings settings)
return (responseMessage, mapping);
}

private IMapping ToMapping(IProxyAndRecordSettings proxyAndRecordSettings, RequestMessage requestMessage, ResponseMessage responseMessage)
private IMapping ToMapping(ProxyAndRecordSettings proxyAndRecordSettings, RequestMessage requestMessage, ResponseMessage responseMessage)
{
string[] excludedHeaders = proxyAndRecordSettings.ExcludedHeaders ?? new string[] { };
string[] excludedCookies = proxyAndRecordSettings.ExcludedCookies ?? new string[] { };
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/ResponseBuilders/IProxyResponseBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
using WireMock.Settings;

namespace WireMock.ResponseBuilders
Expand All @@ -21,6 +21,6 @@ public interface IProxyResponseBuilder : IStatusCodeResponseBuilder
/// </summary>
/// <param name="settings">The IProxyAndRecordSettings.</param>
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithProxy([NotNull] IProxyAndRecordSettings settings);
IResponseBuilder WithProxy([NotNull] ProxyAndRecordSettings settings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ public interface IStatusCodeResponseBuilder : IHeadersResponseBuilder
{
/// <summary>
/// The with status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithStatusCode(int code);

/// <summary>
/// The with status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithStatusCode(string code);

/// <summary>
/// The with status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
Expand Down
6 changes: 3 additions & 3 deletions src/WireMock.Net/ResponseBuilders/Response.WithProxy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net.Http;
using System.Net.Http;
using WireMock.Http;
using WireMock.Settings;
using Stef.Validation;
Expand All @@ -12,7 +12,7 @@ public partial class Response
/// <summary>
/// The WebProxy settings.
/// </summary>
public IProxyAndRecordSettings ProxyAndRecordSettings { get; private set; }
public ProxyAndRecordSettings ProxyAndRecordSettings { get; private set; }

/// <inheritdoc cref="IProxyResponseBuilder.WithProxy(string, string)"/>
public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null)
Expand All @@ -29,7 +29,7 @@ public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2
}

/// <inheritdoc cref="IProxyResponseBuilder.WithProxy(IProxyAndRecordSettings)"/>
public IResponseBuilder WithProxy(IProxyAndRecordSettings settings)
public IResponseBuilder WithProxy(ProxyAndRecordSettings settings)
{
Guard.NotNull(settings, nameof(settings));

Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/ResponseBuilders/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ public IResponseBuilder WithRandomDelay(int minimumMilliseconds = 0, int maximum
return this;
}

/// <inheritdoc cref="IResponseProvider.ProvideResponseAsync(RequestMessage, IWireMockServerSettings)"/>
public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, IWireMockServerSettings settings)
/// <inheritdoc cref="IResponseProvider.ProvideResponseAsync(RequestMessage, WireMockServerSettings)"/>
public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, WireMockServerSettings settings)
{
Guard.NotNull(requestMessage, nameof(requestMessage));
Guard.NotNull(settings, nameof(settings));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public DynamicAsyncResponseProvider(Func<RequestMessage, Task<ResponseMessage>>
_responseMessageFunc = responseMessageFunc;
}

public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, IWireMockServerSettings settings)
public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, WireMockServerSettings settings)
{
return (await _responseMessageFunc(requestMessage).ConfigureAwait(false), null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/ResponseProviders/DynamicResponseProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using WireMock.Settings;

Expand All @@ -13,7 +13,7 @@ public DynamicResponseProvider(Func<RequestMessage, ResponseMessage> responseMes
_responseMessageFunc = responseMessageFunc;
}

public Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, IWireMockServerSettings settings)
public Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, WireMockServerSettings settings)
{
(ResponseMessage responseMessage, IMapping mapping) result = (_responseMessageFunc(requestMessage), null);
return Task.FromResult(result);
Expand Down
2 changes: 1 addition & 1 deletion src/WireMock.Net/ResponseProviders/IResponseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public interface IResponseProvider
/// <param name="requestMessage">The request.</param>
/// <param name="settings">The WireMockServerSettings.</param>
/// <returns>The <see cref="ResponseMessage"/> including a new (optional) <see cref="IMapping"/>.</returns>
Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync([NotNull] RequestMessage requestMessage, [NotNull] IWireMockServerSettings settings);
Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync([NotNull] RequestMessage requestMessage, [NotNull] WireMockServerSettings settings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace WireMock.ResponseProviders
{
internal class ProxyAsyncResponseProvider : IResponseProvider
{
private readonly Func<RequestMessage, IWireMockServerSettings, Task<ResponseMessage>> _responseMessageFunc;
private readonly IWireMockServerSettings _settings;
private readonly Func<RequestMessage, WireMockServerSettings, Task<ResponseMessage>> _responseMessageFunc;
private readonly WireMockServerSettings _settings;

public ProxyAsyncResponseProvider(Func<RequestMessage, IWireMockServerSettings, Task<ResponseMessage>> responseMessageFunc, IWireMockServerSettings settings)
public ProxyAsyncResponseProvider(Func<RequestMessage, WireMockServerSettings, Task<ResponseMessage>> responseMessageFunc, WireMockServerSettings settings)
{
_responseMessageFunc = responseMessageFunc;
_settings = settings;
}

public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, IWireMockServerSettings settings)
public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, WireMockServerSettings settings)
{
return (await _responseMessageFunc(requestMessage, _settings).ConfigureAwait(false), null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WireMock.Net/Serialization/MappingConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public MappingModel ToMappingModel(IMapping mapping)
return mappingModel;
}

private static WebProxyModel MapWebProxy(IWebProxySettings settings)
private static WebProxyModel MapWebProxy(WebProxySettings settings)
{
return settings != null ? new WebProxyModel
{
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Serialization/MappingToFileSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace WireMock.Serialization
{
internal class MappingToFileSaver
{
private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;
private readonly MappingConverter _mappingConverter;

public MappingToFileSaver(IWireMockServerSettings settings, MappingConverter mappingConverter)
public MappingToFileSaver(WireMockServerSettings settings, MappingConverter mappingConverter)
{
Guard.NotNull(settings, nameof(settings));

Expand Down
6 changes: 3 additions & 3 deletions src/WireMock.Net/Serialization/MatcherMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace WireMock.Serialization
{
internal class MatcherMapper
{
private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;

public MatcherMapper(IWireMockServerSettings settings)
public MatcherMapper(WireMockServerSettings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public IMatcher Map([CanBeNull] MatcherModel matcher)
return PluginLoader.Load<ICSharpCodeMatcher>(matchBehaviour, stringPatterns);
}

throw new NotSupportedException("It's not allowed to use the 'CSharpCodeMatcher' because IWireMockServerSettings.AllowCSharpCodeMatcher is not set to 'true'.");
throw new NotSupportedException("It's not allowed to use the 'CSharpCodeMatcher' because WireMockServerSettings.AllowCSharpCodeMatcher is not set to 'true'.");

case nameof(LinqMatcher):
return new LinqMatcher(matchBehaviour, throwExceptionWhenMatcherFails, stringPatterns);
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Server/RespondWithAProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class RespondWithAProvider : IRespondWithAProvider
private int _timesInSameState = 1;
private readonly RegistrationCallback _registrationCallback;
private readonly IRequestMatcher _requestMatcher;
private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;
private readonly bool _saveToFile;

public Guid Guid { get; private set; } = Guid.NewGuid();
Expand All @@ -43,7 +43,7 @@ internal class RespondWithAProvider : IRespondWithAProvider
/// <param name="requestMatcher">The request matcher.</param>
/// <param name="settings">The WireMockServerSettings.</param>
/// <param name="saveToFile">Optional boolean to indicate if this mapping should be saved as static mapping file.</param>
public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher, IWireMockServerSettings settings, bool saveToFile = false)
public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher, WireMockServerSettings settings, bool saveToFile = false)
{
_registrationCallback = registrationCallback;
_requestMatcher = requestMatcher;
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Server/WireMockServer.Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public bool ReadStaticMappingAndAddOrUpdate([NotNull] string path)
#region Proxy and Record
private HttpClient _httpClientForProxy;

private void InitProxyAndRecord(IWireMockServerSettings settings)
private void InitProxyAndRecord(WireMockServerSettings settings)
{
_httpClientForProxy = HttpClientBuilder.Build(settings.ProxyAndRecordSettings);

Expand All @@ -222,7 +222,7 @@ private void InitProxyAndRecord(IWireMockServerSettings settings)
respondProvider.RespondWith(new ProxyAsyncResponseProvider(ProxyAndRecordAsync, settings));
}

private async Task<ResponseMessage> ProxyAndRecordAsync(RequestMessage requestMessage, IWireMockServerSettings settings)
private async Task<ResponseMessage> ProxyAndRecordAsync(RequestMessage requestMessage, WireMockServerSettings settings)
{
var requestUri = new Uri(requestMessage.Url);
var proxyUri = new Uri(settings.ProxyAndRecordSettings.Url);
Expand Down
6 changes: 3 additions & 3 deletions src/WireMock.Net/Server/WireMockServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class WireMockServer : IWireMockServer
{
private const int ServerStartDelayInMs = 100;

private readonly IWireMockServerSettings _settings;
private readonly WireMockServerSettings _settings;
private readonly IOwinSelfHost _httpServer;
private readonly IWireMockMiddlewareOptions _options = new WireMockMiddlewareOptions();
private readonly MappingConverter _mappingConverter;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected virtual void Dispose(bool disposing)
/// <param name="settings">The WireMockServerSettings.</param>
/// <returns>The <see cref="WireMockServer"/>.</returns>
[PublicAPI]
public static WireMockServer Start([NotNull] IWireMockServerSettings settings)
public static WireMockServer Start([NotNull] WireMockServerSettings settings)
{
Guard.NotNull(settings, nameof(settings));

Expand Down Expand Up @@ -193,7 +193,7 @@ public static WireMockServer StartWithAdminInterfaceAndReadStaticMappings(params
/// Service start failed with error: {startTask.Exception.Message}
/// </exception>
/// <exception cref="TimeoutException">Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}</exception>
protected WireMockServer(IWireMockServerSettings settings)
protected WireMockServer(WireMockServerSettings settings)
{
_settings = settings;

Expand Down
19 changes: 13 additions & 6 deletions src/WireMock.Net/Settings/HttpClientSettings.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
namespace WireMock.Settings
namespace WireMock.Settings
{
/// <summary>
/// HttpClientSettings
/// </summary>
public class HttpClientSettings : IHttpClientSettings
public class HttpClientSettings
{
/// <inheritdoc cref="IHttpClientSettings.ClientX509Certificate2ThumbprintOrSubjectName"/>
/// <summary>
/// The clientCertificate thumbprint or subject name fragment to use.
/// Example thumbprint : "D2DBF135A8D06ACCD0E1FAD9BFB28678DF7A9818". Example subject name: "www.google.com""
/// </summary>
public string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }

/// <inheritdoc cref="IHttpClientSettings.WebProxySettings"/>
public IWebProxySettings WebProxySettings { get; set; }
/// <summary>
/// Defines the WebProxySettings.
/// </summary>
public WebProxySettings WebProxySettings { get; set; }

/// <inheritdoc cref="IHttpClientSettings.AllowAutoRedirect"/>
/// <summary>
/// Proxy requests should follow redirection (30x).
/// </summary>
public bool? AllowAutoRedirect { get; set; }
}
}
24 changes: 0 additions & 24 deletions src/WireMock.Net/Settings/IHttpClientSettings.cs

This file was deleted.

Loading

0 comments on commit 42882c8

Please sign in to comment.