Summary

Class:WireMock.Server.FluentMockServer
Assembly:WireMock.Net
File(s):C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\FluentMockServer.Admin.cs
C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\FluentMockServer.cs
Covered lines:200
Uncovered lines:423
Coverable lines:623
Total lines:1180
Line coverage:32.1%
Branch coverage:29.2%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
ReadStaticMappings(...)6484.6260
ReadStaticMapping(...)22100100
InitAdmin()1000
SettingsGet(...)3000
SettingsUpdate(...)3400
MappingGet(...)2200
MappingPut(...)4800
MappingDelete(...)2200
MappingsSave(...)6200
SanitizeFileName(...)1000
MappingsGet(...)4000
MappingsPost(...)1000
DeserializeAndAddMapping(...)106410069.23
MappingsDelete(...)1000
RequestGet(...)2200
RequestDelete(...)2200
RequestsGet(...)2000
ToLogEntryModel(...)7800
RequestsDelete(...)1000
RequestsFind(...)7200
InitRequestBuilder(...)271638439.6844.83
InitResponseBuilder(...)1251238.7136.84
ToMappingModel(...)416553600
Map(...)4200
Map(...)6800
Map(...)4200
Map(...)3200
Map(...)15102452.6347.62
ToJson(...)1000
ToEncoding(...)3210066.67
.ctor(...)1551277.7857.89
.cctor()10100100
FindLogEntries(...)82100100
Start(...)1000
Start(...)10100100
Start(...)10100100
StartWithAdminInterface(...)1000
StartWithAdminInterface(...)1000
StartWithAdminInterfaceAndReadStaticMappings(...)1000
AddCatchAllMapping()2000
Stop()2210066.67
Dispose()3200
Reset()1000
ResetLogEntries()20100100
DeleteLogEntry(...)3200
ResetMappings()30100100
DeleteMapping(...)32100100
AddGlobalProcessingDelay(...)20100100
AllowPartialMapping()2000
SetBasicAuthentication(...)1000
Given(...)10100100
RegisterMapping(...)20100100

File(s)

