diff --git a/src/WireMock.Net/Matchers/SimMetricsMatcher.cs b/src/WireMock.Net/Matchers/SimMetricsMatcher.cs
index db49d248..81789f48 100644
--- a/src/WireMock.Net/Matchers/SimMetricsMatcher.cs
+++ b/src/WireMock.Net/Matchers/SimMetricsMatcher.cs
@@ -32,7 +32,7 @@ namespace WireMock.Matchers
/// The SimMetric Type
public SimMetricsMatcher([NotNull] string[] patterns, SimMetricType simMetricType = SimMetricType.Levenstein)
{
- Check.NotEmpty(patterns, nameof(patterns));
+ Check.NotNullOrEmpty(patterns, nameof(patterns));
_patterns = patterns;
_simMetricType = simMetricType;
diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
index 130b4e72..d3f500d5 100644
--- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
+++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
@@ -31,7 +31,7 @@ namespace WireMock.Owin
public AspNetCoreSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
{
Check.NotNull(options, nameof(options));
- Check.NotEmpty(uriPrefixes, nameof(uriPrefixes));
+ Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
foreach (string uriPrefix in uriPrefixes)
{
@@ -51,8 +51,11 @@ namespace WireMock.Owin
.Configure(appBuilder =>
{
appBuilder.UseMiddleware();
+
_options.PreWireMockMiddlewareInit?.Invoke(appBuilder);
+
appBuilder.UseMiddleware(_options);
+
_options.PostWireMockMiddlewareInit?.Invoke(appBuilder);
})
.UseKestrel(options =>
diff --git a/src/WireMock.Net/Owin/OwinSelfHost.cs b/src/WireMock.Net/Owin/OwinSelfHost.cs
index 2f780b80..81231578 100644
--- a/src/WireMock.Net/Owin/OwinSelfHost.cs
+++ b/src/WireMock.Net/Owin/OwinSelfHost.cs
@@ -19,7 +19,7 @@ namespace WireMock.Owin
public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
{
Check.NotNull(options, nameof(options));
- Check.NotEmpty(uriPrefixes, nameof(uriPrefixes));
+ Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
foreach (string uriPrefix in uriPrefixes)
{
diff --git a/src/WireMock.Net/RequestBuilders/Request.cs b/src/WireMock.Net/RequestBuilders/Request.cs
index 090d3336..b65bdee4 100644
--- a/src/WireMock.Net/RequestBuilders/Request.cs
+++ b/src/WireMock.Net/RequestBuilders/Request.cs
@@ -61,7 +61,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithClientIP(params IMatcher[] matchers)
{
- Check.NotEmpty(matchers, nameof(matchers));
+ Check.NotNullOrEmpty(matchers, nameof(matchers));
_requestMatchers.Add(new RequestMessageClientIPMatcher(matchers));
return this;
@@ -74,7 +74,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithClientIP(params string[] clientIPs)
{
- Check.NotEmpty(clientIPs, nameof(clientIPs));
+ Check.NotNullOrEmpty(clientIPs, nameof(clientIPs));
_requestMatchers.Add(new RequestMessageClientIPMatcher(clientIPs));
return this;
@@ -87,7 +87,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithClientIP(params Func[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessageClientIPMatcher(funcs));
return this;
@@ -100,7 +100,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithPath(params IMatcher[] matchers)
{
- Check.NotEmpty(matchers, nameof(matchers));
+ Check.NotNullOrEmpty(matchers, nameof(matchers));
_requestMatchers.Add(new RequestMessagePathMatcher(matchers));
return this;
@@ -113,7 +113,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithPath(params string[] paths)
{
- Check.NotEmpty(paths, nameof(paths));
+ Check.NotNullOrEmpty(paths, nameof(paths));
_requestMatchers.Add(new RequestMessagePathMatcher(paths));
return this;
@@ -126,7 +126,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithPath(params Func[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessagePathMatcher(funcs));
return this;
@@ -139,7 +139,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithUrl(params IMatcher[] matchers)
{
- Check.NotEmpty(matchers, nameof(matchers));
+ Check.NotNullOrEmpty(matchers, nameof(matchers));
_requestMatchers.Add(new RequestMessageUrlMatcher(matchers));
return this;
@@ -152,7 +152,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithUrl(params string[] urls)
{
- Check.NotEmpty(urls, nameof(urls));
+ Check.NotNullOrEmpty(urls, nameof(urls));
_requestMatchers.Add(new RequestMessageUrlMatcher(urls));
return this;
@@ -165,7 +165,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithUrl(params Func[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessageUrlMatcher(funcs));
return this;
@@ -228,7 +228,7 @@ namespace WireMock.RequestBuilders
///
public IRequestBuilder UsingVerb(params string[] verbs)
{
- Check.NotEmpty(verbs, nameof(verbs));
+ Check.NotNullOrEmpty(verbs, nameof(verbs));
_requestMatchers.Add(new RequestMessageMethodMatcher(verbs));
return this;
@@ -328,7 +328,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithParam(params Func>, bool>[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessageParamMatcher(funcs));
return this;
@@ -363,7 +363,7 @@ namespace WireMock.RequestBuilders
public IRequestBuilder WithHeader(string name, params IMatcher[] matchers)
{
Check.NotNull(name, nameof(name));
- Check.NotEmpty(matchers, nameof(matchers));
+ Check.NotNullOrEmpty(matchers, nameof(matchers));
_requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers));
return this;
@@ -376,7 +376,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithHeader(params Func, bool>[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
return this;
@@ -403,7 +403,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithCookie(string name, params IMatcher[] matchers)
{
- Check.NotEmpty(matchers, nameof(matchers));
+ Check.NotNullOrEmpty(matchers, nameof(matchers));
_requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers));
return this;
@@ -416,7 +416,7 @@ namespace WireMock.RequestBuilders
/// The .
public IRequestBuilder WithCookie(params Func, bool>[] funcs)
{
- Check.NotEmpty(funcs, nameof(funcs));
+ Check.NotNullOrEmpty(funcs, nameof(funcs));
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
return this;
diff --git a/src/WireMock.Net/ResponseBuilders/Response.cs b/src/WireMock.Net/ResponseBuilders/Response.cs
index 96ed90ee..920869a9 100644
--- a/src/WireMock.Net/ResponseBuilders/Response.cs
+++ b/src/WireMock.Net/ResponseBuilders/Response.cs
@@ -300,7 +300,7 @@ namespace WireMock.ResponseBuilders
///
public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null)
{
- Check.NotEmpty(proxyUrl, nameof(proxyUrl));
+ Check.NotNullOrEmpty(proxyUrl, nameof(proxyUrl));
ProxyUrl = proxyUrl;
ClientX509Certificate2ThumbprintOrSubjectName = clientX509Certificate2ThumbprintOrSubjectName;
diff --git a/src/WireMock.Net/ResponseMessage.cs b/src/WireMock.Net/ResponseMessage.cs
index a6c150e9..cc1f5044 100644
--- a/src/WireMock.Net/ResponseMessage.cs
+++ b/src/WireMock.Net/ResponseMessage.cs
@@ -79,7 +79,7 @@ namespace WireMock
/// The values.
public void AddHeader(string name, params string[] values)
{
- Check.NotEmpty(values, nameof(values));
+ Check.NotNullOrEmpty(values, nameof(values));
var newHeaderValues = Headers.TryGetValue(name, out WireMockList existingValues)
? values.Union(existingValues).ToArray()
diff --git a/src/WireMock.Net/Server/FluentMockServer.Admin.cs b/src/WireMock.Net/Server/FluentMockServer.Admin.cs
index 46928b6b..8202f58d 100644
--- a/src/WireMock.Net/Server/FluentMockServer.Admin.cs
+++ b/src/WireMock.Net/Server/FluentMockServer.Admin.cs
@@ -146,7 +146,7 @@ namespace WireMock.Server
{
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(args.FullPath);
- if (Guid.TryParse(filenameWithoutExtension, out var guidFromFilename))
+ if (Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename))
{
DeleteMapping(guidFromFilename);
}
diff --git a/src/WireMock.Net/Server/FluentMockServer.cs b/src/WireMock.Net/Server/FluentMockServer.cs
index 3ab9838c..0ed4e989 100644
--- a/src/WireMock.Net/Server/FluentMockServer.cs
+++ b/src/WireMock.Net/Server/FluentMockServer.cs
@@ -94,7 +94,7 @@ namespace WireMock.Server
[PublicAPI]
public static FluentMockServer Start(params string[] urls)
{
- Check.NotEmpty(urls, nameof(urls));
+ Check.NotNullOrEmpty(urls, nameof(urls));
return new FluentMockServer(new FluentMockServerSettings
{
@@ -127,7 +127,7 @@ namespace WireMock.Server
[PublicAPI]
public static FluentMockServer StartWithAdminInterface(params string[] urls)
{
- Check.NotEmpty(urls, nameof(urls));
+ Check.NotNullOrEmpty(urls, nameof(urls));
return new FluentMockServer(new FluentMockServerSettings
{
@@ -144,7 +144,7 @@ namespace WireMock.Server
[PublicAPI]
public static FluentMockServer StartWithAdminInterfaceAndReadStaticMappings(params string[] urls)
{
- Check.NotEmpty(urls, nameof(urls));
+ Check.NotNullOrEmpty(urls, nameof(urls));
return new FluentMockServer(new FluentMockServerSettings
{
diff --git a/src/WireMock.Net/Validation/Check.cs b/src/WireMock.Net/Validation/Check.cs
index aaf67365..90a298a1 100644
--- a/src/WireMock.Net/Validation/Check.cs
+++ b/src/WireMock.Net/Validation/Check.cs
@@ -23,7 +23,7 @@ namespace WireMock.Validation
if (!condition(value))
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentOutOfRangeException(parameterName);
}
@@ -36,7 +36,7 @@ namespace WireMock.Validation
{
if (ReferenceEquals(value, null))
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentNullException(parameterName);
}
@@ -45,15 +45,12 @@ namespace WireMock.Validation
}
[ContractAnnotation("value:null => halt")]
- public static T NotNull(
- [NoEnumeration] T value,
- [InvokerParameterName] [NotNull] string parameterName,
- [NotNull] string propertyName)
+ public static T NotNull([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName, [NotNull] string propertyName)
{
if (ReferenceEquals(value, null))
{
- NotEmpty(parameterName, nameof(parameterName));
- NotEmpty(propertyName, nameof(propertyName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(propertyName, nameof(propertyName));
throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName));
}
@@ -62,13 +59,13 @@ namespace WireMock.Validation
}
[ContractAnnotation("value:null => halt")]
- public static IList NotEmpty(IList value, [InvokerParameterName] [NotNull] string parameterName)
+ public static IList NotNullOrEmpty(IList value, [InvokerParameterName] [NotNull] string parameterName)
{
NotNull(value, parameterName);
if (value.Count == 0)
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));
}
@@ -77,7 +74,7 @@ namespace WireMock.Validation
}
[ContractAnnotation("value:null => halt")]
- public static string NotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
+ public static string NotNullOrEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
{
Exception e = null;
if (ReferenceEquals(value, null))
@@ -91,7 +88,7 @@ namespace WireMock.Validation
if (e != null)
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw e;
}
@@ -104,7 +101,7 @@ namespace WireMock.Validation
if (!ReferenceEquals(value, null)
&& (value.Length == 0))
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
}
@@ -119,7 +116,7 @@ namespace WireMock.Validation
if (value.Any(e => e == null))
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(parameterName);
}
@@ -131,7 +128,7 @@ namespace WireMock.Validation
{
if (!value.GetTypeInfo().IsClass)
{
- NotEmpty(parameterName, nameof(parameterName));
+ NotNullOrEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
}
diff --git a/src/WireMock.Net/Validation/CoreStrings.cs b/src/WireMock.Net/Validation/CoreStrings.cs
index b6bc3308..dc466b8b 100644
--- a/src/WireMock.Net/Validation/CoreStrings.cs
+++ b/src/WireMock.Net/Validation/CoreStrings.cs
@@ -1,6 +1,4 @@
using System;
-using System.Globalization;
-using JetBrains.Annotations;
// copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Properties/CoreStrings.resx
namespace WireMock.Validation
@@ -11,33 +9,33 @@ namespace WireMock.Validation
///
/// The property '{property}' of the argument '{argument}' cannot be null.
///
- public static string ArgumentPropertyNull([CanBeNull] string property, [CanBeNull] string argument)
+ public static string ArgumentPropertyNull(string property, string argument)
{
- return string.Format(CultureInfo.CurrentCulture, $"The property '{property}' of the argument '{argument}' cannot be null.", property, argument);
+ return $"The property '{property}' of the argument '{argument}' cannot be null.";
}
///
/// The string argument '{argumentName}' cannot be empty.
///
- public static string ArgumentIsEmpty([CanBeNull] string argumentName)
+ public static string ArgumentIsEmpty(string argumentName)
{
- return string.Format(CultureInfo.CurrentCulture, $"The string argument '{argumentName}' cannot be empty.", argumentName);
+ return $"The string argument '{argumentName}' cannot be empty.";
}
///
/// The entity type '{type}' provided for the argument '{argumentName}' must be a reference type.
///
- public static string InvalidEntityType([CanBeNull] Type type, [CanBeNull] string argumentName)
+ public static string InvalidEntityType(Type type, string argumentName)
{
- return string.Format(CultureInfo.CurrentCulture, $"The entity type '{type}' provided for the argument '{argumentName}' must be a reference type.", type, argumentName);
+ return $"The entity type '{type}' provided for the argument '{argumentName}' must be a reference type.";
}
///
/// The collection argument '{argumentName}' must contain at least one element.
///
- public static string CollectionArgumentIsEmpty([CanBeNull] string argumentName)
+ public static string CollectionArgumentIsEmpty(string argumentName)
{
- return string.Format(CultureInfo.CurrentCulture, $"The collection argument '{argumentName}' must contain at least one element.", argumentName);
+ return $"The collection argument '{argumentName}' must contain at least one element.";
}
}
}
\ No newline at end of file