mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-28 19:58:09 +02:00
This commit is contained in:
@@ -32,7 +32,7 @@ namespace WireMock.Matchers
|
|||||||
/// <param name="simMetricType">The SimMetric Type</param>
|
/// <param name="simMetricType">The SimMetric Type</param>
|
||||||
public SimMetricsMatcher([NotNull] string[] patterns, SimMetricType simMetricType = SimMetricType.Levenstein)
|
public SimMetricsMatcher([NotNull] string[] patterns, SimMetricType simMetricType = SimMetricType.Levenstein)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(patterns, nameof(patterns));
|
Check.NotNullOrEmpty(patterns, nameof(patterns));
|
||||||
|
|
||||||
_patterns = patterns;
|
_patterns = patterns;
|
||||||
_simMetricType = simMetricType;
|
_simMetricType = simMetricType;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace WireMock.Owin
|
|||||||
public AspNetCoreSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
public AspNetCoreSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
||||||
{
|
{
|
||||||
Check.NotNull(options, nameof(options));
|
Check.NotNull(options, nameof(options));
|
||||||
Check.NotEmpty(uriPrefixes, nameof(uriPrefixes));
|
Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
|
||||||
|
|
||||||
foreach (string uriPrefix in uriPrefixes)
|
foreach (string uriPrefix in uriPrefixes)
|
||||||
{
|
{
|
||||||
@@ -51,8 +51,11 @@ namespace WireMock.Owin
|
|||||||
.Configure(appBuilder =>
|
.Configure(appBuilder =>
|
||||||
{
|
{
|
||||||
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
||||||
|
|
||||||
_options.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
_options.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||||
|
|
||||||
appBuilder.UseMiddleware<WireMockMiddleware>(_options);
|
appBuilder.UseMiddleware<WireMockMiddleware>(_options);
|
||||||
|
|
||||||
_options.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
_options.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||||
})
|
})
|
||||||
.UseKestrel(options =>
|
.UseKestrel(options =>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace WireMock.Owin
|
|||||||
public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
||||||
{
|
{
|
||||||
Check.NotNull(options, nameof(options));
|
Check.NotNull(options, nameof(options));
|
||||||
Check.NotEmpty(uriPrefixes, nameof(uriPrefixes));
|
Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
|
||||||
|
|
||||||
foreach (string uriPrefix in uriPrefixes)
|
foreach (string uriPrefix in uriPrefixes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithClientIP(params IMatcher[] matchers)
|
public IRequestBuilder WithClientIP(params IMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(matchers, nameof(matchers));
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(matchers));
|
_requestMatchers.Add(new RequestMessageClientIPMatcher(matchers));
|
||||||
return this;
|
return this;
|
||||||
@@ -74,7 +74,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithClientIP(params string[] clientIPs)
|
public IRequestBuilder WithClientIP(params string[] clientIPs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(clientIPs, nameof(clientIPs));
|
Check.NotNullOrEmpty(clientIPs, nameof(clientIPs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(clientIPs));
|
_requestMatchers.Add(new RequestMessageClientIPMatcher(clientIPs));
|
||||||
return this;
|
return this;
|
||||||
@@ -87,7 +87,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithClientIP(params Func<string, bool>[] funcs)
|
public IRequestBuilder WithClientIP(params Func<string, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageClientIPMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
@@ -100,7 +100,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithPath(params IMatcher[] matchers)
|
public IRequestBuilder WithPath(params IMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(matchers, nameof(matchers));
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessagePathMatcher(matchers));
|
_requestMatchers.Add(new RequestMessagePathMatcher(matchers));
|
||||||
return this;
|
return this;
|
||||||
@@ -113,7 +113,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithPath(params string[] paths)
|
public IRequestBuilder WithPath(params string[] paths)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(paths, nameof(paths));
|
Check.NotNullOrEmpty(paths, nameof(paths));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessagePathMatcher(paths));
|
_requestMatchers.Add(new RequestMessagePathMatcher(paths));
|
||||||
return this;
|
return this;
|
||||||
@@ -126,7 +126,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithPath(params Func<string, bool>[] funcs)
|
public IRequestBuilder WithPath(params Func<string, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessagePathMatcher(funcs));
|
_requestMatchers.Add(new RequestMessagePathMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
@@ -139,7 +139,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithUrl(params IMatcher[] matchers)
|
public IRequestBuilder WithUrl(params IMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(matchers, nameof(matchers));
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageUrlMatcher(matchers));
|
_requestMatchers.Add(new RequestMessageUrlMatcher(matchers));
|
||||||
return this;
|
return this;
|
||||||
@@ -152,7 +152,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithUrl(params string[] urls)
|
public IRequestBuilder WithUrl(params string[] urls)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(urls, nameof(urls));
|
Check.NotNullOrEmpty(urls, nameof(urls));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageUrlMatcher(urls));
|
_requestMatchers.Add(new RequestMessageUrlMatcher(urls));
|
||||||
return this;
|
return this;
|
||||||
@@ -165,7 +165,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithUrl(params Func<string, bool>[] funcs)
|
public IRequestBuilder WithUrl(params Func<string, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageUrlMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageUrlMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
@@ -228,7 +228,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingVerb"/>
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingVerb"/>
|
||||||
public IRequestBuilder UsingVerb(params string[] verbs)
|
public IRequestBuilder UsingVerb(params string[] verbs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(verbs, nameof(verbs));
|
Check.NotNullOrEmpty(verbs, nameof(verbs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(verbs));
|
_requestMatchers.Add(new RequestMessageMethodMatcher(verbs));
|
||||||
return this;
|
return this;
|
||||||
@@ -328,7 +328,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithParam(params Func<IDictionary<string, WireMockList<string>>, bool>[] funcs)
|
public IRequestBuilder WithParam(params Func<IDictionary<string, WireMockList<string>>, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageParamMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageParamMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
@@ -363,7 +363,7 @@ namespace WireMock.RequestBuilders
|
|||||||
public IRequestBuilder WithHeader(string name, params IMatcher[] matchers)
|
public IRequestBuilder WithHeader(string name, params IMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotEmpty(matchers, nameof(matchers));
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers));
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers));
|
||||||
return this;
|
return this;
|
||||||
@@ -376,7 +376,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
@@ -403,7 +403,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithCookie(string name, params IMatcher[] matchers)
|
public IRequestBuilder WithCookie(string name, params IMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(matchers, nameof(matchers));
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers));
|
_requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers));
|
||||||
return this;
|
return this;
|
||||||
@@ -416,7 +416,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(funcs, nameof(funcs));
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
/// <inheritdoc cref="IProxyResponseBuilder.WithProxy(string, string)"/>
|
/// <inheritdoc cref="IProxyResponseBuilder.WithProxy(string, string)"/>
|
||||||
public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null)
|
public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(proxyUrl, nameof(proxyUrl));
|
Check.NotNullOrEmpty(proxyUrl, nameof(proxyUrl));
|
||||||
|
|
||||||
ProxyUrl = proxyUrl;
|
ProxyUrl = proxyUrl;
|
||||||
ClientX509Certificate2ThumbprintOrSubjectName = clientX509Certificate2ThumbprintOrSubjectName;
|
ClientX509Certificate2ThumbprintOrSubjectName = clientX509Certificate2ThumbprintOrSubjectName;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace WireMock
|
|||||||
/// <param name="values">The values.</param>
|
/// <param name="values">The values.</param>
|
||||||
public void AddHeader(string name, params string[] 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<string> existingValues)
|
var newHeaderValues = Headers.TryGetValue(name, out WireMockList<string> existingValues)
|
||||||
? values.Union(existingValues).ToArray()
|
? values.Union(existingValues).ToArray()
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(args.FullPath);
|
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(args.FullPath);
|
||||||
|
|
||||||
if (Guid.TryParse(filenameWithoutExtension, out var guidFromFilename))
|
if (Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename))
|
||||||
{
|
{
|
||||||
DeleteMapping(guidFromFilename);
|
DeleteMapping(guidFromFilename);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace WireMock.Server
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static FluentMockServer Start(params string[] urls)
|
public static FluentMockServer Start(params string[] urls)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(urls, nameof(urls));
|
Check.NotNullOrEmpty(urls, nameof(urls));
|
||||||
|
|
||||||
return new FluentMockServer(new FluentMockServerSettings
|
return new FluentMockServer(new FluentMockServerSettings
|
||||||
{
|
{
|
||||||
@@ -127,7 +127,7 @@ namespace WireMock.Server
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static FluentMockServer StartWithAdminInterface(params string[] urls)
|
public static FluentMockServer StartWithAdminInterface(params string[] urls)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(urls, nameof(urls));
|
Check.NotNullOrEmpty(urls, nameof(urls));
|
||||||
|
|
||||||
return new FluentMockServer(new FluentMockServerSettings
|
return new FluentMockServer(new FluentMockServerSettings
|
||||||
{
|
{
|
||||||
@@ -144,7 +144,7 @@ namespace WireMock.Server
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static FluentMockServer StartWithAdminInterfaceAndReadStaticMappings(params string[] urls)
|
public static FluentMockServer StartWithAdminInterfaceAndReadStaticMappings(params string[] urls)
|
||||||
{
|
{
|
||||||
Check.NotEmpty(urls, nameof(urls));
|
Check.NotNullOrEmpty(urls, nameof(urls));
|
||||||
|
|
||||||
return new FluentMockServer(new FluentMockServerSettings
|
return new FluentMockServer(new FluentMockServerSettings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace WireMock.Validation
|
|||||||
|
|
||||||
if (!condition(value))
|
if (!condition(value))
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException(parameterName);
|
throw new ArgumentOutOfRangeException(parameterName);
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ namespace WireMock.Validation
|
|||||||
{
|
{
|
||||||
if (ReferenceEquals(value, null))
|
if (ReferenceEquals(value, null))
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentNullException(parameterName);
|
throw new ArgumentNullException(parameterName);
|
||||||
}
|
}
|
||||||
@@ -45,15 +45,12 @@ namespace WireMock.Validation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ContractAnnotation("value:null => halt")]
|
[ContractAnnotation("value:null => halt")]
|
||||||
public static T NotNull<T>(
|
public static T NotNull<T>([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName, [NotNull] string propertyName)
|
||||||
[NoEnumeration] T value,
|
|
||||||
[InvokerParameterName] [NotNull] string parameterName,
|
|
||||||
[NotNull] string propertyName)
|
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(value, null))
|
if (ReferenceEquals(value, null))
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
NotEmpty(propertyName, nameof(propertyName));
|
NotNullOrEmpty(propertyName, nameof(propertyName));
|
||||||
|
|
||||||
throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName));
|
throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName));
|
||||||
}
|
}
|
||||||
@@ -62,13 +59,13 @@ namespace WireMock.Validation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ContractAnnotation("value:null => halt")]
|
[ContractAnnotation("value:null => halt")]
|
||||||
public static IList<T> NotEmpty<T>(IList<T> value, [InvokerParameterName] [NotNull] string parameterName)
|
public static IList<T> NotNullOrEmpty<T>(IList<T> value, [InvokerParameterName] [NotNull] string parameterName)
|
||||||
{
|
{
|
||||||
NotNull(value, parameterName);
|
NotNull(value, parameterName);
|
||||||
|
|
||||||
if (value.Count == 0)
|
if (value.Count == 0)
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));
|
throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));
|
||||||
}
|
}
|
||||||
@@ -77,7 +74,7 @@ namespace WireMock.Validation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ContractAnnotation("value:null => halt")]
|
[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;
|
Exception e = null;
|
||||||
if (ReferenceEquals(value, null))
|
if (ReferenceEquals(value, null))
|
||||||
@@ -91,7 +88,7 @@ namespace WireMock.Validation
|
|||||||
|
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -104,7 +101,7 @@ namespace WireMock.Validation
|
|||||||
if (!ReferenceEquals(value, null)
|
if (!ReferenceEquals(value, null)
|
||||||
&& (value.Length == 0))
|
&& (value.Length == 0))
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
|
throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
|
||||||
}
|
}
|
||||||
@@ -119,7 +116,7 @@ namespace WireMock.Validation
|
|||||||
|
|
||||||
if (value.Any(e => e == null))
|
if (value.Any(e => e == null))
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentException(parameterName);
|
throw new ArgumentException(parameterName);
|
||||||
}
|
}
|
||||||
@@ -131,7 +128,7 @@ namespace WireMock.Validation
|
|||||||
{
|
{
|
||||||
if (!value.GetTypeInfo().IsClass)
|
if (!value.GetTypeInfo().IsClass)
|
||||||
{
|
{
|
||||||
NotEmpty(parameterName, nameof(parameterName));
|
NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||||
|
|
||||||
throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
|
throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
// copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Properties/CoreStrings.resx
|
// copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Properties/CoreStrings.resx
|
||||||
namespace WireMock.Validation
|
namespace WireMock.Validation
|
||||||
@@ -11,33 +9,33 @@ namespace WireMock.Validation
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The property '{property}' of the argument '{argument}' cannot be null.
|
/// The property '{property}' of the argument '{argument}' cannot be null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The string argument '{argumentName}' cannot be empty.
|
/// The string argument '{argumentName}' cannot be empty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The entity type '{type}' provided for the argument '{argumentName}' must be a reference type.
|
/// The entity type '{type}' provided for the argument '{argumentName}' must be a reference type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The collection argument '{argumentName}' must contain at least one element.
|
/// The collection argument '{argumentName}' must contain at least one element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user