C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\FluentMockServer.Admin.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.IO;
 4using System.Linq;
 5using System.Text;
 6using JetBrains.Annotations;
 7using Newtonsoft.Json;
 8using SimMetrics.Net;
 9using WireMock.Admin.Mappings;
 10using WireMock.Admin.Requests;
 11using WireMock.Admin.Settings;
 12using WireMock.Logging;
 13using WireMock.Matchers;
 14using WireMock.Matchers.Request;
 15using WireMock.RequestBuilders;
 16using WireMock.ResponseBuilders;
 17using WireMock.Util;
 18using WireMock.Validation;
 19
 20namespace WireMock.Server
 21{
 22    /// <summary>
 23    /// The fluent mock server.
 24    /// </summary>
 25    public partial class FluentMockServer
 26    {
 127        private static readonly string AdminMappingsFolder = Path.Combine("__admin", "mappings");
 28        private const string AdminMappings = "/__admin/mappings";
 29        private const string AdminRequests = "/__admin/requests";
 30        private const string AdminSettings = "/__admin/settings";
 1831        private readonly RegexMatcher _adminMappingsGuidPathMatcher = new RegexMatcher(@"^\/__admin\/mappings\/(\{{0,1}(
 1832        private readonly RegexMatcher _adminRequestsGuidPathMatcher = new RegexMatcher(@"^\/__admin\/requests\/(\{{0,1}(
 33
 1834        private readonly JsonSerializerSettings _settings = new JsonSerializerSettings
 1835        {
 1836            Formatting = Formatting.Indented,
 1837            NullValueHandling = NullValueHandling.Ignore,
 1838        };
 39
 40        /// <summary>
 41        /// Reads the static mappings from a folder.
 42        /// </summary>
 43        /// <param name="folder">The optional folder. If not defined, use \__admin\mappings\</param>
 44        [PublicAPI]
 45        public void ReadStaticMappings([CanBeNull] string folder = null)
 146        {
 147             if (folder == null)
 048                folder = Path.Combine(Directory.GetCurrentDirectory(), AdminMappingsFolder);
 49
 150             if (!Directory.Exists(folder))
 051                return;
 52
 953            foreach (string filename in Directory.EnumerateFiles(folder).OrderBy(f => f))
 254            {
 255                ReadStaticMapping(filename);
 256            }
 157        }
 58
 59        /// <summary>
 60        /// Reads the static mapping.
 61        /// </summary>
 62        /// <param name="filename">The filename.</param>
 63        [PublicAPI]
 64        public void ReadStaticMapping([NotNull] string filename)
 465        {
 466            Check.NotNull(filename, nameof(filename));
 67
 468            string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename);
 69            Guid guidFromFilename;
 70
 471             if (Guid.TryParse(filenameWithoutExtension, out guidFromFilename))
 272            {
 273                DeserializeAndAddMapping(File.ReadAllText(filename), guidFromFilename);
 274            }
 75            else
 276            {
 277                DeserializeAndAddMapping(File.ReadAllText(filename));
 278            }
 479        }
 80
 81        private void InitAdmin()
 082        {
 83            // __admin/settings
 084            Given(Request.Create().WithPath(AdminSettings).UsingGet()).RespondWith(new DynamicResponseProvider(SettingsG
 085            Given(Request.Create().WithPath(AdminSettings).UsingVerb("PUT", "POST")).RespondWith(new DynamicResponseProv
 86
 87
 88            // __admin/mappings
 089            Given(Request.Create().WithPath(AdminMappings).UsingGet()).RespondWith(new DynamicResponseProvider(MappingsG
 090            Given(Request.Create().WithPath(AdminMappings).UsingPost()).RespondWith(new DynamicResponseProvider(Mappings
 091            Given(Request.Create().WithPath(AdminMappings).UsingDelete()).RespondWith(new DynamicResponseProvider(Mappin
 92
 93            // __admin/mappings/reset
 094            Given(Request.Create().WithPath(AdminMappings + "/reset").UsingPost()).RespondWith(new DynamicResponseProvid
 95
 96            // __admin/mappings/{guid}
 097            Given(Request.Create().WithPath(_adminMappingsGuidPathMatcher).UsingGet()).RespondWith(new DynamicResponsePr
 098            Given(Request.Create().WithPath(_adminMappingsGuidPathMatcher).UsingPut().WithHeader("Content-Type", "applic
 099            Given(Request.Create().WithPath(_adminMappingsGuidPathMatcher).UsingDelete()).RespondWith(new DynamicRespons
 100
 101            // __admin/mappings/save
 0102            Given(Request.Create().WithPath(AdminMappings + "/save").UsingPost()).RespondWith(new DynamicResponseProvide
 103
 104
 105            // __admin/requests
 0106            Given(Request.Create().WithPath(AdminRequests).UsingGet()).RespondWith(new DynamicResponseProvider(RequestsG
 0107            Given(Request.Create().WithPath(AdminRequests).UsingDelete()).RespondWith(new DynamicResponseProvider(Reques
 108
 109            // __admin/requests/reset
 0110            Given(Request.Create().WithPath(AdminRequests + "/reset").UsingPost()).RespondWith(new DynamicResponseProvid
 111
 112            // __admin/request/{guid}
 0113            Given(Request.Create().WithPath(_adminRequestsGuidPathMatcher).UsingGet()).RespondWith(new DynamicResponsePr
 0114            Given(Request.Create().WithPath(_adminRequestsGuidPathMatcher).UsingDelete()).RespondWith(new DynamicRespons
 115
 116            // __admin/requests/find
 0117            Given(Request.Create().WithPath(AdminRequests + "/find").UsingPost()).RespondWith(new DynamicResponseProvide
 0118        }
 119
 120        #region Settings
 121        private ResponseMessage SettingsGet(RequestMessage requestMessage)
 0122        {
 0123            var model = new SettingsModel
 0124            {
 0125                AllowPartialMapping = _options.AllowPartialMapping,
 0126                GlobalProcessingDelay = _options.RequestProcessingDelay?.Milliseconds
 0127            };
 128
 0129            return ToJson(model);
 0130        }
 131
 132        private ResponseMessage SettingsUpdate(RequestMessage requestMessage)
 0133        {
 0134            var settings = JsonConvert.DeserializeObject<SettingsModel>(requestMessage.Body);
 135
 0136             if (settings.AllowPartialMapping != null)
 0137                _options.AllowPartialMapping = settings.AllowPartialMapping.Value;
 138
 0139             if (settings.GlobalProcessingDelay != null)
 0140                _options.RequestProcessingDelay = TimeSpan.FromMilliseconds(settings.GlobalProcessingDelay.Value);
 141
 0142            return new ResponseMessage { Body = "Settings updated" };
 0143        }
 144        #endregion Settings
 145
 146        #region Mapping/{guid}
 147        private ResponseMessage MappingGet(RequestMessage requestMessage)
 0148        {
 0149            Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminMappings.Length + 1));
 0150            var mapping = Mappings.FirstOrDefault(m => !m.IsAdminInterface && m.Guid == guid);
 151
 0152             if (mapping == null)
 0153                return new ResponseMessage { StatusCode = 404, Body = "Mapping not found" };
 154
 0155            var model = ToMappingModel(mapping);
 156
 0157            return ToJson(model);
 0158        }
 159
 160        private ResponseMessage MappingPut(RequestMessage requestMessage)
 0161        {
 0162            Guid guid = Guid.Parse(requestMessage.Path.TrimStart(AdminMappings.ToCharArray()));
 0163            var mappingModel = JsonConvert.DeserializeObject<MappingModel>(requestMessage.Body);
 164
 0165             if (mappingModel.Request == null)
 0166                return new ResponseMessage { StatusCode = 400, Body = "Request missing" };
 167
 0168             if (mappingModel.Response == null)
 0169                return new ResponseMessage { StatusCode = 400, Body = "Response missing" };
 170
 0171            var requestBuilder = InitRequestBuilder(mappingModel.Request);
 0172            var responseBuilder = InitResponseBuilder(mappingModel.Response);
 173
 0174            IRespondWithAProvider respondProvider = Given(requestBuilder).WithGuid(guid);
 175
 0176             if (!string.IsNullOrEmpty(mappingModel.Title))
 0177                respondProvider = respondProvider.WithTitle(mappingModel.Title);
 178
 0179            respondProvider.RespondWith(responseBuilder);
 180
 0181            return new ResponseMessage { Body = "Mapping added or updated" };
 0182        }
 183
 184        private ResponseMessage MappingDelete(RequestMessage requestMessage)
 0185        {
 0186            Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminMappings.Length + 1));
 187
 0188             if (DeleteMapping(guid))
 0189                return new ResponseMessage { Body = "Mapping removed" };
 190
 0191            return new ResponseMessage { Body = "Mapping not found" };
 0192        }
 193        #endregion Mapping/{guid}
 194
 195        #region Mappings
 196        private ResponseMessage MappingsSave(RequestMessage requestMessage)
 0197        {
 0198            string folder = Path.Combine(Directory.GetCurrentDirectory(), AdminMappingsFolder);
 0199             if (!Directory.Exists(folder))
 0200                Directory.CreateDirectory(folder);
 201
 0202            foreach (var mapping in Mappings.Where(m => !m.IsAdminInterface))
 0203            {
 0204                var model = ToMappingModel(mapping);
 0205                string json = JsonConvert.SerializeObject(model, _settings);
 0206                string filename = !string.IsNullOrEmpty(mapping.Title) ? SanitizeFileName(mapping.Title) : mapping.Guid.
 207
 0208                File.WriteAllText(Path.Combine(folder, filename + ".json"), json);
 0209            }
 210
 0211            return new ResponseMessage { Body = "Mappings saved to disk" };
 0212        }
 213
 214        private static string SanitizeFileName(string name, char replaceChar = '_')
 0215        {
 0216            return Path.GetInvalidFileNameChars().Aggregate(name, (current, c) => current.Replace(c, replaceChar));
 0217        }
 218
 219        private ResponseMessage MappingsGet(RequestMessage requestMessage)
 0220        {
 0221            var result = new List<MappingModel>();
 0222            foreach (var mapping in Mappings.Where(m => !m.IsAdminInterface))
 0223            {
 0224                var model = ToMappingModel(mapping);
 0225                result.Add(model);
 0226            }
 227
 0228            return ToJson(result);
 0229        }
 230
 231        private ResponseMessage MappingsPost(RequestMessage requestMessage)
 0232        {
 233            try
 0234            {
 0235                DeserializeAndAddMapping(requestMessage.Body);
 0236            }
 0237            catch (ArgumentException a)
 0238            {
 0239                return new ResponseMessage { StatusCode = 400, Body = a.Message };
 240            }
 0241            catch (Exception e)
 0242            {
 0243                return new ResponseMessage { StatusCode = 500, Body = e.ToString() };
 244            }
 245
 0246            return new ResponseMessage { StatusCode = 201, Body = "Mapping added" };
 0247        }
 248
 249        private void DeserializeAndAddMapping(string json, Guid? guid = null)
 4250        {
 4251            var mappingModel = JsonConvert.DeserializeObject<MappingModel>(json);
 252
 4253            Check.NotNull(mappingModel, nameof(mappingModel));
 4254            Check.NotNull(mappingModel.Request, nameof(mappingModel.Request));
 4255            Check.NotNull(mappingModel.Response, nameof(mappingModel.Response));
 256
 4257            var requestBuilder = InitRequestBuilder(mappingModel.Request);
 4258            var responseBuilder = InitResponseBuilder(mappingModel.Response);
 259
 4260            IRespondWithAProvider respondProvider = Given(requestBuilder);
 261
 4262             if (guid != null)
 2263            {
 2264                respondProvider = respondProvider.WithGuid(guid.Value);
 2265            }
 2266             else if (mappingModel.Guid != null && mappingModel.Guid != Guid.Empty)
 2267            {
 2268                respondProvider = respondProvider.WithGuid(mappingModel.Guid.Value);
 2269            }
 270
 4271             if (!string.IsNullOrEmpty(mappingModel.Title))
 2272                respondProvider = respondProvider.WithTitle(mappingModel.Title);
 273
 4274             if (mappingModel.Priority != null)
 4275                respondProvider = respondProvider.AtPriority(mappingModel.Priority.Value);
 276
 4277            respondProvider.RespondWith(responseBuilder);
 4278        }
 279
 280        private ResponseMessage MappingsDelete(RequestMessage requestMessage)
 0281        {
 0282            ResetMappings();
 283
 0284            return new ResponseMessage { Body = "Mappings deleted" };
 0285        }
 286        #endregion Mappings
 287
 288        #region Request/{guid}
 289        private ResponseMessage RequestGet(RequestMessage requestMessage)
 0290        {
 0291            Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminRequests.Length + 1));
 0292            var entry = LogEntries.FirstOrDefault(r => !r.RequestMessage.Path.StartsWith("/__admin/") && r.Guid == guid)
 293
 0294             if (entry == null)
 0295                return new ResponseMessage { StatusCode = 404, Body = "Request not found" };
 296
 0297            var model = ToLogEntryModel(entry);
 298
 0299            return ToJson(model);
 0300        }
 301
 302        private ResponseMessage RequestDelete(RequestMessage requestMessage)
 0303        {
 0304            Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminRequests.Length + 1));
 305
 0306             if (DeleteLogEntry(guid))
 0307                return new ResponseMessage { Body = "Request removed" };
 308
 0309            return new ResponseMessage { Body = "Request not found" };
 0310        }
 311        #endregion Request/{guid}
 312
 313        #region Requests
 314        private ResponseMessage RequestsGet(RequestMessage requestMessage)
 0315        {
 0316            var result = LogEntries
 0317                .Where(r => !r.RequestMessage.Path.StartsWith("/__admin/"))
 0318                .Select(ToLogEntryModel);
 319
 0320            return ToJson(result);
 0321        }
 322
 323        private LogEntryModel ToLogEntryModel(LogEntry logEntry)
 0324        {
 0325             return new LogEntryModel
 0326            {
 0327                Guid = logEntry.Guid,
 0328                Request = new LogRequestModel
 0329                {
 0330                    DateTime = logEntry.RequestMessage.DateTime,
 0331                    Path = logEntry.RequestMessage.Path,
 0332                    AbsoluteUrl = logEntry.RequestMessage.Url,
 0333                    Query = logEntry.RequestMessage.Query,
 0334                    Method = logEntry.RequestMessage.Method,
 0335                    Body = logEntry.RequestMessage.Body,
 0336                    Headers = logEntry.RequestMessage.Headers,
 0337                    Cookies = logEntry.RequestMessage.Cookies,
 0338                    BodyEncoding = logEntry.RequestMessage.BodyEncoding != null ? new EncodingModel
 0339                    {
 0340                        EncodingName = logEntry.RequestMessage.BodyEncoding.EncodingName,
 0341                        CodePage = logEntry.RequestMessage.BodyEncoding.CodePage,
 0342                        WebName = logEntry.RequestMessage.BodyEncoding.WebName
 0343                    } : null
 0344                },
 0345                Response = new LogResponseModel
 0346                {
 0347                    StatusCode = logEntry.ResponseMessage.StatusCode,
 0348                    Body = logEntry.ResponseMessage.Body,
 0349                    BodyOriginal = logEntry.ResponseMessage.BodyOriginal,
 0350                    Headers = logEntry.ResponseMessage.Headers,
 0351                    BodyEncoding = logEntry.ResponseMessage.BodyEncoding != null ? new EncodingModel
 0352                    {
 0353                        EncodingName = logEntry.ResponseMessage.BodyEncoding.EncodingName,
 0354                        CodePage = logEntry.ResponseMessage.BodyEncoding.CodePage,
 0355                        WebName = logEntry.ResponseMessage.BodyEncoding.WebName
 0356                    } : null
 0357                },
 0358                MappingGuid = logEntry.MappingGuid,
 0359                MappingTitle = logEntry.MappingTitle,
 0360                RequestMatchResult = logEntry.RequestMatchResult != null ? new LogRequestMatchModel
 0361                {
 0362                    TotalScore = logEntry.RequestMatchResult.TotalScore,
 0363                    TotalNumber = logEntry.RequestMatchResult.TotalNumber,
 0364                    IsPerfectMatch = logEntry.RequestMatchResult.IsPerfectMatch,
 0365                    AverageTotalScore = logEntry.RequestMatchResult.AverageTotalScore
 0366                } : null
 0367            };
 0368        }
 369
 370        private ResponseMessage RequestsDelete(RequestMessage requestMessage)
 0371        {
 0372            ResetLogEntries();
 373
 0374            return new ResponseMessage { Body = "Requests deleted" };
 0375        }
 376        #endregion Requests
 377
 378        #region Requests/find
 379        private ResponseMessage RequestsFind(RequestMessage requestMessage)
 0380        {
 0381            var requestModel = JsonConvert.DeserializeObject<RequestModel>(requestMessage.Body);
 382
 0383            var request = (Request)InitRequestBuilder(requestModel);
 384
 0385            var dict = new Dictionary<LogEntry, RequestMatchResult>();
 0386            foreach (var logEntry in LogEntries.Where(le => !le.RequestMessage.Path.StartsWith("/__admin/")))
 0387            {
 0388                var requestMatchResult = new RequestMatchResult();
 0389                 if (request.GetMatchingScore(logEntry.RequestMessage, requestMatchResult) > 0.99)
 0390                    dict.Add(logEntry, requestMatchResult);
 0391            }
 392
 0393            var result = dict.OrderBy(x => x.Value.AverageTotalScore).Select(x => x.Key);
 394
 0395            return ToJson(result);
 0396        }
 397        #endregion Requests/find
 398
 399        private IRequestBuilder InitRequestBuilder(RequestModel requestModel)
 4400        {
 4401            IRequestBuilder requestBuilder = Request.Create();
 402
 4403             if (requestModel.Path != null)
 4404            {
 4405                string path = requestModel.Path as string;
 4406                 if (path != null)
 0407                    requestBuilder = requestBuilder.WithPath(path);
 408                else
 4409                {
 4410                    var pathModel = JsonUtils.ParseJTokenToObject<PathModel>(requestModel.Path);
 4411                     if (pathModel?.Matchers != null)
 4412                        requestBuilder = requestBuilder.WithPath(pathModel.Matchers.Select(Map).ToArray());
 4413                }
 4414            }
 415
 4416             if (requestModel.Url != null)
 0417            {
 0418                string url = requestModel.Url as string;
 0419                 if (url != null)
 0420                    requestBuilder = requestBuilder.WithUrl(url);
 421                else
 0422                {
 0423                    var urlModel = JsonUtils.ParseJTokenToObject<UrlModel>(requestModel.Url);
 0424                     if (urlModel?.Matchers != null)
 0425                        requestBuilder = requestBuilder.WithUrl(urlModel.Matchers.Select(Map).ToArray());
 0426                }
 0427            }
 428
 4429             if (requestModel.Methods != null)
 4430                requestBuilder = requestBuilder.UsingVerb(requestModel.Methods);
 431
 4432             if (requestModel.Headers != null)
 0433            {
 0434                foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null))
 0435                {
 0436                    requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(Map).ToArra
 0437                }
 0438            }
 439
 4440             if (requestModel.Cookies != null)
 0441            {
 0442                foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null))
 0443                {
 0444                    requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(Map).ToArra
 0445                }
 0446            }
 447
 4448             if (requestModel.Params != null)
 0449            {
 0450                foreach (var paramModel in requestModel.Params.Where(p => p.Values != null))
 0451                {
 0452                    requestBuilder = requestBuilder.WithParam(paramModel.Name, paramModel.Values.ToArray());
 0453                }
 0454            }
 455
 4456             if (requestModel.Body?.Matcher != null)
 2457            {
 2458                var bodyMatcher = Map(requestModel.Body.Matcher);
 2459                requestBuilder = requestBuilder.WithBody(bodyMatcher);
 2460            }
 461
 4462            return requestBuilder;
 4463        }
 464
 465        private IResponseBuilder InitResponseBuilder(ResponseModel responseModel)
 4466        {
 4467            IResponseBuilder responseBuilder = Response.Create();
 468
 4469             if (responseModel.StatusCode.HasValue)
 4470                responseBuilder = responseBuilder.WithStatusCode(responseModel.StatusCode.Value);
 471
 4472             if (responseModel.Headers != null)
 4473                responseBuilder = responseBuilder.WithHeaders(responseModel.Headers);
 0474             else if (responseModel.HeadersRaw != null)
 0475            {
 0476                foreach (string headerLine in responseModel.HeadersRaw.Split(new[] { "\n", "\r\n" }, StringSplitOptions.
 0477                {
 0478                    int indexColon = headerLine.IndexOf(":", StringComparison.Ordinal);
 0479                    string key = headerLine.Substring(0, indexColon).TrimStart(' ', '\t');
 0480                    string value = headerLine.Substring(indexColon + 1).TrimStart(' ', '\t');
 0481                    responseBuilder = responseBuilder.WithHeader(key, value);
 0482                }
 0483            }
 484
 4485             if (responseModel.Body != null)
 4486                responseBuilder = responseBuilder.WithBody(responseModel.Body, ToEncoding(responseModel.BodyEncoding));
 0487             else if (responseModel.BodyAsJson != null)
 0488                responseBuilder = responseBuilder.WithBodyAsJson(responseModel.BodyAsJson, ToEncoding(responseModel.Body
 0489             else if (responseModel.BodyAsBase64 != null)
 0490                responseBuilder = responseBuilder.WithBodyAsBase64(responseModel.BodyAsBase64, ToEncoding(responseModel.
 491
 4492             if (responseModel.UseTransformer)
 0493                responseBuilder = responseBuilder.WithTransformer();
 494
 4495             if (responseModel.Delay > 0)
 0496                responseBuilder = responseBuilder.WithDelay(responseModel.Delay.Value);
 497
 4498            return responseBuilder;
 4499        }
 500
 501        private MappingModel ToMappingModel(Mapping mapping)
 0502        {
 0503            var request = (Request)mapping.RequestMatcher;
 0504            var response = (Response)mapping.Provider;
 505
 0506            var pathMatchers = request.GetRequestMessageMatchers<RequestMessagePathMatcher>();
 0507            var urlMatchers = request.GetRequestMessageMatchers<RequestMessageUrlMatcher>();
 0508            var headerMatchers = request.GetRequestMessageMatchers<RequestMessageHeaderMatcher>();
 0509            var cookieMatchers = request.GetRequestMessageMatchers<RequestMessageCookieMatcher>();
 0510            var paramsMatchers = request.GetRequestMessageMatchers<RequestMessageParamMatcher>();
 0511            var bodyMatcher = request.GetRequestMessageMatcher<RequestMessageBodyMatcher>();
 0512            var methodMatcher = request.GetRequestMessageMatcher<RequestMessageMethodMatcher>();
 513
 0514             return new MappingModel
 0515            {
 0516                Guid = mapping.Guid,
 0517                Title = mapping.Title,
 0518                Priority = mapping.Priority,
 0519                Request = new RequestModel
 0520                {
 0521                    Path = pathMatchers != null && pathMatchers.Any() ? new PathModel
 0522                    {
 0523                        Matchers = Map(pathMatchers.Where(m => m.Matchers != null).SelectMany(m => m.Matchers)),
 0524                        Funcs = Map(pathMatchers.Where(m => m.Funcs != null).SelectMany(m => m.Funcs))
 0525                    } : null,
 0526
 0527                    Url = urlMatchers != null && urlMatchers.Any() ? new UrlModel
 0528                    {
 0529                        Matchers = Map(urlMatchers.Where(m => m.Matchers != null).SelectMany(m => m.Matchers)),
 0530                        Funcs = Map(urlMatchers.Where(m => m.Funcs != null).SelectMany(m => m.Funcs))
 0531                    } : null,
 0532
 0533                    Methods = methodMatcher?.Methods,
 0534
 0535                    Headers = headerMatchers != null && headerMatchers.Any() ? headerMatchers.Select(hm => new HeaderMod
 0536                    {
 0537                        Name = hm.Name,
 0538                        Matchers = Map(hm.Matchers),
 0539                        Funcs = Map(hm.Funcs)
 0540                    }).ToList() : null,
 0541
 0542                    Cookies = cookieMatchers != null && cookieMatchers.Any() ? cookieMatchers.Select(cm => new CookieMod
 0543                    {
 0544                        Name = cm.Name,
 0545                        Matchers = Map(cm.Matchers),
 0546                        Funcs = Map(cm.Funcs)
 0547                    }).ToList() : null,
 0548
 0549                     Params = paramsMatchers != null && paramsMatchers.Any() ? paramsMatchers.Select(pm => new ParamModel
 0550                    {
 0551                        Name = pm.Key,
 0552                        Values = pm.Values?.ToList(),
 0553                        Funcs = Map(pm.Funcs)
 0554                    }).ToList() : null,
 0555
 0556                    Body = methodMatcher?.Methods != null && methodMatcher.Methods.Count(m => m == "get") == 1 ? null : 
 0557                    {
 0558                        Matcher = bodyMatcher != null ? Map(bodyMatcher.Matcher) : null,
 0559                        Func = bodyMatcher != null ? Map(bodyMatcher.Func) : null,
 0560                        DataFunc = bodyMatcher != null ? Map(bodyMatcher.DataFunc) : null
 0561                    }
 0562                },
 0563                Response = new ResponseModel
 0564                {
 0565                    StatusCode = response.ResponseMessage.StatusCode,
 0566                    Headers = response.ResponseMessage.Headers,
 0567                    Body = response.ResponseMessage.Body,
 0568                    UseTransformer = response.UseTransformer,
 0569                    Delay = response.Delay?.Milliseconds,
 0570
 0571                    BodyEncoding = response.ResponseMessage.BodyEncoding != null ? new EncodingModel
 0572                    {
 0573                        EncodingName = response.ResponseMessage.BodyEncoding.EncodingName,
 0574                        CodePage = response.ResponseMessage.BodyEncoding.CodePage,
 0575                        WebName = response.ResponseMessage.BodyEncoding.WebName
 0576                    } : null
 0577                }
 0578            };
 0579        }
 580
 581        private MatcherModel[] Map([CanBeNull] IEnumerable<IMatcher> matchers)
 0582        {
 0583             if (matchers == null || !matchers.Any())
 0584                return null;
 585
 0586            return matchers.Select(Map).Where(x => x != null).ToArray();
 0587        }
 588
 589        private MatcherModel Map([CanBeNull] IMatcher matcher)
 0590        {
 0591             if (matcher == null)
 0592                return null;
 593
 0594            var patterns = matcher.GetPatterns();
 595
 0596             return new MatcherModel
 0597            {
 0598                Name = matcher.GetName(),
 0599                Pattern = patterns.Length == 1 ? patterns.First() : null,
 0600                Patterns = patterns.Length > 1 ? patterns : null
 0601            };
 0602        }
 603
 604        private string[] Map<T>([CanBeNull] IEnumerable<Func<T, bool>> funcs)
 0605        {
 0606             if (funcs == null || !funcs.Any())
 0607                return null;
 608
 0609            return funcs.Select(Map).Where(x => x != null).ToArray();
 0610        }
 611
 612        private string Map<T>([CanBeNull] Func<T, bool> func)
 0613        {
 0614             return func?.ToString();
 0615        }
 616
 617        private IMatcher Map([CanBeNull] MatcherModel matcher)
 6618        {
 6619             if (matcher == null)
 0620                return null;
 621
 6622            var parts = matcher.Name.Split('.');
 6623            string matcherName = parts[0];
 6624             string matcherType = parts.Length > 1 ? parts[1] : null;
 625
 6626            string[] patterns = matcher.Patterns ?? new[] { matcher.Pattern };
 627
 6628             switch (matcherName)
 629            {
 630                case "ExactMatcher":
 4631                    return new ExactMatcher(patterns);
 632
 633                case "RegexMatcher":
 0634                    return new RegexMatcher(patterns);
 635
 636                case "JsonPathMatcher":
 0637                    return new JsonPathMatcher(patterns);
 638
 639                case "XPathMatcher":
 0640                    return new XPathMatcher(matcher.Pattern);
 641
 642                case "WildcardMatcher":
 2643                     return new WildcardMatcher(patterns, matcher.IgnoreCase == true);
 644
 645                case "SimMetricsMatcher":
 0646                    SimMetricType type = SimMetricType.Levenstein;
 0647                     if (!string.IsNullOrEmpty(matcherType) && !Enum.TryParse(matcherType, out type))
 0648                        throw new NotSupportedException($"Matcher '{matcherName}' with Type '{matcherType}' is not suppo
 649
 0650                    return new SimMetricsMatcher(matcher.Pattern, type);
 651
 652                default:
 0653                    throw new NotSupportedException($"Matcher '{matcherName}' is not supported.");
 654            }
 6655        }
 656
 657        private ResponseMessage ToJson<T>(T result)
 0658        {
 0659            return new ResponseMessage
 0660            {
 0661                Body = JsonConvert.SerializeObject(result, _settings),
 0662                StatusCode = 200,
 0663                Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
 0664            };
 0665        }
 666
 667        private Encoding ToEncoding(EncodingModel encodingModel)
 4668        {
 4669             return encodingModel != null ? Encoding.GetEncoding(encodingModel.CodePage) : null;
 4670        }
 671    }
 672}

C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\FluentMockServer.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Collections.ObjectModel;
 5using System.Linq;
 6using System.Text;
 7using System.Threading;
 8using System.Threading.Tasks;
 9using JetBrains.Annotations;
 10using WireMock.Http;
 11using WireMock.Logging;
 12using WireMock.Matchers;
 13using WireMock.Matchers.Request;
 14using WireMock.RequestBuilders;
 15using WireMock.Validation;
 16using WireMock.Owin;
 17
 18namespace WireMock.Server
 19{
 20    /// <summary>
 21    /// The fluent mock server.
 22    /// </summary>
 23    public partial class FluentMockServer : IDisposable
 24    {
 25        private readonly IOwinSelfHost _httpServer;
 26
 1827        private readonly object _syncRoot = new object();
 28
 1829        private readonly WireMockMiddlewareOptions _options = new WireMockMiddlewareOptions();
 30
 31        /// <summary>
 32        /// Gets the ports.
 33        /// </summary>
 34        /// <value>
 35        /// The ports.
 36        /// </value>
 37        [PublicAPI]
 1338        public List<int> Ports { get; }
 39
 40        /// <summary>
 41        /// Gets the urls.
 42        /// </summary>
 43        [PublicAPI]
 1844        public string[] Urls { get; }
 45
 46        /// <summary>
 47        /// Gets the request logs.
 48        /// </summary>
 49        [PublicAPI]
 50        public IEnumerable<LogEntry> LogEntries
 51        {
 52            get
 353            {
 354                lock (((ICollection)_options.LogEntries).SyncRoot)
 355                {
 356                    return new ReadOnlyCollection<LogEntry>(_options.LogEntries);
 57                }
 358            }
 59        }
 60
 61        /// <summary>
 62        /// The search log-entries based on matchers.
 63        /// </summary>
 64        /// <param name="matchers">The matchers.</param>
 65        /// <returns>The <see cref="IEnumerable"/>.</returns>
 66        [PublicAPI]
 67        public IEnumerable<LogEntry> FindLogEntries([NotNull] params IRequestMatcher[] matchers)
 168        {
 169            lock (((ICollection)_options.LogEntries).SyncRoot)
 170            {
 171                var results = new Dictionary<LogEntry, RequestMatchResult>();
 72
 773                foreach (var log in _options.LogEntries)
 274                {
 275                    var requestMatchResult = new RequestMatchResult();
 1076                    foreach (var matcher in matchers)
 277                    {
 278                        matcher.GetMatchingScore(log.RequestMessage, requestMatchResult);
 279                    }
 80
 281                     if (requestMatchResult.AverageTotalScore > 0.99)
 182                        results.Add(log, requestMatchResult);
 283                }
 84
 385                return new ReadOnlyCollection<LogEntry>(results.OrderBy(x => x.Value).Select(x => x.Key).ToList());
 86            }
 187        }
 88
 89        /// <summary>
 90        /// Gets the mappings.
 91        /// </summary>
 92        [PublicAPI]
 93        public IEnumerable<Mapping> Mappings
 94        {
 95            get
 796            {
 797                lock (((ICollection)_options.Mappings).SyncRoot)
 798                {
 799                    return new ReadOnlyCollection<Mapping>(_options.Mappings);
 100                }
 7101            }
 102        }
 103
 104        /// <summary>
 105        /// Starts the specified settings.
 106        /// </summary>
 107        /// <param name="settings">The FluentMockServerSettings.</param>
 108        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 109        [PublicAPI]
 110        public static FluentMockServer Start(FluentMockServerSettings settings)
 0111        {
 0112            Check.NotNull(settings, nameof(settings));
 113
 0114            return new FluentMockServer(settings);
 0115        }
 116
 117        /// <summary>
 118        /// Start this FluentMockServer.
 119        /// </summary>
 120        /// <param name="port">The port.</param>
 121        /// <param name="ssl">The SSL support.</param>
 122        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 123        [PublicAPI]
 124        public static FluentMockServer Start([CanBeNull] int? port = 0, bool ssl = false)
 16125        {
 16126            return new FluentMockServer(new FluentMockServerSettings
 16127            {
 16128                Port = port,
 16129                UseSSL = ssl
 16130            });
 16131        }
 132
 133        /// <summary>
 134        /// Start this FluentMockServer.
 135        /// </summary>
 136        /// <param name="urls">The urls to listen on.</param>
 137        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 138        [PublicAPI]
 139        public static FluentMockServer Start(params string[] urls)
 2140        {
 2141            Check.NotEmpty(urls, nameof(urls));
 142
 2143            return new FluentMockServer(new FluentMockServerSettings
 2144            {
 2145                Urls = urls
 2146            });
 2147        }
 148
 149        /// <summary>
 150        /// Start this FluentMockServer with the admin interface.
 151        /// </summary>
 152        /// <param name="port">The port.</param>
 153        /// <param name="ssl">The SSL support.</param>
 154        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 155        [PublicAPI]
 156        public static FluentMockServer StartWithAdminInterface(int? port = 0, bool ssl = false)
 0157        {
 0158            return new FluentMockServer(new FluentMockServerSettings
 0159            {
 0160                Port = port,
 0161                UseSSL = ssl,
 0162                StartAdminInterface = true
 0163            });
 0164        }
 165
 166        /// <summary>
 167        /// Start this FluentMockServer with the admin interface.
 168        /// </summary>
 169        /// <param name="urls">The urls.</param>
 170        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 171        [PublicAPI]
 172        public static FluentMockServer StartWithAdminInterface(params string[] urls)
 0173        {
 0174            Check.NotEmpty(urls, nameof(urls));
 175
 0176            return new FluentMockServer(new FluentMockServerSettings
 0177            {
 0178                Urls = urls,
 0179                StartAdminInterface = true
 0180            });
 0181        }
 182
 183        /// <summary>
 184        /// Start this FluentMockServer with the admin interface and read static mappings.
 185        /// </summary>
 186        /// <param name="urls">The urls.</param>
 187        /// <returns>The <see cref="FluentMockServer"/>.</returns>
 188        [PublicAPI]
 189        public static FluentMockServer StartWithAdminInterfaceAndReadStaticMappings(params string[] urls)
 0190        {
 0191            Check.NotEmpty(urls, nameof(urls));
 192
 0193            return new FluentMockServer(new FluentMockServerSettings
 0194            {
 0195                Urls = urls,
 0196                StartAdminInterface = true,
 0197                ReadStaticMappings = true
 0198            });
 0199        }
 200
 18201        private FluentMockServer(FluentMockServerSettings settings)
 18202        {
 18203             if (settings.Urls != null)
 2204            {
 2205                Urls = settings.Urls;
 2206            }
 207            else
 16208            {
 16209                 int port = settings.Port > 0 ? settings.Port.Value : PortUtil.FindFreeTcpPort();
 16210                 Urls = new[] { (settings.UseSSL == true ? "https" : "http") + "://localhost:" + port + "/" };
 16211            }
 212
 213#if NET45
 18214            _httpServer = new OwinSelfHost(_options, Urls);
 215#else
 216            _httpServer = new AspNetCoreSelfHost(_options, Urls);
 217#endif
 18218            Ports = _httpServer.Ports;
 219
 18220            _httpServer.StartAsync();
 221
 18222             if (settings.StartAdminInterface == true)
 0223            {
 0224                InitAdmin();
 0225            }
 226
 18227             if (settings.ReadStaticMappings == true)
 0228            {
 0229                ReadStaticMappings();
 0230            }
 18231        }
 232
 233        /// <summary>
 234        /// Adds the catch all mapping.
 235        /// </summary>
 236        [PublicAPI]
 237        public void AddCatchAllMapping()
 0238        {
 0239            Given(Request.Create().WithPath("/*").UsingAnyVerb())
 0240                .WithGuid(Guid.Parse("90008000-0000-4444-a17e-669cd84f1f05"))
 0241                .AtPriority(1000)
 0242                .RespondWith(new DynamicResponseProvider(request => new ResponseMessage { StatusCode = 404, Body = "No m
 0243        }
 244
 245        /// <summary>
 246        /// Stop this server.
 247        /// </summary>
 248        [PublicAPI]
 249        public void Stop()
 18250        {
 18251             _httpServer?.StopAsync();
 252
 253            //while (_httpServer != null && _httpServer.IsStarted)
 254            //{
 255            //    Task.Delay(999).Wait();
 256            //}
 18257        }
 258
 259        /// <summary>
 260        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 261        /// </summary>
 262        public void Dispose()
 0263        {
 0264             if (_httpServer != null && _httpServer.IsStarted)
 0265            {
 0266                _httpServer.StopAsync();
 267
 268                //while (_httpServer != null && _httpServer.IsStarted)
 269                //{
 270                //    Task.Delay(999).Wait();
 271                //}
 0272            }
 0273        }
 274
 275        /// <summary>
 276        /// Resets LogEntries and Mappings.
 277        /// </summary>
 278        [PublicAPI]
 279        public void Reset()
 0280        {
 0281            ResetLogEntries();
 282
 0283            ResetMappings();
 0284        }
 285
 286        /// <summary>
 287        /// Resets the LogEntries.
 288        /// </summary>
 289        [PublicAPI]
 290        public void ResetLogEntries()
 1291        {
 1292            lock (((ICollection)_options.LogEntries).SyncRoot)
 1293            {
 1294                _options.LogEntries.Clear();
 1295            }
 1296        }
 297
 298        /// <summary>
 299        /// Deletes the mapping.
 300        /// </summary>
 301        /// <param name="guid">The unique identifier.</param>
 302        [PublicAPI]
 303        public bool DeleteLogEntry(Guid guid)
 0304        {
 0305            lock (((ICollection)_options.LogEntries).SyncRoot)
 0306            {
 307                // Check a logentry exists with the same GUID, if so, remove it.
 0308                var existing = _options.LogEntries.FirstOrDefault(m => m.Guid == guid);
 0309                 if (existing != null)
 0310                {
 0311                    _options.LogEntries.Remove(existing);
 0312                    return true;
 313                }
 314
 0315                return false;
 316            }
 0317        }
 318
 319        /// <summary>
 320        /// Resets the Mappings.
 321        /// </summary>
 322        [PublicAPI]
 323        public void ResetMappings()
 1324        {
 1325            lock (((ICollection)_options.Mappings).SyncRoot)
 1326            {
 2327                _options.Mappings = _options.Mappings.Where(m => m.Provider is DynamicResponseProvider).ToList();
 1328            }
 1329        }
 330
 331        /// <summary>
 332        /// Deletes the mapping.
 333        /// </summary>
 334        /// <param name="guid">The unique identifier.</param>
 335        [PublicAPI]
 336        public bool DeleteMapping(Guid guid)
 17337        {
 17338            lock (((ICollection)_options.Mappings).SyncRoot)
 17339            {
 340                // Check a mapping exists with the same GUID, if so, remove it.
 22341                var existingMapping = _options.Mappings.FirstOrDefault(m => m.Guid == guid);
 17342                 if (existingMapping != null)
 1343                {
 1344                    _options.Mappings.Remove(existingMapping);
 1345                    return true;
 346                }
 347
 16348                return false;
 349            }
 17350        }
 351
 352        /// <summary>
 353        /// The add request processing delay.
 354        /// </summary>
 355        /// <param name="delay">
 356        /// The delay.
 357        /// </param>
 358        [PublicAPI]
 359        public void AddGlobalProcessingDelay(TimeSpan delay)
 1360        {
 1361            lock (_syncRoot)
 1362            {
 1363                _options.RequestProcessingDelay = delay;
 1364            }
 1365        }
 366
 367        /// <summary>
 368        /// Allows the partial mapping.
 369        /// </summary>
 370        [PublicAPI]
 371        public void AllowPartialMapping()
 0372        {
 0373            lock (_syncRoot)
 0374            {
 0375                _options.AllowPartialMapping = true;
 0376            }
 0377        }
 378
 379        /// <summary>
 380        /// Sets the basic authentication.
 381        /// </summary>
 382        /// <param name="username">The username.</param>
 383        /// <param name="password">The password.</param>
 384        [PublicAPI]
 385        public void SetBasicAuthentication([NotNull] string username, [NotNull] string password)
 0386        {
 0387            Check.NotNull(username, nameof(username));
 0388            Check.NotNull(password, nameof(password));
 389
 0390            string authorization = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + p
 0391            _options.AuthorizationMatcher = new RegexMatcher("^(?i)BASIC " + authorization + "$");
 0392        }
 393
 394        /// <summary>
 395        /// The given.
 396        /// </summary>
 397        /// <param name="requestMatcher">The request matcher.</param>
 398        /// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
 399        [PublicAPI]
 400        public IRespondWithAProvider Given(IRequestMatcher requestMatcher)
 17401        {
 17402            return new RespondWithAProvider(RegisterMapping, requestMatcher);
 17403        }
 404
 405        /// <summary>
 406        /// The register mapping.
 407        /// </summary>
 408        /// <param name="mapping">
 409        /// The mapping.
 410        /// </param>
 411        private void RegisterMapping(Mapping mapping)
 17412        {
 17413            lock (((ICollection)_options.Mappings).SyncRoot)
 17414            {
 415                // Check a mapping exists with the same GUID, if so, remove it first.
 17416                DeleteMapping(mapping.Guid);
 417
 17418                _options.Mappings.Add(mapping);
 17419            }
 17420        }
 421
 422        //private async void HandleRequestOld(IOwinContext ctx)
 423        //{
 424        //    if (_requestProcessingDelay > TimeSpan.Zero)
 425        //    {
 426        //        lock (_syncRoot)
 427        //        {
 428        //            Task.Delay(_requestProcessingDelay.Value).Wait();
 429        //        }
 430        //    }
 431
 432        //    var request = _requestMapper.MapAsync(ctx.Request);
 433
 434        //    ResponseMessage response = null;
 435        //    Mapping targetMapping = null;
 436        //    RequestMatchResult requestMatchResult = null;
 437        //    try
 438        //    {
 439        //        var mappings = _mappings
 440        //            .Select(m => new { Mapping = m, MatchResult = m.IsRequestHandled(request) })
 441        //            .ToList();
 442
 443        //        if (_allowPartialMapping)
 444        //        {
 445        //            var partialMappings = mappings
 446        //                .Where(pm => pm.Mapping.IsAdminInterface && pm.MatchResult.IsPerfectMatch || !pm.Mapping.IsAdm
 447        //                .OrderBy(m => m.MatchResult)
 448        //                .ThenBy(m => m.Mapping.Priority)
 449        //                .ToList();
 450
 451        //            var bestPartialMatch = partialMappings.FirstOrDefault(pm => pm.MatchResult.AverageTotalScore > 0.0
 452
 453        //            targetMapping = bestPartialMatch?.Mapping;
 454        //            requestMatchResult = bestPartialMatch?.MatchResult;
 455        //        }
 456        //        else
 457        //        {
 458        //            var perfectMatch = mappings
 459        //                .OrderBy(m => m.Mapping.Priority)
 460        //                .FirstOrDefault(m => m.MatchResult.IsPerfectMatch);
 461
 462        //            targetMapping = perfectMatch?.Mapping;
 463        //            requestMatchResult = perfectMatch?.MatchResult;
 464        //        }
 465
 466        //        if (targetMapping == null)
 467        //        {
 468        //            response = new ResponseMessage { StatusCode = 404, Body = "No matching mapping found" };
 469        //            return;
 470        //        }
 471
 472        //        if (targetMapping.IsAdminInterface && _authorizationMatcher != null)
 473        //        {
 474        //            string authorization;
 475        //            bool present = request.Headers.TryGetValue("Authorization", out authorization);
 476        //            if (!present || _authorizationMatcher.IsMatch(authorization) < 1.0)
 477        //            {
 478        //                response = new ResponseMessage { StatusCode = 401 };
 479        //                return;
 480        //            }
 481        //        }
 482
 483        //        response = await targetMapping.ResponseTo(request);
 484        //    }
 485        //    catch (Exception ex)
 486        //    {
 487        //        response = new ResponseMessage { StatusCode = 500, Body = ex.ToString() };
 488        //    }
 489        //    finally
 490        //    {
 491        //        var log = new LogEntry
 492        //        {
 493        //            Guid = Guid.NewGuid(),
 494        //            RequestMessage = request,
 495        //            ResponseMessage = response,
 496        //            MappingGuid = targetMapping?.Guid,
 497        //            MappingTitle = targetMapping?.Title,
 498        //            RequestMatchResult = requestMatchResult
 499        //        };
 500
 501        //        LogRequest(log);
 502
 503        //        _responseMapper.MapAsync(response, ctx.Response);
 504        //        ctx.Response.Close();
 505        //    }
 506        //}
 507    }
 508}

Methods/Properties

.cctor()
.ctor(WireMock.Server.FluentMockServerSettings)
ReadStaticMappings(System.String)
ReadStaticMapping(System.String)
InitAdmin()
SettingsGet(WireMock.RequestMessage)
SettingsUpdate(WireMock.RequestMessage)
MappingGet(WireMock.RequestMessage)
MappingPut(WireMock.RequestMessage)
MappingDelete(WireMock.RequestMessage)
MappingsSave(WireMock.RequestMessage)
SanitizeFileName(System.String,System.Char)
MappingsGet(WireMock.RequestMessage)
MappingsPost(WireMock.RequestMessage)
DeserializeAndAddMapping(System.String,System.Nullable`1<System.Guid>)
MappingsDelete(WireMock.RequestMessage)
RequestGet(WireMock.RequestMessage)
RequestDelete(WireMock.RequestMessage)
RequestsGet(WireMock.RequestMessage)
ToLogEntryModel(WireMock.Logging.LogEntry)
RequestsDelete(WireMock.RequestMessage)
RequestsFind(WireMock.RequestMessage)
InitRequestBuilder(WireMock.Admin.Mappings.RequestModel)
InitResponseBuilder(WireMock.Admin.Mappings.ResponseModel)
ToMappingModel(WireMock.Mapping)
Map(System.Collections.Generic.IEnumerable`1<WireMock.Matchers.IMatcher>)
Map(WireMock.Matchers.IMatcher)
Map(System.Collections.Generic.IEnumerable`1<System.Func`2<T,System.Boolean>>)
Map(System.Func`2<T,System.Boolean>)
Map(WireMock.Admin.Mappings.MatcherModel)
ToJson(T)
ToEncoding(WireMock.Admin.Mappings.EncodingModel)
Ports()
Urls()
LogEntries()
FindLogEntries(WireMock.Matchers.Request.IRequestMatcher[])
Mappings()
Start(WireMock.Server.FluentMockServerSettings)
Start(System.Nullable`1<System.Int32>,System.Boolean)
Start(System.String[])
StartWithAdminInterface(System.Nullable`1<System.Int32>,System.Boolean)
StartWithAdminInterface(System.String[])
StartWithAdminInterfaceAndReadStaticMappings(System.String[])
AddCatchAllMapping()
Stop()
Dispose()
Reset()
ResetLogEntries()
DeleteLogEntry(System.Guid)
ResetMappings()
DeleteMapping(System.Guid)
AddGlobalProcessingDelay(System.TimeSpan)
AllowPartialMapping()
SetBasicAuthentication(System.String,System.String)
Given(WireMock.Matchers.Request.IRequestMatcher)
RegisterMapping(WireMock.Mapping)