diff --git a/MbDotNet/Enums/Method.cs b/MbDotNet/Enums/Method.cs index 065f5b0..7964baa 100644 --- a/MbDotNet/Enums/Method.cs +++ b/MbDotNet/Enums/Method.cs @@ -1,5 +1,9 @@ +#pragma warning disable CS1591 namespace MbDotNet.Enums { + /// + /// HTTP Method + /// public enum Method { Get, diff --git a/MbDotNet/Enums/Protocol.cs b/MbDotNet/Enums/Protocol.cs index 65e29dd..dc20826 100644 --- a/MbDotNet/Enums/Protocol.cs +++ b/MbDotNet/Enums/Protocol.cs @@ -1,5 +1,9 @@ +#pragma warning disable CS1591 namespace MbDotNet.Enums { + /// + /// Supported network protocols for defining imposters + /// public enum Protocol { Http, diff --git a/MbDotNet/Enums/ProxyMode.cs b/MbDotNet/Enums/ProxyMode.cs index aca71e5..a338abb 100644 --- a/MbDotNet/Enums/ProxyMode.cs +++ b/MbDotNet/Enums/ProxyMode.cs @@ -1,7 +1,11 @@ using System.Runtime.Serialization; +#pragma warning disable CS1591 namespace MbDotNet.Enums { + /// + /// Mode for proxy responses + /// public enum ProxyMode { [EnumMember(Value = "proxyOnce")] diff --git a/MbDotNet/Enums/TcpMode.cs b/MbDotNet/Enums/TcpMode.cs index 0e74ab2..25f48ee 100644 --- a/MbDotNet/Enums/TcpMode.cs +++ b/MbDotNet/Enums/TcpMode.cs @@ -1,5 +1,9 @@ +#pragma warning disable CS1591 namespace MbDotNet.Enums { + /// + /// Defines the encoding used for request and response strings in TCP imposters + /// public enum TcpMode { Text, diff --git a/MbDotNet/Exceptions/ImposterNotFoundException.cs b/MbDotNet/Exceptions/ImposterNotFoundException.cs index edbb033..701c1be 100644 --- a/MbDotNet/Exceptions/ImposterNotFoundException.cs +++ b/MbDotNet/Exceptions/ImposterNotFoundException.cs @@ -8,7 +8,10 @@ namespace MbDotNet.Exceptions [Serializable] public class ImposterNotFoundException : MountebankException { + /// public ImposterNotFoundException(string message) : base(message) { } + + /// public ImposterNotFoundException(string message, Exception innerException) : base(message, innerException) { } } } diff --git a/MbDotNet/Exceptions/InvalidProtocolException.cs b/MbDotNet/Exceptions/InvalidProtocolException.cs index 9db80df..9a3b441 100644 --- a/MbDotNet/Exceptions/InvalidProtocolException.cs +++ b/MbDotNet/Exceptions/InvalidProtocolException.cs @@ -8,7 +8,10 @@ namespace MbDotNet.Exceptions [Serializable] public class InvalidProtocolException : MountebankException { + /// public InvalidProtocolException(string message) : base(message) { } + + /// public InvalidProtocolException(string message, Exception innerException) : base(message, innerException) { } } } diff --git a/MbDotNet/Exceptions/MountebankException.cs b/MbDotNet/Exceptions/MountebankException.cs index 1cecc0d..c4153d1 100644 --- a/MbDotNet/Exceptions/MountebankException.cs +++ b/MbDotNet/Exceptions/MountebankException.cs @@ -8,7 +8,10 @@ namespace MbDotNet.Exceptions [Serializable] public class MountebankException : Exception { + /// public MountebankException(string message) : base(message) { } + + /// public MountebankException(string message, Exception innerException) : base(message, innerException) { } } } diff --git a/MbDotNet/IClient.cs b/MbDotNet/IClient.cs index da75ea9..2ee7520 100644 --- a/MbDotNet/IClient.cs +++ b/MbDotNet/IClient.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; using MbDotNet.Enums; @@ -9,25 +10,26 @@ namespace MbDotNet { + /// + /// A client for interacting with the Mountebank API + /// + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "CORS is an abbreviation")] public interface IClient { /// /// A collection of all of the current imposters. The imposters in this - /// collection may or may not have been added to mountebank. See IImposter.PendingSubmission - /// for more information. + /// collection may or may not have been submitted to mountebank. /// ICollection Imposters { get; } - /// /// Get the entry hypermedia /// /// The Home object which contains entry hypermedia - Task GetEntryHypermediaAsync(CancellationToken cancellationToken = default); /// - /// Get the logs + /// Get the Mountebank server logs /// /// The list of logs Task> GetLogsAsync(CancellationToken cancellationToken = default); @@ -41,7 +43,7 @@ public interface IClient /// The port the imposter will be set up to receive requests on, or null to allow /// Mountebank to set the port. /// - /// The name the imposter will recieve, useful for debugging/logging purposes + /// The name the imposter will receive, useful for debugging/logging purposes /// /// Enables recording requests to use the imposter as a mock. See /// here for more details on Mountebank @@ -52,7 +54,7 @@ public interface IClient /// The newly created imposter HttpImposter CreateHttpImposter(int? port = null, string name = null, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false); - /// + /// /// Creates a new imposter on the specified port with the HTTPS protocol. The Submit method /// must be called on the client in order to submit the imposter to mountebank. If the port /// is blank, Mountebank will assign one which can be retrieved after Submit. @@ -61,7 +63,7 @@ public interface IClient /// The port the imposter will be set up to receive requests on, or null to allow /// Mountebank to set the port. /// - /// The name the imposter will recieve, useful for debugging/logging purposes + /// The name the imposter will receive, useful for debugging/logging purposes /// The private key the imposter will use /// The public certificate the imposer will use /// Whether or not the server requires mutual auth @@ -84,7 +86,7 @@ HttpsImposter CreateHttpsImposter(int? port = null, string name = null, string k /// The port the imposter will be set up to receive requests on, or null to allow /// Mountebank to set the port. /// - /// The name the imposter will recieve, useful for debugging/logging purposes + /// The name the imposter will receive, useful for debugging/logging purposes /// The mode of the imposter, text or binary. This defines the encoding for request/response data /// /// Enables recording requests to use the imposter as a mock. See @@ -106,7 +108,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// The port the imposter will be set up to receive requests on, or null to allow /// Mountebank to set the port. /// - /// The name the imposter will recieve, useful for debugging/logging purposes + /// The name the imposter will receive, useful for debugging/logging purposes /// /// Enables recording requests to use the imposter as a mock. See /// here for more details on Mountebank @@ -115,12 +117,10 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// The newly created imposter SmtpImposter CreateSmtpImposter(int? port = null, string name = null, bool recordRequests = false); - /// /// Retrieves the list of imposters /// /// The list of retrieved imposters - Task> GetImpostersAsync(CancellationToken cancellationToken = default); /// @@ -128,6 +128,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// imposter if mountebank is running with the "--mock" flag. /// /// The port number of the imposter to retrieve + /// /// The retrieved imposter /// Thrown if no imposter was found on the specified port. /// Thrown if the retrieved imposter was not an HTTP imposter @@ -138,6 +139,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// imposter if mountebank is running with the "--mock" flag. /// /// The port number of the imposter to retrieve + /// /// The retrieved imposter /// Thrown if no imposter was found on the specified port. /// Thrown if the retrieved imposter was not an HTTP imposter @@ -148,6 +150,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// imposter if mountebank is running with the "--mock" flag. /// /// The port number of the imposter to retrieve + /// /// The retrieved imposter /// Thrown if no imposter was found on the specified port. /// Thrown if the retrieved imposter was not an HTTP imposter @@ -158,6 +161,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// imposter if Mountebank is running with the "--mock" flag. /// /// The port number of the imposter to retrieve + /// /// The retrieved imposter /// Thrown if no imposter was found on the specified port. /// Thrown if the retrieved imposter was not an SMTP imposter @@ -168,6 +172,7 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// of imposters that the client maintains. /// /// The port number of the imposter to be removed + /// Task DeleteImposterAsync(int port, CancellationToken cancellationToken = default); /// @@ -177,23 +182,26 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode Task DeleteAllImpostersAsync(CancellationToken cancellationToken = default); /// - /// Submits all pending imposters from the supplied collection to be created in mountebank. + /// Submits all pending imposters from the supplied collection to be created in mountebank. /// Thrown if unable to create the imposter. /// /// The imposters being submitted to mountebank + /// Task SubmitAsync(ICollection imposters, CancellationToken cancellationToken = default); /// - /// Submits imposter to be created in mountebank. + /// Submits imposter to be created in mountebank. /// Thrown if unable to create the imposter. /// /// The imposter being submitted to mountebank + /// Task SubmitAsync(Imposter imposter, CancellationToken cancellationToken = default); /// /// Overwrites the stubs of an existing imposter without restarting it. /// /// The imposter to be updated with new stubs + /// /// Thrown if no imposter was found on the specified port. Task UpdateImposterAsync(Imposter imposter, CancellationToken cancellationToken = default); @@ -201,13 +209,14 @@ TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode /// Deletes previously saved requests for an imposter /// /// The port of the imposter to delete request history + /// /// Thrown if no imposter was found on the specified port. Task DeleteSavedRequestsAsync(int port, CancellationToken cancellationToken = default); /// /// Gets the configuration information of Mountebank /// - /// A Config object containing the configuration of Mountebank + /// A Config object containing the configuration of Mountebank Task GetConfigAsync(CancellationToken cancellationToken = default); } } diff --git a/MbDotNet/Models/Config.cs b/MbDotNet/Models/Config.cs index b8731d3..5e016a7 100644 --- a/MbDotNet/Models/Config.cs +++ b/MbDotNet/Models/Config.cs @@ -3,14 +3,26 @@ namespace MbDotNet.Models { + /// + /// The configuration of the Mountebank server + /// public class Config { + /// + /// The version of Mountebank that is running + /// [JsonProperty("version")] public string Version { get; set; } + /// + /// The command line options used to start Mountebank + /// [JsonProperty("options")] public Dictionary Options { get; set; } + /// + /// Information about the running Mountebank process + /// [JsonProperty("process")] public Dictionary Process { get; set; } } diff --git a/MbDotNet/Models/Imposters/HttpImposter.cs b/MbDotNet/Models/Imposters/HttpImposter.cs index ef9af65..662bac1 100644 --- a/MbDotNet/Models/Imposters/HttpImposter.cs +++ b/MbDotNet/Models/Imposters/HttpImposter.cs @@ -1,12 +1,20 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using MbDotNet.Models.Responses.Fields; using MbDotNet.Models.Stubs; using Newtonsoft.Json; namespace MbDotNet.Models.Imposters { + /// + /// An imposter using the HTTP protocol + /// + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "CORS is an abbreviation")] public class HttpImposter : Imposter { + /// + /// The stubs defined for this imposter + /// [JsonProperty("stubs")] public ICollection Stubs { get; private set; } @@ -22,6 +30,14 @@ public class HttpImposter : Imposter [JsonProperty("allowCORS")] public bool AllowCORS { get; private set; } + /// + /// Create a new HttpImposter instance + /// + /// An optional port for the imposter to listen on + /// An optional name for the imposter + /// Whether or not Mountebank should record requests made to the imposter, defaults to false + /// An optional default response for when no predicates match a request + /// Enables CORS requests, defaults to false public HttpImposter(int? port, string name, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false) : base(port, Enums.Protocol.Http, name, recordRequests) { @@ -30,6 +46,10 @@ public HttpImposter(int? port, string name, bool recordRequests = false, HttpRes AllowCORS = allowCORS; } + /// + /// Add an empty stub to this imposter + /// + /// The new stub public HttpStub AddStub() { var stub = new HttpStub(); diff --git a/MbDotNet/Models/Imposters/HttpsImposter.cs b/MbDotNet/Models/Imposters/HttpsImposter.cs index 6c9cc29..c525fdb 100644 --- a/MbDotNet/Models/Imposters/HttpsImposter.cs +++ b/MbDotNet/Models/Imposters/HttpsImposter.cs @@ -1,21 +1,38 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using MbDotNet.Models.Responses.Fields; using MbDotNet.Models.Stubs; using Newtonsoft.Json; namespace MbDotNet.Models.Imposters { + /// + /// An imposter using the HTTPS protocol + /// + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "CORS is an abbreviation")] public class HttpsImposter : Imposter { + /// + /// The stubs defined for this imposter + /// [JsonProperty("stubs")] public ICollection Stubs { get; private set; } + /// + /// An optional SSL certificate used by the imposter + /// [JsonProperty("cert", NullValueHandling = NullValueHandling.Ignore)] public string Cert { get; private set; } + /// + /// An optional SSL private key used by the imposter + /// [JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)] public string Key { get; private set; } + /// + /// The server will request a client certificate if enabled + /// [JsonProperty("mutualAuth")] public bool MutualAuthRequired { get; private set; } @@ -31,11 +48,30 @@ public class HttpsImposter : Imposter [JsonProperty("allowCORS")] public bool AllowCORS { get; private set; } + /// + /// Create a new HttpImposter instance + /// + /// An optional port for the imposter to listen on + /// An optional name for the imposter + /// Whether or not Mountebank should record requests made to the imposter, defaults to false + /// An optional default response for when no predicates match a request + /// Enables CORS requests, defaults to false public HttpsImposter(int? port, string name, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false) : this(port, name, null, null, false, recordRequests, defaultResponse, allowCORS) { } + /// + /// Create a new HttpsImposter instance + /// + /// An optional port for the imposter to listen on + /// An optional name for the imposter + /// Forces the server to request a client certificate, defaults to false + /// Whether or not Mountebank should record requests made to the imposter, defaults to false + /// An optional default response for when no predicates match a request + /// Enables CORS requests, defaults to false + /// An optional SSL private key used by the imposter + /// An optional SSL certificate used by the imposter public HttpsImposter(int? port, string name, string key, string cert, bool mutualAuthRequired, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false) : base(port, Enums.Protocol.Https, name, recordRequests) { @@ -47,6 +83,10 @@ public HttpsImposter(int? port, string name, string key, string cert, bool mutua AllowCORS = allowCORS; } + /// + /// Add an empty stub to this imposter + /// + /// The new stub public HttpStub AddStub() { var stub = new HttpStub(); diff --git a/MbDotNet/Models/Imposters/Imposter.cs b/MbDotNet/Models/Imposters/Imposter.cs index ebc2596..fa9e59e 100644 --- a/MbDotNet/Models/Imposters/Imposter.cs +++ b/MbDotNet/Models/Imposters/Imposter.cs @@ -4,6 +4,9 @@ namespace MbDotNet.Models.Imposters { + /// + /// Abstract representation of an imposter. All protocol-specific imposters derive from this type. + /// public abstract class Imposter { /// @@ -32,7 +35,7 @@ public abstract class Imposter internal void SetDynamicPort(int port) { - if (Port != default(int)) + if (Port != default) { throw new MountebankException("Cannot change imposter port once it has been set."); } @@ -40,8 +43,15 @@ internal void SetDynamicPort(int port) Port = port; } + /// + /// Create a new Imposter instance + /// + /// An optional port the imposter should be associated with + /// The network protocol of the imposter + /// An optional name for the imposter + /// Whether or not Mountebank should record requests made to the imposter [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Set as virtual for testing purposes")] - public Imposter(int? port, Protocol protocol, string name, bool recordRequests) + protected Imposter(int? port, Protocol protocol, string name, bool recordRequests) { if (port.HasValue) { diff --git a/MbDotNet/Models/Imposters/Match.cs b/MbDotNet/Models/Imposters/Match.cs index a35f91b..6254984 100644 --- a/MbDotNet/Models/Imposters/Match.cs +++ b/MbDotNet/Models/Imposters/Match.cs @@ -13,12 +13,21 @@ public class Match where TRequest : Request where TResponseFields : ResponseFields, new() { + /// + /// The request that was matched by the stub + /// [JsonProperty("request")] public TRequest Request { get; set; } + /// + /// The response returned when the stub was matched + /// [JsonProperty("response")] public TResponseFields Response { get; set; } + /// + /// When the match occurred + /// [JsonProperty("timestamp")] public string Timestamp { get; set; } } diff --git a/MbDotNet/Models/Imposters/RetrievedHttpImposter.cs b/MbDotNet/Models/Imposters/RetrievedHttpImposter.cs index 25f1ebe..0ada8c3 100644 --- a/MbDotNet/Models/Imposters/RetrievedHttpImposter.cs +++ b/MbDotNet/Models/Imposters/RetrievedHttpImposter.cs @@ -3,6 +3,9 @@ namespace MbDotNet.Models.Imposters { + /// + /// A retrieved imposter using the HTTP protocol + /// public class RetrievedHttpImposter : RetrievedImposter { diff --git a/MbDotNet/Models/Imposters/RetrievedHttpsImposter.cs b/MbDotNet/Models/Imposters/RetrievedHttpsImposter.cs index 7147325..0fd4644 100644 --- a/MbDotNet/Models/Imposters/RetrievedHttpsImposter.cs +++ b/MbDotNet/Models/Imposters/RetrievedHttpsImposter.cs @@ -4,14 +4,26 @@ namespace MbDotNet.Models.Imposters { + /// + /// A retrieved imposter using the HTTPS protocol + /// public class RetrievedHttpsImposter : RetrievedImposter { + /// + /// The configured SSL private key + /// [JsonProperty("key")] public string Key { get; internal set; } + /// + /// The configured SSL certificate + /// [JsonProperty("cert")] public string Cert { get; internal set; } + /// + /// The configured mutual auth setting + /// [JsonProperty("mutualAuth")] public bool MutualAuthRequired { get; internal set; } } diff --git a/MbDotNet/Models/Imposters/RetrievedSmtpImposter.cs b/MbDotNet/Models/Imposters/RetrievedSmtpImposter.cs index 734ffb8..4119eb1 100644 --- a/MbDotNet/Models/Imposters/RetrievedSmtpImposter.cs +++ b/MbDotNet/Models/Imposters/RetrievedSmtpImposter.cs @@ -6,6 +6,9 @@ namespace MbDotNet.Models.Imposters { + /// + /// A retrieved imposters using the SMTP protocol + /// public class RetrievedSmtpImposter : RetrievedImposter { } diff --git a/MbDotNet/Models/Imposters/RetrievedTcpImposter.cs b/MbDotNet/Models/Imposters/RetrievedTcpImposter.cs index c08f757..037dcaf 100644 --- a/MbDotNet/Models/Imposters/RetrievedTcpImposter.cs +++ b/MbDotNet/Models/Imposters/RetrievedTcpImposter.cs @@ -6,11 +6,17 @@ namespace MbDotNet.Models.Imposters { + /// + /// A retrieved imposter using the TCP protocol + /// public class RetrievedTcpImposter : RetrievedImposter { [JsonProperty("mode")] internal string RawMode { get; set; } + /// + /// The configured encoding for request and response strings + /// public TcpMode Mode => string.Equals(RawMode, "text", StringComparison.CurrentCultureIgnoreCase) ? TcpMode.Text : TcpMode.Binary; } } diff --git a/MbDotNet/Models/Imposters/SmtpImposter.cs b/MbDotNet/Models/Imposters/SmtpImposter.cs index dc63bbe..c334f36 100644 --- a/MbDotNet/Models/Imposters/SmtpImposter.cs +++ b/MbDotNet/Models/Imposters/SmtpImposter.cs @@ -4,8 +4,17 @@ namespace MbDotNet.Models.Imposters { + /// + /// An imposter using the SMTP protocol + /// public class SmtpImposter : Imposter { + /// + /// Create a new SmtpImposter instance + /// + /// An optional port for the imposter to listen on + /// An optional name for the imposter + /// Whether or not Mountebank should record requests made to the imposter, defaults to false public SmtpImposter(int? port, string name, bool recordRequests = false) : base(port, Enums.Protocol.Smtp, name, recordRequests) { diff --git a/MbDotNet/Models/Imposters/TcpImposter.cs b/MbDotNet/Models/Imposters/TcpImposter.cs index fcfe576..7740f35 100644 --- a/MbDotNet/Models/Imposters/TcpImposter.cs +++ b/MbDotNet/Models/Imposters/TcpImposter.cs @@ -6,11 +6,20 @@ namespace MbDotNet.Models.Imposters { + /// + /// An imposter using the TCP protocol + /// public class TcpImposter : Imposter { + /// + /// The stubs defined for this imposter + /// [JsonProperty("stubs")] public ICollection Stubs { get; private set; } + /// + /// The encoding used for request and response strings + /// [JsonProperty("mode")] public string Mode { get; private set; } @@ -20,6 +29,14 @@ public class TcpImposter : Imposter [JsonProperty("defaultResponse", NullValueHandling = NullValueHandling.Ignore)] public TcpResponseFields DefaultResponse { get; private set; } + /// + /// Create a new TcpImposter instance + /// + /// An optional port for the imposter to listen on + /// An optional name for the imposter + /// The encoding used for request and response strings + /// Whether or not Mountebank should record requests made to the imposter, defaults to false + /// An optional default response for when no predicates match a request public TcpImposter(int? port, string name, TcpMode mode, bool recordRequests = false, TcpResponseFields defaultResponse = null) : base(port, Enums.Protocol.Tcp, name, recordRequests) { @@ -28,6 +45,10 @@ public TcpImposter(int? port, string name, TcpMode mode, bool recordRequests = f DefaultResponse = defaultResponse; } + /// + /// Add an empty stub to this imposter + /// + /// The new stub public TcpStub AddStub() { var stub = new TcpStub(); diff --git a/MbDotNet/Models/Predicates/AndPredicate.cs b/MbDotNet/Models/Predicates/AndPredicate.cs index 281bb2d..3b430a1 100644 --- a/MbDotNet/Models/Predicates/AndPredicate.cs +++ b/MbDotNet/Models/Predicates/AndPredicate.cs @@ -3,11 +3,21 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "and" predicate + /// public class AndPredicate : PredicateBase { + /// + /// The predicates that are being combined + /// [JsonProperty("and")] public IEnumerable Predicates { get; private set; } + /// + /// Create a new AndPredicate instance + /// + /// The predicates that are being combined public AndPredicate(IEnumerable predicates) { Predicates = predicates; diff --git a/MbDotNet/Models/Predicates/ContainsPredicate.cs b/MbDotNet/Models/Predicates/ContainsPredicate.cs index 78b7085..7152d3e 100644 --- a/MbDotNet/Models/Predicates/ContainsPredicate.cs +++ b/MbDotNet/Models/Predicates/ContainsPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "contains" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class ContainsPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("contains")] public T Fields { get; private set; } + /// + /// Create a new ContainsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public ContainsPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/DeepEqualsPredicate.cs b/MbDotNet/Models/Predicates/DeepEqualsPredicate.cs index c2e626e..db653ad 100644 --- a/MbDotNet/Models/Predicates/DeepEqualsPredicate.cs +++ b/MbDotNet/Models/Predicates/DeepEqualsPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "deepEquals" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class DeepEqualsPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("deepEquals")] public T Fields { get; private set; } + /// + /// Create a new DeepEqualsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public DeepEqualsPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/EndsWithPredicate.cs b/MbDotNet/Models/Predicates/EndsWithPredicate.cs index 7d49844..e74bfa6 100644 --- a/MbDotNet/Models/Predicates/EndsWithPredicate.cs +++ b/MbDotNet/Models/Predicates/EndsWithPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "endsWith" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class EndsWithPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("endsWith")] public T Fields { get; private set; } + /// + /// Create a new EndsWithPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public EndsWithPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/EqualsPredicate.cs b/MbDotNet/Models/Predicates/EqualsPredicate.cs index e8d812e..629d195 100644 --- a/MbDotNet/Models/Predicates/EqualsPredicate.cs +++ b/MbDotNet/Models/Predicates/EqualsPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "contains" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class EqualsPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("equals")] public T Fields { get; private set; } + /// + /// Create a new EqualsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public EqualsPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/ExistsPredicate.cs b/MbDotNet/Models/Predicates/ExistsPredicate.cs index f7365e8..175c2ea 100644 --- a/MbDotNet/Models/Predicates/ExistsPredicate.cs +++ b/MbDotNet/Models/Predicates/ExistsPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "exists" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class ExistsPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("exists")] public T Fields { get; private set; } + /// + /// Create a new ExistsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public ExistsPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/Fields/HttpBooleanPredicateFields.cs b/MbDotNet/Models/Predicates/Fields/HttpBooleanPredicateFields.cs index fcd2717..b4c8e79 100644 --- a/MbDotNet/Models/Predicates/Fields/HttpBooleanPredicateFields.cs +++ b/MbDotNet/Models/Predicates/Fields/HttpBooleanPredicateFields.cs @@ -4,6 +4,9 @@ namespace MbDotNet.Models.Predicates.Fields { + /// + /// Used to specify which HTTP predicate fields should be generated for proxy predicates + /// public class HttpBooleanPredicateFields : PredicateFields { /// diff --git a/MbDotNet/Models/Predicates/Fields/HttpPredicateFields.cs b/MbDotNet/Models/Predicates/Fields/HttpPredicateFields.cs index 008175a..196db1b 100644 --- a/MbDotNet/Models/Predicates/Fields/HttpPredicateFields.cs +++ b/MbDotNet/Models/Predicates/Fields/HttpPredicateFields.cs @@ -4,6 +4,9 @@ namespace MbDotNet.Models.Predicates.Fields { + /// + /// Predicate fields for predicates on HTTP imposters + /// public class HttpPredicateFields : PredicateFields { /// @@ -19,10 +22,8 @@ public class HttpPredicateFields : PredicateFields public object RequestBody { get; set; } /// - /// Form-encoded key-value pairs in the body. - /// Supports key-specific predicates. - /// For example, with a body of "firstname=bob&lastname=smith", you - /// could set a predicate on just "lastname". + /// Form-encoded key-value pairs in the body. + /// Supports key-specific predicates. /// [JsonProperty("form", NullValueHandling = NullValueHandling.Ignore)] public Dictionary FormContent { get; set; } diff --git a/MbDotNet/Models/Predicates/Fields/PredicateFields.cs b/MbDotNet/Models/Predicates/Fields/PredicateFields.cs index 07713dc..190184f 100644 --- a/MbDotNet/Models/Predicates/Fields/PredicateFields.cs +++ b/MbDotNet/Models/Predicates/Fields/PredicateFields.cs @@ -1,5 +1,8 @@ namespace MbDotNet.Models.Predicates.Fields { + /// + /// Abstract representation of predicate fields with no specific protocol + /// public abstract class PredicateFields { } diff --git a/MbDotNet/Models/Predicates/Fields/TcpBooleanPredicateFields.cs b/MbDotNet/Models/Predicates/Fields/TcpBooleanPredicateFields.cs index 390e9da..36498ac 100644 --- a/MbDotNet/Models/Predicates/Fields/TcpBooleanPredicateFields.cs +++ b/MbDotNet/Models/Predicates/Fields/TcpBooleanPredicateFields.cs @@ -2,6 +2,9 @@ namespace MbDotNet.Models.Predicates.Fields { + /// + /// Used to specify which TCP predicate fields should be generated for proxy predicates + /// public class TcpBooleanPredicateFields : PredicateFields { /// diff --git a/MbDotNet/Models/Predicates/Fields/TcpPredicateFields.cs b/MbDotNet/Models/Predicates/Fields/TcpPredicateFields.cs index 69cf8da..61d58a2 100644 --- a/MbDotNet/Models/Predicates/Fields/TcpPredicateFields.cs +++ b/MbDotNet/Models/Predicates/Fields/TcpPredicateFields.cs @@ -2,6 +2,9 @@ namespace MbDotNet.Models.Predicates.Fields { + /// + /// Predicate fields for predicates on TCP imposters + /// public class TcpPredicateFields : PredicateFields { /// diff --git a/MbDotNet/Models/Predicates/InjectPredicate.cs b/MbDotNet/Models/Predicates/InjectPredicate.cs index 4d326d4..3109212 100644 --- a/MbDotNet/Models/Predicates/InjectPredicate.cs +++ b/MbDotNet/Models/Predicates/InjectPredicate.cs @@ -2,11 +2,23 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "inject" predicate + /// public class InjectPredicate : PredicateBase { + /// + /// A javascript function that is run to determine whether to match a stub. + /// The function should take a single request object that will contain the request, an + /// empty state object to share with response injectors, and a logger. + /// [JsonProperty("inject")] public string InjectedFunction { get; private set; } + /// + /// Create a new InjectPredicate instance + /// + /// A javascript function that is run to determine whether to match a stub public InjectPredicate(string injectedFunction) { InjectedFunction = injectedFunction; diff --git a/MbDotNet/Models/Predicates/JsonPathSelector.cs b/MbDotNet/Models/Predicates/JsonPathSelector.cs index 0f2369e..7d88e29 100644 --- a/MbDotNet/Models/Predicates/JsonPathSelector.cs +++ b/MbDotNet/Models/Predicates/JsonPathSelector.cs @@ -3,11 +3,21 @@ namespace MbDotNet.Models.Predicates { + /// + /// A jsonpath selector + /// public class JsonPathSelector { + /// + /// A jsonpath selector + /// [JsonProperty("selector", NullValueHandling = NullValueHandling.Ignore)] public string Selector { get; private set; } + /// + /// Create a new JsonPathSelector instance + /// + /// A jsonpath selector public JsonPathSelector(string selector) { Selector = selector; diff --git a/MbDotNet/Models/Predicates/MatchesPredicate.cs b/MbDotNet/Models/Predicates/MatchesPredicate.cs index d8d36cb..36c28c0 100644 --- a/MbDotNet/Models/Predicates/MatchesPredicate.cs +++ b/MbDotNet/Models/Predicates/MatchesPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "matches" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class MatchesPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("matches")] public T Fields { get; private set; } + /// + /// Create a new ContainsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public MatchesPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/NotPredicate.cs b/MbDotNet/Models/Predicates/NotPredicate.cs index 2504968..d11cfd9 100644 --- a/MbDotNet/Models/Predicates/NotPredicate.cs +++ b/MbDotNet/Models/Predicates/NotPredicate.cs @@ -2,11 +2,21 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "not" predicate + /// public class NotPredicate : PredicateBase { + /// + /// The predicate that is being negated + /// [JsonProperty("not")] public PredicateBase ChildPredicate { get; private set; } + /// + /// Create a new NotPredicate instance + /// + /// The predicate that is being negated public NotPredicate(PredicateBase childPredicate) { ChildPredicate = childPredicate; diff --git a/MbDotNet/Models/Predicates/OrPredicate.cs b/MbDotNet/Models/Predicates/OrPredicate.cs index 5923c11..3245354 100644 --- a/MbDotNet/Models/Predicates/OrPredicate.cs +++ b/MbDotNet/Models/Predicates/OrPredicate.cs @@ -3,11 +3,21 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "or" predicate + /// public class OrPredicate : PredicateBase { + /// + /// The predicates that are being combined + /// [JsonProperty("or")] public IEnumerable Predicates { get; private set; } + /// + /// Create a new OrPredicate instance + /// + /// The predicates that are being combined public OrPredicate(IEnumerable predicates) { Predicates = predicates; diff --git a/MbDotNet/Models/Predicates/PredicateBase.cs b/MbDotNet/Models/Predicates/PredicateBase.cs index f41d793..0d3b195 100644 --- a/MbDotNet/Models/Predicates/PredicateBase.cs +++ b/MbDotNet/Models/Predicates/PredicateBase.cs @@ -2,23 +2,48 @@ namespace MbDotNet.Models.Predicates { + /// + /// An abstract representation of a predicate + /// public abstract class PredicateBase { + /// + /// Whether or not the predicate should be case sensitive when performing matches + /// [JsonProperty("caseSensitive", NullValueHandling = NullValueHandling.Ignore)] public bool IsCaseSensitive { get; private set; } + /// + /// A regular expression to strip out of the request field before matching + /// [JsonProperty("except", NullValueHandling = NullValueHandling.Ignore)] public string ExceptExpression { get; private set; } + /// + /// A xpath selector to narrow the value being matched + /// [JsonProperty("xpath", NullValueHandling = NullValueHandling.Ignore)] public XPathSelector XPathSelector { get; private set; } + /// + /// A jsonpath selector to narrow the value being matched + /// [JsonProperty("jsonpath", NullValueHandling = NullValueHandling.Ignore)] public JsonPathSelector JsonPathSelector { get; private set; } - public PredicateBase() { } + /// + /// Create a new PredicateBase instance + /// + protected PredicateBase() { } - public PredicateBase(bool isCaseSensitive, string exceptExpression, XPathSelector xpath, JsonPathSelector jsonpath) + /// + /// Create a new PredicateBase instance + /// + /// Whether or not predicate matching is case sensitive + /// A regular expression for eliminating parts of a predicate value + /// A xpath selector for narrowing the predicate value + /// A jsonpath selector for narrowing the predicate value + protected PredicateBase(bool isCaseSensitive, string exceptExpression, XPathSelector xpath, JsonPathSelector jsonpath) { IsCaseSensitive = isCaseSensitive; ExceptExpression = exceptExpression; diff --git a/MbDotNet/Models/Predicates/StartsWithPredicate.cs b/MbDotNet/Models/Predicates/StartsWithPredicate.cs index 9cf5cbb..74d1064 100644 --- a/MbDotNet/Models/Predicates/StartsWithPredicate.cs +++ b/MbDotNet/Models/Predicates/StartsWithPredicate.cs @@ -3,11 +3,26 @@ namespace MbDotNet.Models.Predicates { + /// + /// A "startsWith" predicate + /// + /// The type of predicate fields based on the imposter type the predicate is added to public class StartsWithPredicate : PredicateBase where T : PredicateFields { + /// + /// The predicate fields to match on + /// [JsonProperty("startsWith")] public T Fields { get; private set; } + /// + /// Create a new ContainsPredicate instance + /// + /// The predicate fields to match on + /// Whether matches should be case sensitive, defaults to false + /// A regular expression to strip out of the request field before matching + /// An optional xpath selector to narrow the value being matched + /// An optional jsonpath selector to narrow the value being matched public StartsWithPredicate(T fields, bool isCaseSensitive = false, string exceptExpression = null, XPathSelector xpath = null, JsonPathSelector jsonpath = null) : base(isCaseSensitive, exceptExpression, xpath, jsonpath) diff --git a/MbDotNet/Models/Predicates/XPathSelector.cs b/MbDotNet/Models/Predicates/XPathSelector.cs index ca49003..c59bd7e 100644 --- a/MbDotNet/Models/Predicates/XPathSelector.cs +++ b/MbDotNet/Models/Predicates/XPathSelector.cs @@ -3,17 +3,29 @@ namespace MbDotNet.Models.Predicates { + /// + /// A xpath selector + /// public class XPathSelector { + /// + /// A xpath selector + /// [JsonProperty("selector", NullValueHandling = NullValueHandling.Ignore)] public string Selector { get; private set; } + /// + /// The xpath namespace map + /// [JsonProperty("ns", NullValueHandling = NullValueHandling.Ignore)] public IDictionary Namespaces { get; private set; } - public XPathSelector(string selector) : this(selector, null) { } - - public XPathSelector(string selector, IDictionary namespaces) + /// + /// Create a new XPathSelector instance + /// + /// A xpath selector + /// The xpath namespace map + public XPathSelector(string selector, IDictionary namespaces = null) { Selector = selector; Namespaces = namespaces; diff --git a/MbDotNet/Models/Requests/EmailAddress.cs b/MbDotNet/Models/Requests/EmailAddress.cs index c400658..afced45 100644 --- a/MbDotNet/Models/Requests/EmailAddress.cs +++ b/MbDotNet/Models/Requests/EmailAddress.cs @@ -5,11 +5,20 @@ namespace MbDotNet.Models.Requests { + /// + /// An email address + /// public class EmailAddress { + /// + /// An email address + /// [JsonProperty("address")] public string Address { get; set; } + /// + /// A name associated with the email address + /// [JsonProperty("name")] public string Name { get; set; } } diff --git a/MbDotNet/Models/Requests/EmailAttachment.cs b/MbDotNet/Models/Requests/EmailAttachment.cs index 4031bcf..985dfcb 100644 --- a/MbDotNet/Models/Requests/EmailAttachment.cs +++ b/MbDotNet/Models/Requests/EmailAttachment.cs @@ -5,20 +5,38 @@ namespace MbDotNet.Models.Requests { + /// + /// An email attachment + /// public class EmailAttachment { + /// + /// The type of the attachment + /// [JsonProperty("type")] public string Type { get; internal set; } + /// + /// The content type of the attachment + /// [JsonProperty("contentType")] public string ContentType { get; internal set; } + /// + /// The content of the attachment + /// [JsonProperty("content")] public EmailContent Content { get; internal set; } + /// + /// The content disposition of the attachment + /// [JsonProperty("contentDisposition")] public string ContentDisposition { get; internal set; } + /// + /// The size of the attachment + /// [JsonProperty("size")] public long Size { get; internal set; } } diff --git a/MbDotNet/Models/Requests/EmailContent.cs b/MbDotNet/Models/Requests/EmailContent.cs index 3cdb271..837f009 100644 --- a/MbDotNet/Models/Requests/EmailContent.cs +++ b/MbDotNet/Models/Requests/EmailContent.cs @@ -5,11 +5,20 @@ namespace MbDotNet.Models.Requests { + /// + /// Content of an email attachment + /// public class EmailContent { + /// + /// The type of the content + /// [JsonProperty("type")] public string Type { get; internal set; } + /// + /// The binary data of the content + /// [JsonProperty("data")] public byte[] Data { get; internal set; } } diff --git a/MbDotNet/Models/Requests/HttpRequest.cs b/MbDotNet/Models/Requests/HttpRequest.cs index f079934..c7f93f7 100644 --- a/MbDotNet/Models/Requests/HttpRequest.cs +++ b/MbDotNet/Models/Requests/HttpRequest.cs @@ -5,23 +5,44 @@ namespace MbDotNet.Models.Requests { + /// + /// A request in the HTTP protocol + /// public class HttpRequest : Request { + /// + /// The path of the request, without the querystring + /// [JsonProperty("path")] public string Path { get; internal set; } + /// + /// The request body + /// [JsonProperty("body")] public string Body { get; internal set; } + /// + /// The request method + /// [JsonProperty("method")] public Method Method { get; internal set; } + /// + /// When the request was made + /// [JsonProperty("timestamp")] public DateTime Timestamp { get; internal set; } + /// + /// The querystring of the request + /// [JsonProperty("query")] public Dictionary QueryParameters { get; internal set; } + /// + /// The HTTP headers + /// [JsonProperty("headers")] public Dictionary Headers { get; internal set; } } diff --git a/MbDotNet/Models/Requests/Request.cs b/MbDotNet/Models/Requests/Request.cs index bb85dc7..6c3be21 100644 --- a/MbDotNet/Models/Requests/Request.cs +++ b/MbDotNet/Models/Requests/Request.cs @@ -2,8 +2,14 @@ namespace MbDotNet.Models.Requests { + /// + /// An abstract representation of a request without a specific protocol + /// public abstract class Request { + /// + /// The client socket, primarily used for logging and debugging + /// [JsonProperty("requestFrom")] public string RequestFrom { get; set; } } diff --git a/MbDotNet/Models/Requests/SmtpRequest.cs b/MbDotNet/Models/Requests/SmtpRequest.cs index e88c196..b01714e 100644 --- a/MbDotNet/Models/Requests/SmtpRequest.cs +++ b/MbDotNet/Models/Requests/SmtpRequest.cs @@ -5,41 +5,80 @@ namespace MbDotNet.Models.Requests { + /// + /// A request in the SMTP protocol + /// public class SmtpRequest : Request { + /// + /// The from address sent in the MAIL command + /// [JsonProperty("envelopeFrom")] public string EnvelopeFrom { get; internal set; } + /// + /// The address sent using the RCPT command + /// [JsonProperty("envelopeTo")] public IList EnvelopeTo { get; internal set; } + /// + /// The sender of the message + /// [JsonProperty("from")] public EmailAddress From { get; internal set; } + /// + /// The recipients of the message + /// [JsonProperty("to")] public IList To { get; internal set; } + /// + /// The CC recipients of the message + /// [JsonProperty("cc")] public IList Cc { get; internal set; } + /// + /// The BCC recipients of the message + /// [JsonProperty("bcc")] public IList Bcc { get; internal set; } + /// + /// The subject of the message + /// [JsonProperty("subject")] public string Subject { get; internal set; } + /// + /// The priority of the message + /// [JsonProperty("priority")] public string Priority { get; internal set; } + /// + /// The in reply to of the message + /// [JsonProperty("inReplyTo")] public IList InReplyTo { get; internal set; } + /// + /// The text-only message + /// [JsonProperty("text")] public string Text { get; internal set; } + /// + /// The html message + /// [JsonProperty("html")] public string Html { get; internal set; } + /// + /// The message attachments + /// [JsonProperty("attachments")] public IList Attachments { get; internal set; } } diff --git a/MbDotNet/Models/Requests/TcpRequest.cs b/MbDotNet/Models/Requests/TcpRequest.cs index c0ba248..ae9cff6 100644 --- a/MbDotNet/Models/Requests/TcpRequest.cs +++ b/MbDotNet/Models/Requests/TcpRequest.cs @@ -2,8 +2,14 @@ namespace MbDotNet.Models.Requests { + /// + /// A request in the TCP protcol + /// public class TcpRequest : Request { + /// + /// The data in the request + /// [JsonProperty("data")] public string Data { get; internal set; } } diff --git a/MbDotNet/Models/Responses/Behavior.cs b/MbDotNet/Models/Responses/Behavior.cs index eedb3cb..75b0570 100644 --- a/MbDotNet/Models/Responses/Behavior.cs +++ b/MbDotNet/Models/Responses/Behavior.cs @@ -2,8 +2,14 @@ namespace MbDotNet.Models.Responses { + /// + /// A "behavior" response + /// public class Behavior { + /// + /// The latency to add to the response + /// [JsonProperty("wait", NullValueHandling = NullValueHandling.Ignore)] public int? LatencyInMilliseconds { get; set; } } diff --git a/MbDotNet/Models/Responses/Fields/HttpResponseFields.cs b/MbDotNet/Models/Responses/Fields/HttpResponseFields.cs index 51c9eb2..9476d59 100644 --- a/MbDotNet/Models/Responses/Fields/HttpResponseFields.cs +++ b/MbDotNet/Models/Responses/Fields/HttpResponseFields.cs @@ -4,17 +4,32 @@ namespace MbDotNet.Models.Responses.Fields { + /// + /// Response fields that can be set for HTTP requests + /// public class HttpResponseFields : ResponseFields { + /// + /// The HTTP status code of the response + /// [JsonProperty("statusCode", NullValueHandling = NullValueHandling.Ignore)] public HttpStatusCode? StatusCode { get; set; } + /// + /// The body of the response + /// [JsonProperty("body", NullValueHandling = NullValueHandling.Ignore)] public object ResponseObject { get; set; } + /// + /// The HTTP headers + /// [JsonProperty("headers", NullValueHandling = NullValueHandling.Ignore)] public IDictionary Headers { get; set; } + /// + /// The mode of the response, "text" (default) or "binary" + /// [JsonProperty("_mode", NullValueHandling = NullValueHandling.Ignore)] public string Mode { get; set; } } diff --git a/MbDotNet/Models/Responses/Fields/ProxyResponseFields.cs b/MbDotNet/Models/Responses/Fields/ProxyResponseFields.cs index 426a581..d29843a 100644 --- a/MbDotNet/Models/Responses/Fields/ProxyResponseFields.cs +++ b/MbDotNet/Models/Responses/Fields/ProxyResponseFields.cs @@ -9,15 +9,28 @@ namespace MbDotNet.Models.Responses.Fields { + /// + /// Response fields for configuring a "proxy" response + /// + /// public class ProxyResponseFields : ResponseFields where T : PredicateFields { + /// + /// The origin server that the request should proxy to + /// [JsonProperty("to", NullValueHandling = NullValueHandling.Ignore)] public Uri To { get; set; } + /// + /// The replay behavior of the proxy + /// [JsonProperty("mode", NullValueHandling = NullValueHandling.Ignore)] [JsonConverter(typeof(StringEnumConverter))] public ProxyMode Mode { get; set; } + /// + /// An array of objects that defines how the predicates for new stubs are created + /// [JsonProperty("predicateGenerators", NullValueHandling = NullValueHandling.Ignore)] public IList> PredicateGenerators { get; set; } } diff --git a/MbDotNet/Models/Responses/Fields/ResponseFields.cs b/MbDotNet/Models/Responses/Fields/ResponseFields.cs index 7ccee6c..8191f8f 100644 --- a/MbDotNet/Models/Responses/Fields/ResponseFields.cs +++ b/MbDotNet/Models/Responses/Fields/ResponseFields.cs @@ -1,5 +1,8 @@ namespace MbDotNet.Models.Responses.Fields { + /// + /// An abstract representation of response fields without a specific protocol + /// public abstract class ResponseFields { } diff --git a/MbDotNet/Models/Responses/Fields/SmtpResponseFields.cs b/MbDotNet/Models/Responses/Fields/SmtpResponseFields.cs index dcf61f9..e3e500c 100644 --- a/MbDotNet/Models/Responses/Fields/SmtpResponseFields.cs +++ b/MbDotNet/Models/Responses/Fields/SmtpResponseFields.cs @@ -4,6 +4,9 @@ namespace MbDotNet.Models.Responses.Fields { + /// + /// Response fields that can be set for SMTP requests + /// public class SmtpResponseFields : ResponseFields { } diff --git a/MbDotNet/Models/Responses/Fields/TcpResponseFields.cs b/MbDotNet/Models/Responses/Fields/TcpResponseFields.cs index b7f0c8d..8c36cfe 100644 --- a/MbDotNet/Models/Responses/Fields/TcpResponseFields.cs +++ b/MbDotNet/Models/Responses/Fields/TcpResponseFields.cs @@ -2,6 +2,9 @@ namespace MbDotNet.Models.Responses.Fields { + /// + /// Response fields that can be set for TCP requests + /// public class TcpResponseFields : ResponseFields { /// diff --git a/MbDotNet/Models/Responses/Home.cs b/MbDotNet/Models/Responses/Home.cs index 64087fe..9148ccc 100644 --- a/MbDotNet/Models/Responses/Home.cs +++ b/MbDotNet/Models/Responses/Home.cs @@ -3,30 +3,53 @@ namespace MbDotNet.Models.Responses { + /// + /// The base response from the Mountebank server + /// public class Home { + /// + /// Links to various information about the Mountebank server + /// [JsonProperty("_links")] public Link Links { get; internal set; } } + /// + /// Set of links to information about the Mountebank server + /// public class Link { + /// + /// Link to the configured imposters + /// [JsonProperty("imposters")] public HrefField Imposters { get; internal set; } + + /// + /// Link to the server configuration + /// [JsonProperty("config")] public HrefField Config { get; internal set; } + + /// + /// Link to the server logs + /// [JsonProperty("logs")] public HrefField Logs { get; internal set; } - } + /// + /// An href + /// public class HrefField { + /// + /// An href + /// [JsonProperty("href")] public string Href { get; internal set; } - - } } diff --git a/MbDotNet/Models/Responses/IsResponse.cs b/MbDotNet/Models/Responses/IsResponse.cs index 5a3c833..f7d2d60 100644 --- a/MbDotNet/Models/Responses/IsResponse.cs +++ b/MbDotNet/Models/Responses/IsResponse.cs @@ -3,14 +3,29 @@ namespace MbDotNet.Models.Responses { + /// + /// A "is" response + /// + /// public class IsResponse : ResponseBase where T : ResponseFields, new() { + /// + /// Response fields to return when matched + /// [JsonProperty("is")] public T Fields { get; set; } + /// + /// Configured response behaviors + /// [JsonProperty("_behaviors", NullValueHandling = NullValueHandling.Ignore)] public Behavior Behavior { get; set; } + /// + /// Create a new IsResponse instance + /// + /// The fields to return when matched + /// Optional response behavior public IsResponse(T fields, Behavior behavior = null) { Fields = fields; diff --git a/MbDotNet/Models/Responses/Log.cs b/MbDotNet/Models/Responses/Log.cs index 48c41a4..7148d80 100644 --- a/MbDotNet/Models/Responses/Log.cs +++ b/MbDotNet/Models/Responses/Log.cs @@ -3,14 +3,26 @@ namespace MbDotNet.Models.Responses { + /// + /// A Mountebank server log + /// public class Log { + /// + /// The log level + /// [JsonProperty("level")] public string Level { get; internal set; } + /// + /// The log message + /// [JsonProperty("message")] public string Message { get; internal set; } + /// + /// When the log was recorded + /// [JsonProperty("Timestamp")] public DateTime Timestamp { get; internal set; } } diff --git a/MbDotNet/Models/Responses/ProxyResponse.cs b/MbDotNet/Models/Responses/ProxyResponse.cs index 9bf5a9a..c4bf783 100644 --- a/MbDotNet/Models/Responses/ProxyResponse.cs +++ b/MbDotNet/Models/Responses/ProxyResponse.cs @@ -3,11 +3,22 @@ namespace MbDotNet.Models.Responses { + /// + /// A "proxy" response for record/replay behavior + /// + /// public class ProxyResponse : ResponseBase where T : ResponseFields, new() { + /// + /// The fields that should be captured for generated predicates + /// [JsonProperty("proxy")] public T Fields { get; set; } + /// + /// Create a new ProxyResponse instance + /// + /// The fields that should be captured for generated predicates public ProxyResponse(T fields) { Fields = fields; diff --git a/MbDotNet/Models/Responses/ResponseBase.cs b/MbDotNet/Models/Responses/ResponseBase.cs index c5ebda1..5607efc 100644 --- a/MbDotNet/Models/Responses/ResponseBase.cs +++ b/MbDotNet/Models/Responses/ResponseBase.cs @@ -1,5 +1,8 @@ namespace MbDotNet.Models.Responses { + /// + /// An abstract representation of a response without a specific protocol + /// public abstract class ResponseBase { } diff --git a/MbDotNet/Models/Stubs/HttpStub.cs b/MbDotNet/Models/Stubs/HttpStub.cs index c5a350e..22903f2 100644 --- a/MbDotNet/Models/Stubs/HttpStub.cs +++ b/MbDotNet/Models/Stubs/HttpStub.cs @@ -12,6 +12,9 @@ namespace MbDotNet.Models.Stubs { + /// + /// A HTTP imposter stub + /// public class HttpStub : StubBase { @@ -74,7 +77,7 @@ public HttpStub ReturnsXml(HttpStatusCode statusCode, T responseObject) /// /// Adds a response to the stub that will return the specified HTTP status code - /// along with a response object serialized as XML. Automatically adds an appropriate + /// along with a response object serialized as XML. Automatically adds an appropriate /// Content-Type header to the response. Serializes the XML with the specified encoding. /// /// The type of the response object being serialized diff --git a/MbDotNet/Models/Stubs/RetrievedStub.cs b/MbDotNet/Models/Stubs/RetrievedStub.cs index 7b1eca0..afaa8ce 100644 --- a/MbDotNet/Models/Stubs/RetrievedStub.cs +++ b/MbDotNet/Models/Stubs/RetrievedStub.cs @@ -21,6 +21,9 @@ public class RetrievedStub [JsonProperty("matches", NullValueHandling = NullValueHandling.Ignore)] public ICollection> Matches { get; set; } + /// + /// Create a new RetrievedStub instance + /// public RetrievedStub() { Matches = new List>(); diff --git a/MbDotNet/Models/Stubs/StubBase.cs b/MbDotNet/Models/Stubs/StubBase.cs index 8021950..19a30ff 100644 --- a/MbDotNet/Models/Stubs/StubBase.cs +++ b/MbDotNet/Models/Stubs/StubBase.cs @@ -5,6 +5,9 @@ namespace MbDotNet.Models.Stubs { + /// + /// An abstract representation of a stub without a specific protocol + /// public abstract class StubBase { /// @@ -19,6 +22,9 @@ public abstract class StubBase [JsonProperty("responses", NullValueHandling = NullValueHandling.Ignore)] public ICollection Responses { get; set; } + /// + /// Create a new StubBase instance + /// protected StubBase() { Responses = new List(); diff --git a/MbDotNet/Models/Stubs/TcpStub.cs b/MbDotNet/Models/Stubs/TcpStub.cs index 0e3daac..b109d54 100644 --- a/MbDotNet/Models/Stubs/TcpStub.cs +++ b/MbDotNet/Models/Stubs/TcpStub.cs @@ -8,6 +8,9 @@ namespace MbDotNet.Models.Stubs { + /// + /// A TCP imposter stub + /// public class TcpStub : StubBase { diff --git a/MbDotNet/MountebankClient.cs b/MbDotNet/MountebankClient.cs index 0454c42..5cb5a6e 100644 --- a/MbDotNet/MountebankClient.cs +++ b/MbDotNet/MountebankClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text.RegularExpressions; using System.Threading; @@ -14,17 +15,24 @@ namespace MbDotNet { + /// + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "CORS is an abbreviation")] public class MountebankClient : IClient { private readonly IRequestProxy _requestProxy; - /// - /// A collection of all of the submitted imposters. - /// + /// public ICollection Imposters { get; private set; } + /// + /// Create a new MountebankClient instance for a server at the default address of http://127.0.0.1:2525 + /// public MountebankClient() : this(new MountebankRequestProxy()) { } + /// + /// Create a new MountebankClient instance for a specific server URL + /// + /// public MountebankClient(string mountebankUrl) : this(new MountebankRequestProxy(mountebankUrl)) { } internal MountebankClient(IRequestProxy requestProxy) @@ -33,54 +41,25 @@ internal MountebankClient(IRequestProxy requestProxy) _requestProxy = requestProxy; } + /// public async Task GetEntryHypermediaAsync(CancellationToken cancellationToken = default) { return await _requestProxy.GetEntryHypermediaAsync(cancellationToken).ConfigureAwait(false); } + /// public async Task> GetLogsAsync(CancellationToken cancellationToken = default) { return await _requestProxy.GetLogsAsync(cancellationToken).ConfigureAwait(false); } - /// - /// Creates a new imposter on the specified port with the HTTP protocol. The Submit method - /// must be called on the client in order to submit the imposter to mountebank. - /// - /// The port the imposter will be set up to receive requests on - /// The name the imposter will recieve, useful for debugging/logging purposes - /// - /// Enables recording requests to use the imposter as a mock. See - /// here for more details on Mountebank - /// verification. - /// - /// The default response to send if no predicate matches - /// Will allow all CORS preflight requests if set to true - /// The newly created imposter + /// public HttpImposter CreateHttpImposter(int? port = null, string name = null, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false) { return new HttpImposter(port, name, recordRequests, defaultResponse, allowCORS); } - /// - /// Creates a new imposter on the specified port with the HTTPS protocol. The Submit method - /// must be called on the client in order to submit the imposter to mountebank. - /// - /// The key and cert parameters MUST be valid PEM-formatted strings. - /// - /// The port the imposter will be set up to receive requests on - /// The name the imposter will recieve, useful for debugging/logging purposes - /// The private key the imposter will use, MUST be a PEM-formatted string - /// The public certificate the imposer will use, MUST be a PEM-formatted string - /// Whether or not the server will require mutual auth - /// - /// Enables recording requests to use the imposter as a mock. See - /// here for more details on Mountebank - /// verification. - /// - /// The default response to send if no predicate matches - /// Will allow all CORS preflight requests if set to true - /// The newly created imposter + /// public HttpsImposter CreateHttpsImposter(int? port = null, string name = null, string key = null, string cert = null, bool mutualAuthRequired = false, bool recordRequests = false, HttpResponseFields defaultResponse = null, bool allowCORS = false) @@ -98,70 +77,29 @@ public HttpsImposter CreateHttpsImposter(int? port = null, string name = null, s return new HttpsImposter(port, name, key, cert, mutualAuthRequired, recordRequests, defaultResponse, allowCORS); } - private bool IsPEMFormatted(string value) + private static bool IsPEMFormatted(string value) => Regex.IsMatch(value, @"-----BEGIN CERTIFICATE-----[\S\s]*-----END CERTIFICATE-----"); - /// - /// Creates a new imposter on the specified port with the TCP protocol. The Submit method - /// must be called on the client in order to submit the imposter to mountebank. - /// - /// The port the imposter will be set up to receive requests on - /// The name the imposter will recieve, useful for debugging/logging purposes - /// The mode of the imposter, text or binary. This defines the encoding for request/response data - /// - /// Enables recording requests to use the imposter as a mock. See - /// here for more details on Mountebank - /// verification. - /// - /// The default response to send if no predicate matches - /// The newly created imposter + /// public TcpImposter CreateTcpImposter(int? port = null, string name = null, TcpMode mode = TcpMode.Text, bool recordRequests = false, TcpResponseFields defaultResponse = null) { return new TcpImposter(port, name, mode, recordRequests, defaultResponse); } - /// - /// Creates a new imposter on the specified port with the SMTP protocol. The Submit method - /// must be called on the client in order to submit the imposter to Mountebank. If the port - /// is blank, Mountebank will assign one which can be retrieved after Submit. Note that Mountebank does not yet support - /// stubs for SMTP imposters. - /// - /// - /// The port the imposter will be set up to receive requests on, or null to allow - /// Mountebank to set the port. - /// - /// The name the imposter will recieve, useful for debugging/logging purposes - /// - /// Enables recording requests to use the imposter as a mock. See - /// here for more details on Mountebank - /// verification. - /// - /// The newly created imposter + /// public SmtpImposter CreateSmtpImposter(int? port = null, string name = null, bool recordRequests = false) { return new SmtpImposter(port, name, recordRequests); } - - /// - /// Retrieves a list of imposers - /// imposter if mountebank is running with the "--mock" flag. - /// - /// The list of retrieved imposters + /// public async Task> GetImpostersAsync(CancellationToken cancellationToken = default) { return await _requestProxy.GetImpostersAsync(cancellationToken).ConfigureAwait(false); } - /// - /// Retrieves an HttpImposter along with information about requests made to that - /// imposter if mountebank is running with the "--mock" flag. - /// - /// The port number of the imposter to retrieve - /// The retrieved imposter - /// Thrown if no imposter was found on the specified port. - /// Thrown if the retrieved imposter was not an HTTP imposter + /// public async Task GetHttpImposterAsync(int port, CancellationToken cancellationToken = default) { var imposter = await _requestProxy.GetHttpImposterAsync(port, cancellationToken).ConfigureAwait(false); @@ -171,14 +109,7 @@ public async Task GetHttpImposterAsync(int port, Cancella return imposter; } - /// - /// Retrieves a TcpImposter along with information about requests made to that - /// imposter if mountebank is running with the "--mock" flag. - /// - /// The port number of the imposter to retrieve - /// The retrieved imposter - /// Thrown if no imposter was found on the specified port. - /// Thrown if the retrieved imposter was not an HTTP imposter + /// public async Task GetTcpImposterAsync(int port, CancellationToken cancellationToken = default) { var imposter = await _requestProxy.GetTcpImposterAsync(port, cancellationToken).ConfigureAwait(false); @@ -188,14 +119,7 @@ public async Task GetTcpImposterAsync(int port, Cancellati return imposter; } - /// - /// Retrieves an HttpsImposter along with information about requests made to that - /// imposter if mountebank is running with the "--mock" flag. - /// - /// The port number of the imposter to retrieve - /// The retrieved imposter - /// Thrown if no imposter was found on the specified port. - /// Thrown if the retrieved imposter was not an HTTP imposter + /// public async Task GetHttpsImposterAsync(int port, CancellationToken cancellationToken = default) { var imposter = await _requestProxy.GetHttpsImposterAsync(port, cancellationToken).ConfigureAwait(false); @@ -205,14 +129,7 @@ public async Task GetHttpsImposterAsync(int port, Cancel return imposter; } - /// - /// Retrieves a SmtpImposter along with information about requests made to that - /// imposter if Mountebank is running with the "--mock" flag. - /// - /// The port number of the imposter to retrieve - /// The retrieved imposter - /// Thrown if no imposter was found on the specified port. - /// Thrown if the retrieved imposter was not an SMTP imposter + /// public async Task GetSmtpImposterAsync(int port, CancellationToken cancellationToken = default) { var imposter = await _requestProxy.GetSmtpImposterAsync(port, cancellationToken).ConfigureAwait(false); @@ -234,11 +151,7 @@ private static void ValidateRetrievedImposterProtocol } } - /// - /// Deletes a single imposter from mountebank. Will also remove the imposter from the collection - /// of imposters that the client maintains. - /// - /// The port number of the imposter to be removed + /// public async Task DeleteImposterAsync(int port, CancellationToken cancellationToken = default) { var imposter = Imposters.FirstOrDefault(imp => imp.Port == port); @@ -250,20 +163,14 @@ public async Task DeleteImposterAsync(int port, CancellationToken cancellationTo } } - /// - /// Deletes all imposters from mountebank. Will also remove the imposter from the collection - /// of imposters that the client maintains. - /// + /// public async Task DeleteAllImpostersAsync(CancellationToken cancellationToken = default) { await _requestProxy.DeleteAllImpostersAsync(cancellationToken).ConfigureAwait(false); Imposters = new List(); } - /// - /// Submits all pending imposters from the supplied collection to be created in mountebank. - /// Thrown if unable to create the imposter. - /// + /// public async Task SubmitAsync(ICollection imposters, CancellationToken cancellationToken = default) { foreach (var imposter in imposters) @@ -273,39 +180,25 @@ public async Task SubmitAsync(ICollection imposters, CancellationToken } } - /// - /// Submits imposter to be created in mountebank. - /// Thrown if unable to create the imposter. - /// + /// public async Task SubmitAsync(Imposter imposter, CancellationToken cancellationToken = default) { await SubmitAsync(new[] { imposter }, cancellationToken).ConfigureAwait(false); } - /// - /// Overwrites the stubs of an existing imposter without restarting it. - /// - /// The imposter to be updated with new stubs - /// Thrown if no imposter was found on the specified port. + /// public async Task UpdateImposterAsync(Imposter imposter, CancellationToken cancellationToken = default) { await _requestProxy.UpdateImposterAsync(imposter, cancellationToken); } - /// - /// Deletes previously saved requests for an imposter - /// - /// The port of the imposter to delete request history - /// Thrown if no imposter was found on the specified port. + /// public async Task DeleteSavedRequestsAsync(int port, CancellationToken cancellationToken = default) { await _requestProxy.DeleteSavedRequestsAsync(port, cancellationToken); } - /// - /// Gets the configuration information of Mountebank - /// - /// A Config object containing the configuration of Mountebank + /// public async Task GetConfigAsync(CancellationToken cancellationToken = default) { return await _requestProxy.GetConfigAsync(cancellationToken);