diff --git a/src/WireMock.Net/Admin/Mappings/BodyModel.cs b/src/WireMock.Net/Admin/Mappings/BodyModel.cs
index 32220409..da5a725f 100644
--- a/src/WireMock.Net/Admin/Mappings/BodyModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/BodyModel.cs
@@ -9,15 +9,5 @@
/// Gets or sets the matcher.
///
public MatcherModel Matcher { get; set; }
-
- /////
- ///// Gets or sets the function.
- /////
- //public string Func { get; set; }
-
- /////
- ///// Gets or sets the data function.
- /////
- //public string DataFunc { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/ClientIPModel.cs b/src/WireMock.Net/Admin/Mappings/ClientIPModel.cs
index aad9c9df..3260b09b 100644
--- a/src/WireMock.Net/Admin/Mappings/ClientIPModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/ClientIPModel.cs
@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
///
public MatcherModel[] Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/CookieModel.cs b/src/WireMock.Net/Admin/Mappings/CookieModel.cs
index 03a4561f..9b219b6c 100644
--- a/src/WireMock.Net/Admin/Mappings/CookieModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/CookieModel.cs
@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
/// Gets or sets the matchers.
///
public IList Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/HeaderModel.cs b/src/WireMock.Net/Admin/Mappings/HeaderModel.cs
index abd50196..7c2585b0 100644
--- a/src/WireMock.Net/Admin/Mappings/HeaderModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/HeaderModel.cs
@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
/// Gets or sets the matchers.
///
public IList Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/ParamModel.cs b/src/WireMock.Net/Admin/Mappings/ParamModel.cs
index 1fe25043..8b4ca0b1 100644
--- a/src/WireMock.Net/Admin/Mappings/ParamModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/ParamModel.cs
@@ -1,6 +1,4 @@
-// using System.Collections.Generic;
-
-namespace WireMock.Admin.Mappings
+namespace WireMock.Admin.Mappings
{
///
/// Param Model
@@ -12,19 +10,9 @@ namespace WireMock.Admin.Mappings
///
public string Name { get; set; }
- /////
- ///// Gets or sets the values.
- /////
- //public IList Values { get; set; }
-
///
/// Gets or sets the matchers.
///
public MatcherModel[] Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/PathModel.cs b/src/WireMock.Net/Admin/Mappings/PathModel.cs
index ecd42a3c..56915622 100644
--- a/src/WireMock.Net/Admin/Mappings/PathModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/PathModel.cs
@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
///
public MatcherModel[] Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Admin/Mappings/UrlModel.cs b/src/WireMock.Net/Admin/Mappings/UrlModel.cs
index 68ac6d63..083192da 100644
--- a/src/WireMock.Net/Admin/Mappings/UrlModel.cs
+++ b/src/WireMock.Net/Admin/Mappings/UrlModel.cs
@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
///
public MatcherModel[] Matchers { get; set; }
-
- /////
- ///// Gets or sets the functions.
- /////
- //public string[] Funcs { get; set; }
}
}
diff --git a/src/WireMock.Net/HttpsCertificate/ClientCertificateHelper.cs b/src/WireMock.Net/HttpsCertificate/ClientCertificateHelper.cs
index 8237560d..85c12b21 100644
--- a/src/WireMock.Net/HttpsCertificate/ClientCertificateHelper.cs
+++ b/src/WireMock.Net/HttpsCertificate/ClientCertificateHelper.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Security.Cryptography.X509Certificates;
namespace WireMock.HttpsCertificate
@@ -10,19 +11,19 @@ namespace WireMock.HttpsCertificate
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
try
{
- //Certificate must be in the local machine store
+ // Certificate must be in the local machine store
certStore.Open(OpenFlags.ReadOnly);
- //Attempt to find by thumbprint first
+ // Attempt to find by thumbprint first
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectName, false);
if (matchingCertificates.Count == 0)
{
- //Fallback to subject name
+ // Fallback to subject name
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectName, false);
if (matchingCertificates.Count == 0)
{
// No certificates matched the search criteria.
- throw new Exception($"No certificate found with Thumbprint or SubjectName '{thumbprintOrSubjectName}'");
+ throw new FileNotFoundException("No certificate found with specified Thumbprint or SubjectName.", thumbprintOrSubjectName);
}
}
// Use the first matching certificate.
diff --git a/src/WireMock.Net/Logging/IWireMockLogger.cs b/src/WireMock.Net/Logging/IWireMockLogger.cs
index 41486d8b..86a1a2d1 100644
--- a/src/WireMock.Net/Logging/IWireMockLogger.cs
+++ b/src/WireMock.Net/Logging/IWireMockLogger.cs
@@ -49,8 +49,8 @@ namespace WireMock.Logging
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
///
/// The Request Log Model.
- /// Defines if this request is an admin request.
+ /// Defines if this request is an admin request.
[PublicAPI]
- void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminrequest);
+ void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminRequest);
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Logging/WireMockNullLogger.cs b/src/WireMock.Net/Logging/WireMockNullLogger.cs
index f2fea811..f1627a79 100644
--- a/src/WireMock.Net/Logging/WireMockNullLogger.cs
+++ b/src/WireMock.Net/Logging/WireMockNullLogger.cs
@@ -11,26 +11,31 @@ namespace WireMock.Logging
///
public void Debug(string formatString, params object[] args)
{
+ // Log nothing
}
///
public void Info(string formatString, params object[] args)
{
+ // Log nothing
}
///
public void Warn(string formatString, params object[] args)
{
+ // Log nothing
}
///
public void Error(string formatString, params object[] args)
{
+ // Log nothing
}
///
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
{
+ // Log nothing
}
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageScenarioAndStateMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageScenarioAndStateMatcher.cs
index a51dc1ec..8bb0aeb7 100644
--- a/src/WireMock.Net/Matchers/Request/RequestMessageScenarioAndStateMatcher.cs
+++ b/src/WireMock.Net/Matchers/Request/RequestMessageScenarioAndStateMatcher.cs
@@ -7,11 +7,6 @@ namespace WireMock.Matchers.Request
///
internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher
{
- /////
- ///// Scenario.
- /////
- //[CanBeNull] private string _scenario;
-
///
/// Execution state condition for the current mapping.
///
diff --git a/src/WireMock.Net/Owin/WireMockMiddleware.cs b/src/WireMock.Net/Owin/WireMockMiddleware.cs
index 97fb90dd..67c85189 100644
--- a/src/WireMock.Net/Owin/WireMockMiddleware.cs
+++ b/src/WireMock.Net/Owin/WireMockMiddleware.cs
@@ -7,7 +7,6 @@ using System.Linq;
using WireMock.Matchers;
using WireMock.Util;
using Newtonsoft.Json;
-using WireMock.Admin.Mappings;
using WireMock.Http;
using WireMock.Serialization;
#if !NETSTANDARD
@@ -24,8 +23,6 @@ namespace WireMock.Owin
internal class WireMockMiddleware
#endif
{
- private readonly IDictionary> _contentTypeJsonHeaders = new Dictionary> { { HttpKnownHeaderNames.ContentType, new WireMockList { "application/json" } } };
-
private static readonly Task CompletedTask = Task.FromResult(false);
private readonly WireMockMiddlewareOptions _options;
diff --git a/src/WireMock.Net/RequestBuilders/IHeadersAndCookiesRequestBuilder.cs b/src/WireMock.Net/RequestBuilders/IHeadersAndCookiesRequestBuilder.cs
index a8b1b853..254938d9 100644
--- a/src/WireMock.Net/RequestBuilders/IHeadersAndCookiesRequestBuilder.cs
+++ b/src/WireMock.Net/RequestBuilders/IHeadersAndCookiesRequestBuilder.cs
@@ -85,8 +85,8 @@ namespace WireMock.RequestBuilders
///
/// WithCookie: matching based on functions.
///
- /// The funcs.
+ /// The funcs.
/// The .
- IRequestBuilder WithCookie([NotNull] params Func, bool>[] cookieFuncs);
+ IRequestBuilder WithCookie([NotNull] params Func, bool>[] funcs);
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/RequestBuilders/IMethodRequestBuilder.cs b/src/WireMock.Net/RequestBuilders/IMethodRequestBuilder.cs
index a14b3444..93d90d24 100644
--- a/src/WireMock.Net/RequestBuilders/IMethodRequestBuilder.cs
+++ b/src/WireMock.Net/RequestBuilders/IMethodRequestBuilder.cs
@@ -61,7 +61,7 @@ namespace WireMock.RequestBuilders
/// UsingAnyVerb: add HTTP Method matching on any method.
///
/// The .
- [Obsolete]
+ [Obsolete("Use the method UsingAnyMethod().")]
IRequestBuilder UsingAnyVerb();
///
@@ -84,7 +84,7 @@ namespace WireMock.RequestBuilders
///
/// The methods.
/// The .
- [Obsolete]
+ [Obsolete("Use the method UsingMethod(...).")]
IRequestBuilder UsingVerb([NotNull] params string[] verbs);
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/RequestBuilders/IUrlAndPathRequestBuilder.cs b/src/WireMock.Net/RequestBuilders/IUrlAndPathRequestBuilder.cs
index a3f979a7..1c62a4f8 100644
--- a/src/WireMock.Net/RequestBuilders/IUrlAndPathRequestBuilder.cs
+++ b/src/WireMock.Net/RequestBuilders/IUrlAndPathRequestBuilder.cs
@@ -63,8 +63,8 @@ namespace WireMock.RequestBuilders
///
/// WithUrl: add url matching based on functions.
///
- /// The path func.
+ /// The url functions.
/// The .
- IRequestBuilder WithUrl([NotNull] params Func[] func);
+ IRequestBuilder WithUrl([NotNull] params Func[] funcs);
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
index 4d4689cf..2ab12e77 100644
--- a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
+++ b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs
@@ -59,7 +59,7 @@ namespace WireMock.ResponseBuilders
/// The body.
/// The Encoding.
/// A .
- [Obsolete]
+ [Obsolete("Should not be used, will be removed in future.")]
IResponseBuilder WithBodyFromBase64([NotNull] string bodyAsbase64, [CanBeNull] Encoding encoding = null);
///
diff --git a/src/WireMock.Net/ResponseBuilders/Response.cs b/src/WireMock.Net/ResponseBuilders/Response.cs
index dc21d718..48629d1e 100644
--- a/src/WireMock.Net/ResponseBuilders/Response.cs
+++ b/src/WireMock.Net/ResponseBuilders/Response.cs
@@ -173,7 +173,7 @@ namespace WireMock.ResponseBuilders
}
///
- public IResponseBuilder WithBody(byte[] body, string destination, Encoding encoding = null)
+ public IResponseBuilder WithBody(byte[] body, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null)
{
Check.NotNull(body, nameof(body));
diff --git a/src/WireMock.Net/Serialization/MappingConverter.cs b/src/WireMock.Net/Serialization/MappingConverter.cs
index 6f7d6c9b..92069cc7 100644
--- a/src/WireMock.Net/Serialization/MappingConverter.cs
+++ b/src/WireMock.Net/Serialization/MappingConverter.cs
@@ -146,15 +146,5 @@ namespace WireMock.Serialization
return newDictionary;
}
-
- //private static string[] Map([CanBeNull] IEnumerable> funcs)
- //{
- // return funcs?.Select(Map).Where(x => x != null).ToArray();
- //}
-
- //private static string Map([CanBeNull] Func func)
- //{
- // return func?.ToString();
- //}
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Server/FluentMockServer.cs b/src/WireMock.Net/Server/FluentMockServer.cs
index 732a0f4c..5dc0f1af 100644
--- a/src/WireMock.Net/Server/FluentMockServer.cs
+++ b/src/WireMock.Net/Server/FluentMockServer.cs
@@ -56,7 +56,30 @@ namespace WireMock.Server
/// Gets the scenarios.
///
[PublicAPI]
- public ConcurrentDictionary Scenarios => new ConcurrentDictionary(_options.Scenarios); // Checked
+ public ConcurrentDictionary Scenarios => new ConcurrentDictionary(_options.Scenarios);
+
+ #region IDisposable Members
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases unmanaged and - optionally - managed resources.
+ ///
+ /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_httpServer != null && _httpServer.IsStarted)
+ {
+ _httpServer.StopAsync();
+ }
+ }
+ #endregion
#region Start/Stop
///
@@ -267,17 +290,6 @@ namespace WireMock.Server
.RespondWith(new DynamicResponseProvider(request => ResponseMessageBuilder.Create("No matching mapping found", 404)));
}
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- if (_httpServer != null && _httpServer.IsStarted)
- {
- _httpServer.StopAsync();
- }
- }
-
///
/// Resets LogEntries and Mappings.
///
diff --git a/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs b/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs
index c2139cbf..50bdb6d7 100644
--- a/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs
+++ b/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs
@@ -9,9 +9,8 @@ namespace WireMock.Util
///
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
///
- ///
- ///
- public class EnhancedFileSystemWatcher : FileSystemWatcher, IDisposable
+ ///
+ public class EnhancedFileSystemWatcher : FileSystemWatcher
{
#region Private Members
// Default Watch Interval in Milliseconds
@@ -251,15 +250,5 @@ namespace WireMock.Util
}
#endregion
#endregion
-
- #region IDisposable Members
- ///
- /// Releases all resources used by the .
- ///
- public new void Dispose()
- {
- base.Dispose();
- }
- #endregion
}
}
\ No newline at end of file
diff --git a/src/WireMock.Net/Util/WireMockList.cs b/src/WireMock.Net/Util/WireMockList.cs
index 8af519b0..64812e9d 100644
--- a/src/WireMock.Net/Util/WireMockList.cs
+++ b/src/WireMock.Net/Util/WireMockList.cs
@@ -38,10 +38,7 @@ namespace WireMock.Util
///
public override string ToString()
{
- if (this != null && this.Any())
- return this.First().ToString();
-
- return base.ToString();
+ return this.Any() ? this.First().ToString() : base.ToString();
}
}
}
\ No newline at end of file