mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Fix Sonarqube issues
This commit is contained in:
@@ -45,7 +45,18 @@ namespace WireMock
|
||||
/// </summary>
|
||||
object StatusCode { get; }
|
||||
|
||||
//void AddHeader(string name, params string[] values);
|
||||
//void AddHeader(string name, string value);
|
||||
/// <summary>
|
||||
/// Adds the header.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
void AddHeader(string name, string value);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the header.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="values">The values.</param>
|
||||
void AddHeader(string name, params string[] values);
|
||||
}
|
||||
}
|
||||
@@ -3,78 +3,54 @@ using WireMock.Matchers.Request;
|
||||
|
||||
namespace WireMock.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// ILogEntry
|
||||
/// </summary>
|
||||
public interface ILogEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The unique identifier.
|
||||
/// </value>
|
||||
Guid Guid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping unique identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The mapping unique identifier.
|
||||
/// </value>
|
||||
Guid? MappingGuid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping unique title.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The mapping unique title.
|
||||
/// </value>
|
||||
string MappingTitle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the partial mapping unique identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The mapping unique identifier.
|
||||
/// </value>
|
||||
Guid? PartialMappingGuid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the partial mapping unique title.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The mapping unique title.
|
||||
/// </value>
|
||||
string PartialMappingTitle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the partial match result.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The request match result.
|
||||
/// </value>
|
||||
IRequestMatchResult PartialMatchResult { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request match result.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The request match result.
|
||||
/// </value>
|
||||
IRequestMatchResult RequestMatchResult { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request message.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The request message.
|
||||
/// </value>
|
||||
IRequestMessage RequestMessage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the response message.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The response message.
|
||||
/// </value>
|
||||
IResponseMessage ResponseMessage { get; }
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,19 @@
|
||||
|
||||
namespace WireMock.Matchers.Request
|
||||
{
|
||||
/// <summary>
|
||||
/// MatchDetail
|
||||
/// </summary>
|
||||
public class MatchDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the matcher.
|
||||
/// </summary>
|
||||
public Type MatcherType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the score between 0.0 and 1.0
|
||||
/// </summary>
|
||||
public double Score { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RandomDataGenerator.FieldOptions;
|
||||
using RandomDataGenerator.Randomizers;
|
||||
using WireMock.Exceptions;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Http;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Types;
|
||||
|
||||
@@ -2,9 +2,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using WireMock.Logging;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using WireMock.Matchers;
|
||||
using Newtonsoft.Json;
|
||||
using WireMock.Http;
|
||||
using WireMock.Owin.Mappers;
|
||||
using WireMock.Serialization;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.ObjectModel;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Matchers;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace WireMock.ResponseBuilders
|
||||
[PublicAPI]
|
||||
public static IResponseBuilder Create([CanBeNull] ResponseMessage responseMessage = null)
|
||||
{
|
||||
var message = responseMessage ?? new ResponseMessage(); // { StatusCode = (int)HttpStatusCode.OK };
|
||||
var message = responseMessage ?? new ResponseMessage();
|
||||
return new Response(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,21 +35,13 @@ namespace WireMock
|
||||
/// <inheritdoc cref="IResponseMessage.FaultPercentage" />
|
||||
public double? FaultPercentage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the header.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <inheritdoc cref="IResponseMessage.AddHeader(string, string)" />
|
||||
public void AddHeader(string name, string value)
|
||||
{
|
||||
Headers.Add(name, new WireMockList<string>(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the header.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="values">The values.</param>
|
||||
/// <inheritdoc cref="IResponseMessage.AddHeader(string, string[])" />
|
||||
public void AddHeader(string name, params string[] values)
|
||||
{
|
||||
Check.NotNullOrEmpty(values, nameof(values));
|
||||
|
||||
@@ -95,21 +95,6 @@ namespace WireMock.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
private ExactObjectMatcher CreateExactObjectMatcher(MatchBehaviour matchBehaviour, string stringPattern, bool throwException)
|
||||
{
|
||||
byte[] bytePattern;
|
||||
try
|
||||
{
|
||||
bytePattern = Convert.FromBase64String(stringPattern);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"Matcher 'ExactObjectMatcher' has invalid pattern. The pattern value '{stringPattern}' is not a Base64String.", nameof(stringPattern));
|
||||
}
|
||||
|
||||
return new ExactObjectMatcher(matchBehaviour, bytePattern, throwException);
|
||||
}
|
||||
|
||||
public MatcherModel[] Map([CanBeNull] IEnumerable<IMatcher> matchers)
|
||||
{
|
||||
return matchers?.Select(Map).Where(m => m != null).ToArray();
|
||||
@@ -154,5 +139,20 @@ namespace WireMock.Serialization
|
||||
Patterns = patterns.Length > 1 ? patterns : null
|
||||
};
|
||||
}
|
||||
|
||||
private ExactObjectMatcher CreateExactObjectMatcher(MatchBehaviour matchBehaviour, string stringPattern, bool throwException)
|
||||
{
|
||||
byte[] bytePattern;
|
||||
try
|
||||
{
|
||||
bytePattern = Convert.FromBase64String(stringPattern);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"Matcher 'ExactObjectMatcher' has invalid pattern. The pattern value '{stringPattern}' is not a Base64String.", nameof(stringPattern));
|
||||
}
|
||||
|
||||
return new ExactObjectMatcher(matchBehaviour, bytePattern, throwException);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -833,9 +833,9 @@ namespace WireMock.Server
|
||||
|
||||
if (requestModel.Params != null)
|
||||
{
|
||||
foreach (var paramModel in requestModel.Params.Where(c => c.Matchers != null))
|
||||
foreach (var paramModel in requestModel.Params.Where(p => p != null && p.Matchers != null))
|
||||
{
|
||||
bool ignoreCase = paramModel?.IgnoreCase ?? false;
|
||||
bool ignoreCase = paramModel.IgnoreCase == true;
|
||||
requestBuilder = requestBuilder.WithParam(paramModel.Name, ignoreCase, paramModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,17 @@ namespace WireMock.Server
|
||||
ReadStaticMappings = true
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WireMockServer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <exception cref="WireMockException">
|
||||
/// Service start failed with error: {_httpServer.RunningException.Message}
|
||||
/// or
|
||||
/// 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)
|
||||
{
|
||||
_settings = settings;
|
||||
@@ -422,7 +433,7 @@ namespace WireMock.Server
|
||||
{
|
||||
_options.Scenarios.Clear();
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc cref="IWireMockServer.WithMapping(MappingModel[])" />
|
||||
[PublicAPI]
|
||||
public IWireMockServer WithMapping(params MappingModel[] mappings)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace WireMock.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// IWebProxySettings
|
||||
/// </summary>
|
||||
public interface IWebProxySettings
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace WireMock.Settings
|
||||
{
|
||||
/// <seealso cref="IWebProxySettings" />
|
||||
public class WebProxySettings : IWebProxySettings
|
||||
{
|
||||
/// <inheritdoc cref="IWebProxySettings.Address"/>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using HandlebarsDotNet;
|
||||
|
||||
namespace WireMock.Transformers
|
||||
namespace WireMock.Transformers
|
||||
{
|
||||
interface IHandlebarsContextFactory
|
||||
{
|
||||
IHandlebarsContext Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
// Copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs
|
||||
@@ -96,19 +95,6 @@ namespace WireMock.Validation
|
||||
return value;
|
||||
}
|
||||
|
||||
//public static string NullButNotEmpty(string value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
|
||||
//{
|
||||
// if (!ReferenceEquals(value, null)
|
||||
// && (value.Length == 0))
|
||||
// {
|
||||
// NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||
|
||||
// throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
|
||||
// }
|
||||
|
||||
// return value;
|
||||
//}
|
||||
|
||||
public static IList<T> HasNoNulls<T>(IList<T> value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
|
||||
where T : class
|
||||
{
|
||||
@@ -123,17 +109,5 @@ namespace WireMock.Validation
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
//public static Type ValidEntityType(Type value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
|
||||
//{
|
||||
// if (!value.GetTypeInfo().IsClass)
|
||||
// {
|
||||
// NotNullOrEmpty(parameterName, nameof(parameterName));
|
||||
|
||||
// throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
|
||||
// }
|
||||
|
||||
// return value;
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user