using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using JetBrains.Annotations; [module: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "Reviewed. Suppression is OK here, as it conflicts with internal naming rules.")] [module: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1126:PrefixCallsCorrectly", Justification = "Reviewed. Suppression is OK here, as it conflicts with internal naming rules.")] [module: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:FieldNamesMustNotBeginWithUnderscore", Justification = "Reviewed. Suppression is OK here, as it conflicts with internal naming rules.")] [module: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Reviewed. Suppression is OK here, as unknown copyright and company.")] // ReSharper disable ArrangeThisQualifier // ReSharper disable InconsistentNaming namespace WireMock.RequestBuilders { /// /// The requests. /// public class Request : CompositeRequestSpec, IVerbRequestBuilder, IHeadersRequestBuilder, IParamsRequestBuilder { /// /// The _request specs. /// private readonly IList _requestSpecs; /// /// Initializes a new instance of the class. /// /// /// The request specs. /// private Request(IList requestSpecs) : base(requestSpecs) { _requestSpecs = requestSpecs; } /// /// The with url. /// /// /// The url. /// /// /// The . /// public static IVerbRequestBuilder WithUrl(string url) { var specs = new List { new RequestUrlSpec(url) }; return new Request(specs); } /// /// The with url. /// /// /// The url func. /// /// /// The . /// public static IVerbRequestBuilder WithUrl(Func func) { var specs = new List { new RequestUrlSpec(func) }; return new Request(specs); } /// /// The with path. /// /// /// The path. /// /// /// The . /// public static IVerbRequestBuilder WithPath(string path) { var specs = new List { new RequestPathSpec(path) }; return new Request(specs); } /// /// The with path. /// /// /// The path func. /// /// /// The . /// public static IVerbRequestBuilder WithPath([NotNull] Func func) { var specs = new List { new RequestPathSpec(func) }; return new Request(specs); } /// /// The using get. /// /// /// The . /// public IHeadersRequestBuilder UsingGet() { _requestSpecs.Add(new RequestVerbSpec("get")); return this; } /// /// The using post. /// /// /// The . /// public IHeadersRequestBuilder UsingPost() { _requestSpecs.Add(new RequestVerbSpec("post")); return this; } /// /// The using put. /// /// /// The . /// public IHeadersRequestBuilder UsingPut() { _requestSpecs.Add(new RequestVerbSpec("put")); return this; } /// /// The using delete. /// /// /// The . /// public IHeadersRequestBuilder UsingDelete() { _requestSpecs.Add(new RequestVerbSpec("delete")); return this; } /// /// The using head. /// /// /// The . /// public IHeadersRequestBuilder UsingHead() { _requestSpecs.Add(new RequestVerbSpec("head")); return this; } /// /// The using any verb. /// /// /// The . /// public IHeadersRequestBuilder UsingAnyVerb() { return this; } /// /// The using verb. /// /// /// The verb. /// /// /// The . /// public IHeadersRequestBuilder UsingVerb(string verb) { _requestSpecs.Add(new RequestVerbSpec(verb)); return this; } /// /// The with body. /// /// /// The body. /// /// /// The . /// public ISpecifyRequests WithBody(string body) { _requestSpecs.Add(new RequestBodySpec(body)); return this; } /// /// The with body. /// /// /// The body function. /// /// /// The . /// public ISpecifyRequests WithBody(Func func) { _requestSpecs.Add(new RequestBodySpec(func)); return this; } /// /// The with parameters. /// /// /// The key. /// /// /// The values. /// /// /// The . /// public ISpecifyRequests WithParam(string key, params string[] values) { _requestSpecs.Add(new RequestParamSpec(key, values.ToList())); return this; } /// /// The with parameters. /// /// /// The func. /// /// /// The . /// public ISpecifyRequests WithParam(Func>, bool> func) { _requestSpecs.Add(new RequestParamSpec(func)); return this; } /// /// The with header. /// /// /// The name. /// /// /// The value. /// /// ignore Case /// /// The . /// public IHeadersRequestBuilder WithHeader(string name, string value, bool ignoreCase = true) { _requestSpecs.Add(new RequestHeaderSpec(name, value, ignoreCase)); return this; } /// /// The with header. /// /// /// The func. /// /// /// The . /// public IHeadersRequestBuilder WithHeader(Func, bool> func) { _requestSpecs.Add(new RequestHeaderSpec(func)); return this; } } }