private IEnumerable <ILabelledFeature> extractRegionsFromYaml(YamlStream yamlStream) { List <ILabelledFeature> features = new List <ILabelledFeature>(); // Pull out the regions from the YAML files foreach (YamlDocument doc in yamlStream.Documents) { Assert.IsInstanceOf(typeof(Mapping), doc.Root); Mapping m = ( Mapping )doc.Root; foreach (MappingEntry me in m.Enties) { Assert.IsInstanceOf(typeof(Mapping), me.Value); Mapping mPoints = ( Mapping )me.Value; Dictionary <String, Int32> coords = MappingConverter.convertToDictionary(mPoints, MappingConverter.KeyCase.FORCE_LOWER); Point[] points = new Point[4]; bool found = true; int x = 0; int y = 0; int width = 0; int height = 0; found = found && coords.TryGetValue("x", out x); found = found && coords.TryGetValue("y", out y); found = found && coords.TryGetValue("width", out width); found = found && coords.TryGetValue("height", out height); if (found) { if ((x == 0) && (y == 0) && (width == 0) && (height == 0)) { regionAllZero++; } else { points[0] = new Point(x, y); points[1] = new Point(x + width, y); points[2] = new Point(x + width, y + height); points[3] = new Point(x, y + height); DataSetEnums.FeatureName featureName; //bool featureNameFound = tryGetFeatureNameFor( me.Key.ToString(), out featureName ); //if ( featureNameFound ) //{ // features.Add( new LabelledFeature( featureName, new MultiPointPath( points, true ) ) ); //} //else //{ // unrecognisedFeatureName++; //} } } else { notFoundRegionCorners++; } } } return(features); }
private void _btnGo_Click(object sender, EventArgs e) { ShowHideFilesProcessed(true); ShowHideErrors(false); _txtFilesProcessed.Text = ""; _txtErrors.Text = ""; MappingConverter mappingConverter = new MappingConverter(WriteFileName, WriteError); mappingConverter.ConvertAll(_txtHbmDir.Text, _txtMapDir.Text, _txtNamespace.Text, _chkRecursive.Checked); }
private ResponseMessage MappingsGet(RequestMessage requestMessage) { var result = new List <MappingModel>(); foreach (var mapping in Mappings.Where(m => !m.IsAdminInterface)) { var model = MappingConverter.ToMappingModel(mapping); result.Add(model); } return(ToJson(result)); }
public void MappingConverter_ToMappingModel() { // Assign var request = Request.Create(); var response = Response.Create(); var mapping = new Mapping(Guid.NewGuid(), "", null, request, response, 0, null, null, null); // Act var model = MappingConverter.ToMappingModel(mapping); // Assert Check.That(model).IsNotNull(); }
public void Should_emit_Table_if_present_in_original_xml() { const string input = @""; MappedClassInfo classInfo = HbmFileUtility.LoadFromString(@" <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2""> <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">" + input + @"</class> </hibernate-mapping>" ); string result = MappingConverter.Convert("CountyMap", classInfo, "Test"); var expected = (MappingConverter.FluentNHibernateNames.Table + @"(""USERS"");").SplitOnFormattingWhitespace(); ClassFileUtilities.GetConstructorContents(result, "CountyMap").ShouldBeEqualTo(expected); }
public void TestNoMappingReturnsValue() { var converter = new MappingConverter(); converter.Mappings.Add(new Mapping() { From = null, To = 1 }); Assert.AreEqual(1, converter.Convert(null, null, null, null)); Assert.AreEqual(2, converter.Convert(2, null, null, null)); Assert.AreEqual(null, converter.ConvertBack(1, null, null, null)); Assert.AreEqual(2, converter.ConvertBack(2, null, null, null)); }
public void ToMappingModel_WithPriority_ReturnsPriority() { // Assign var request = Request.Create(); var response = Response.Create().WithBodyAsJson(new { x = "x" }).WithTransformer(); var mapping = new Mapping(Guid.NewGuid(), "", null, _fileSystemHandlerMock.Object, request, response, 42, null, null, null); // Act var model = MappingConverter.ToMappingModel(mapping); // Assert model.Should().NotBeNull(); model.Priority.Should().Be(42); model.Response.UseTransformer.Should().BeTrue(); }
private void SaveMappingToFile(Mapping mapping) { string folder = Path.Combine(Directory.GetCurrentDirectory(), AdminMappingsFolder); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var model = MappingConverter.ToMappingModel(mapping); string json = JsonConvert.SerializeObject(model, _settings); string filename = !string.IsNullOrEmpty(mapping.Title) ? SanitizeFileName(mapping.Title) : mapping.Guid.ToString(); File.WriteAllText(Path.Combine(folder, filename + ".json"), json); }
private ResponseMessage MappingGet(RequestMessage requestMessage) { Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminMappings.Length + 1)); var mapping = Mappings.FirstOrDefault(m => !m.IsAdminInterface && m.Guid == guid); if (mapping == null) { _logger.Warn("HttpStatusCode set to 404 : Mapping not found"); return(ResponseMessageBuilder.Create("Mapping not found", 404)); } var model = MappingConverter.ToMappingModel(mapping); return(ToJson(model)); }
public void ToMappingModel() { // Assign var request = Request.Create(); var response = Response.Create(); var mapping = new Mapping(Guid.NewGuid(), "", null, _fileSystemHandlerMock.Object, request, response, 0, null, null, null); // Act var model = MappingConverter.ToMappingModel(mapping); // Assert model.Should().NotBeNull(); model.Priority.Should().BeNull(); model.Response.BodyAsJsonIndented.Should().BeNull(); model.Response.UseTransformer.Should().BeNull(); }
private ResponseMessage MappingGet(RequestMessage requestMessage) { Guid guid = Guid.Parse(requestMessage.Path.Substring(AdminMappings.Length + 1)); var mapping = Mappings.FirstOrDefault(m => !m.IsAdminInterface && m.Guid == guid); if (mapping == null) { return new ResponseMessage { StatusCode = 404, Body = "Mapping not found" } } ; var model = MappingConverter.ToMappingModel(mapping); return(ToJson(model)); }
public void Should_emit_Column_name() { const string input = @" <property name=""LastName"" type=""String""> <column name=""LAST_NAME"" sql-type=""VARCHAR2"" not-null=""false""/> </property>" ; MappedClassInfo classInfo = HbmFileUtility.LoadFromString(@" <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2""> <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"">" + input + @"</class> </hibernate-mapping>" ); string result = MappingConverter.Convert("CountyMap", classInfo, "Test"); var expected = (@" " + Map.FluentNHibernateNames.Map + @"(x => x.LastName, ""LAST_NAME"");").SplitOnFormattingWhitespace(); ClassFileUtilities.GetConstructorContents(result, "CountyMap").ShouldBeEqualTo(expected, result); }
public void Should_emit_Index_if_present_in_original_xml() { const string input = @" <many-to-one name=""State"" class=""Mvba.Enterprise.Business.State, Mvba.Enterprise.Business""> <column length=""2"" sql-type=""VARCHAR2"" index=""IX_STATE""/> </many-to-one>" ; MappedClassInfo classInfo = HbmFileUtility.LoadFromString(@" <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2""> <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"">" + input + @"</class> </hibernate-mapping>" ); string result = MappingConverter.Convert("CountyMap", classInfo, "Test"); var expected = (@" " + References.FluentNHibernateNames.References + @"(x => x.State) ." + Index.FluentNHibernateNames.Index + @"(""IX_STATE"");").SplitOnFormattingWhitespace(); ClassFileUtilities.GetConstructorContents(result, "CountyMap").ShouldBeEqualTo(expected); }
public void Should_emit_UnsavedValue_if_present_in_original_xml() { const string input = @" <id name=""CountyId"" type=""Int32"" unsaved-value=""0""> <column sql-type=""NUMBER"" not-null=""true"" unique=""true"" index=""PK_COUNTY""/> </id>" ; MappedClassInfo classInfo = HbmFileUtility.LoadFromString(@" <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2""> <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"">" + input + @"</class> </hibernate-mapping>" ); string result = MappingConverter.Convert("CountyMap", classInfo, "Test"); var expected = (@" " + Id.FluentNHibernateNames.Id + @"(x => x.CountyId) ." + UnsavedValue.FluentNHibernateNames.UnsavedValue + @"(0);").SplitOnFormattingWhitespace(); ClassFileUtilities.GetConstructorContents(result, "CountyMap").ShouldBeEqualTo(expected); }
public void TestBooleanToVisibilityConverter() { var converter = new MappingConverter(); converter.Mappings.Add(new Mapping() { From = true, To = Visibility.Visible }); converter.Mappings.Add(new Mapping() { From = false, To = Visibility.Collapsed }); Assert.AreEqual(Visibility.Visible, converter.Convert(true, null, null, null)); Assert.AreEqual(Visibility.Collapsed, converter.Convert(false, null, null, null)); Assert.AreEqual(true, converter.ConvertBack(Visibility.Visible, null, null, null)); Assert.AreEqual(false, converter.ConvertBack(Visibility.Collapsed, null, null, null)); }
private void SaveMappingToFile(IMapping mapping, string folder = null) { if (folder == null) { folder = _fileSystemHandler.GetMappingFolder(); } if (!_fileSystemHandler.FolderExists(folder)) { _fileSystemHandler.CreateFolder(folder); } var model = MappingConverter.ToMappingModel(mapping); string filename = (!string.IsNullOrEmpty(mapping.Title) ? SanitizeFileName(mapping.Title) : mapping.Guid.ToString()) + ".json"; string path = Path.Combine(folder, filename); _logger.Info("Saving Mapping file {0}", filename); _fileSystemHandler.WriteMappingFile(path, JsonConvert.SerializeObject(model, _settings)); }
private void SaveMappingToFile(Mapping mapping, [CanBeNull] string folder = null) { if (folder == null) { folder = Path.Combine(Directory.GetCurrentDirectory(), AdminMappingsFolder); } if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var model = MappingConverter.ToMappingModel(mapping); string filename = !string.IsNullOrEmpty(mapping.Title) ? SanitizeFileName(mapping.Title) : mapping.Guid.ToString(); string filePath = Path.Combine(folder, filename + ".json"); _logger.Info("Saving Mapping to file {0}", filePath); File.WriteAllText(filePath, JsonConvert.SerializeObject(model, _settings)); }
private IRequestBuilder InitRequestBuilder(RequestModel requestModel) { IRequestBuilder requestBuilder = Request.Create(); if (requestModel.ClientIP != null) { string clientIP = requestModel.ClientIP as string; if (clientIP != null) { requestBuilder = requestBuilder.WithClientIP(clientIP); } else { var clientIPModel = JsonUtils.ParseJTokenToObject <ClientIPModel>(requestModel.ClientIP); if (clientIPModel?.Matchers != null) { requestBuilder = requestBuilder.WithPath(clientIPModel.Matchers.Select(MappingConverter.Map).Cast <IStringMatcher>().ToArray()); } } } if (requestModel.Path != null) { string path = requestModel.Path as string; if (path != null) { requestBuilder = requestBuilder.WithPath(path); } else { var pathModel = JsonUtils.ParseJTokenToObject <PathModel>(requestModel.Path); if (pathModel?.Matchers != null) { requestBuilder = requestBuilder.WithPath(pathModel.Matchers.Select(MappingConverter.Map).Cast <IStringMatcher>().ToArray()); } } } if (requestModel.Url != null) { string url = requestModel.Url as string; if (url != null) { requestBuilder = requestBuilder.WithUrl(url); } else { var urlModel = JsonUtils.ParseJTokenToObject <UrlModel>(requestModel.Url); if (urlModel?.Matchers != null) { requestBuilder = requestBuilder.WithUrl(urlModel.Matchers.Select(MappingConverter.Map).Cast <IStringMatcher>().ToArray()); } } } if (requestModel.Methods != null) { requestBuilder = requestBuilder.UsingVerb(requestModel.Methods); } if (requestModel.Headers != null) { foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null)) { requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(MappingConverter.Map).Cast <IStringMatcher>().ToArray()); } } if (requestModel.Cookies != null) { foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null)) { requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(MappingConverter.Map).Cast <IStringMatcher>().ToArray()); } } if (requestModel.Params != null) { foreach (var paramModel in requestModel.Params.Where(p => p.Values != null)) { requestBuilder = requestBuilder.WithParam(paramModel.Name, paramModel.Values.ToArray()); } } if (requestModel.Body?.Matcher != null) { var bodyMatcher = MappingConverter.Map(requestModel.Body.Matcher); requestBuilder = requestBuilder.WithBody(bodyMatcher); } return(requestBuilder); }
private async Task InvokeInternal(IContext ctx) { var request = await _requestMapper.MapAsync(ctx.Request, _options); bool logRequest = false; ResponseMessage response = null; (MappingMatcherResult Match, MappingMatcherResult Partial)result = (null, null); try { foreach (var mapping in _options.Mappings.Values.Where(m => m?.Scenario != null)) { // Set scenario start if (!_options.Scenarios.ContainsKey(mapping.Scenario) && mapping.IsStartState) { _options.Scenarios.TryAdd(mapping.Scenario, new ScenarioState { Name = mapping.Scenario }); } } result = _mappingMatcher.FindBestMatch(request); var targetMapping = result.Match?.Mapping; if (targetMapping == null) { logRequest = true; _options.Logger.Warn("HttpStatusCode set to 404 : No matching mapping found"); response = ResponseMessageBuilder.Create("No matching mapping found", 404); return; } logRequest = targetMapping.LogMapping; if (targetMapping.IsAdminInterface && _options.AuthorizationMatcher != null) { bool present = request.Headers.TryGetValue(HttpKnownHeaderNames.Authorization, out WireMockList <string> authorization); if (!present || _options.AuthorizationMatcher.IsMatch(authorization.ToString()) < MatchScores.Perfect) { _options.Logger.Error("HttpStatusCode set to 401"); response = ResponseMessageBuilder.Create(null, 401); return; } } if (!targetMapping.IsAdminInterface && _options.RequestProcessingDelay > TimeSpan.Zero) { await Task.Delay(_options.RequestProcessingDelay.Value); } response = await targetMapping.ProvideResponseAsync(request); var responseBuilder = targetMapping.Provider as Response; if (!targetMapping.IsAdminInterface) { if (responseBuilder?.ProxyAndRecordSettings?.SaveMapping == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMapping == true) { _options.Mappings.TryAdd(targetMapping.Guid, targetMapping); } if (responseBuilder?.ProxyAndRecordSettings?.SaveMappingToFile == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMappingToFile == true) { var matcherMapper = new MatcherMapper(targetMapping.Settings); var mappingConverter = new MappingConverter(matcherMapper); var mappingToFileSaver = new MappingToFileSaver(targetMapping.Settings, mappingConverter); mappingToFileSaver.SaveMappingToFile(targetMapping); } } if (targetMapping.Scenario != null) { UpdateScenarioState(targetMapping); } } catch (Exception ex) { _options.Logger.Error($"Providing a Response for Mapping '{result.Match?.Mapping?.Guid}' failed. HttpStatusCode set to 500. Exception: {ex}"); response = ResponseMessageBuilder.Create(ex.Message, 500); } finally { var log = new LogEntry { Guid = Guid.NewGuid(), RequestMessage = request, ResponseMessage = response, MappingGuid = result.Match?.Mapping?.Guid, MappingTitle = result.Match?.Mapping?.Title, RequestMatchResult = result.Match?.RequestMatchResult, PartialMappingGuid = result.Partial?.Mapping?.Guid, PartialMappingTitle = result.Partial?.Mapping?.Title, PartialMatchResult = result.Partial?.RequestMatchResult }; LogRequest(log, logRequest); await _responseMapper.MapAsync(response, ctx.Response); } await CompletedTask; }
public MappingConverterTests() { _sut = new MappingConverter(new MatcherMapper(_settingsMock.Object)); }
private FluentMockServer(IFluentMockServerSettings settings) { _settings = settings; // Set default values if not provided _settings.Logger = settings.Logger ?? new WireMockNullLogger(); _settings.FileSystemHandler = settings.FileSystemHandler ?? new LocalFileSystemHandler(); _settings.Logger.Info("WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)"); _settings.Logger.Debug("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented)); if (settings.Urls != null) { Urls = settings.Urls.ToArray(); } else { int port = settings.Port > 0 ? settings.Port.Value : PortUtils.FindFreeTcpPort(); Urls = new[] { $"{(settings.UseSSL == true ? "https" : "http")}://localhost:{port}" }; } _options.FileSystemHandler = _settings.FileSystemHandler; _options.PreWireMockMiddlewareInit = settings.PreWireMockMiddlewareInit; _options.PostWireMockMiddlewareInit = settings.PostWireMockMiddlewareInit; _options.Logger = _settings.Logger; _matcherMapper = new MatcherMapper(_settings); _mappingConverter = new MappingConverter(_matcherMapper); #if USE_ASPNETCORE _httpServer = new AspNetCoreSelfHost(_options, Urls); #else _httpServer = new OwinSelfHost(_options, Urls); #endif Ports = _httpServer.Ports; var startTask = _httpServer.StartAsync(); using (var ctsStartTimeout = new CancellationTokenSource(settings.StartTimeout)) { while (!_httpServer.IsStarted) { // Throw exception if service start fails if (_httpServer.RunningException != null) { throw new WireMockException($"Service start failed with error: {_httpServer.RunningException.Message}", _httpServer.RunningException); } if (ctsStartTimeout.IsCancellationRequested) { // In case of an aggregate exception, throw the exception. if (startTask.Exception != null) { throw new WireMockException($"Service start failed with error: {startTask.Exception.Message}", startTask.Exception); } // Else throw TimeoutException throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}"); } ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelayInMs); } } if (settings.AllowPartialMapping == true) { AllowPartialMapping(); } if (settings.StartAdminInterface == true) { if (!string.IsNullOrEmpty(settings.AdminUsername) && !string.IsNullOrEmpty(settings.AdminPassword)) { SetBasicAuthentication(settings.AdminUsername, settings.AdminPassword); } InitAdmin(); } if (settings.ReadStaticMappings == true) { ReadStaticMappings(); } if (settings.WatchStaticMappings == true) { WatchStaticMappings(); } if (settings.ProxyAndRecordSettings != null) { InitProxyAndRecord(settings); } if (settings.RequestLogExpirationDuration != null) { SetRequestLogExpirationDuration(settings.RequestLogExpirationDuration); } if (settings.MaxRequestLogCount != null) { SetMaxRequestLogCount(settings.MaxRequestLogCount); } }
private IEnumerable <ILabelledFeature> extractContoursFromYaml(YamlStream yamlStream) { List <ILabelledFeature> features = new List <ILabelledFeature>(); //return features; // Pull out the contours from the YAML files foreach (YamlDocument doc in yamlStream.Documents) { Assert.IsInstanceOf(typeof(Mapping), doc.Root); Mapping m = ( Mapping )doc.Root; // Validate that this refers to the correct file 'Image file' should be '00011010.jpg' for example Assert.True(m.Enties[0].Key.ToString().CompareTo("Image file") == 0, "Unexpected order of Mapping elements"); Assert.True(m.Enties[1].Key.ToString().CompareTo("Contours count") == 0, "Unexpected order of Mapping elements"); Assert.True(m.Enties[2].Key.ToString().CompareTo("Contours") == 0, "Unexpected order of Mapping elements"); // m.Enties[ 2 ].Value; Assert.IsInstanceOf(typeof(Sequence), m.Enties[2].Value); Sequence seqContours = ( Sequence )m.Enties[2].Value; foreach (DataItem di in seqContours.Enties) { Assert.IsInstanceOf(typeof(Mapping), di); Mapping mdi = ( Mapping )di; Assert.True(mdi.Enties[0].Key.ToString().CompareTo("Name") == 0, "Unexpected order of Mapping elements"); Assert.True(mdi.Enties[1].Key.ToString().CompareTo("Count") == 0, "Unexpected order of Mapping elements"); Assert.True(mdi.Enties[2].Key.ToString().CompareTo("Closed") == 0, "Unexpected order of Mapping elements"); Assert.True(mdi.Enties[3].Key.ToString().CompareTo("Points") == 0, "Unexpected order of Mapping elements"); DataSetEnums.FeatureName featureName; //bool featureNameFound = tryGetFeatureNameFor( mdi.Enties[ 0 ].Value.ToString(), out featureName ); //// Skip this one if unrecognised feature name //if ( !featureNameFound ) //{ // unrecognisedFeatureName++; // continue; //} // Skip this one if there is a zero 'Contours count' if (Convert.ToInt32(mdi.Enties[1].Value.ToString()) == 0) { noContours++; continue; } // Figure out if closed or open bool closed = (mdi.Enties[2].Value.ToString().CompareTo("1") == 0); // Now extract the sequence of x,y values Sequence pointSeq = ( Sequence )mdi.Enties[3].Value; Point[] points = new Point[pointSeq.Enties.Count]; for (int i = 0; i < pointSeq.Enties.Count; i++) { Mapping pointMap = ( Mapping )pointSeq.Enties[i]; Dictionary <String, Int32> coords = MappingConverter.convertToDictionary(pointMap, MappingConverter.KeyCase.FORCE_LOWER); bool found = true; int x = 0; int y = 0; found = found && coords.TryGetValue("x", out x); found = found && coords.TryGetValue("y", out y); Assert.True(found, "Could not convert coordinates"); points[i] = new Point(x, y); } // This feature is a multiple point path // features.Add( new LabelledFeature( featureName, new MultiPointPath( points, closed ) ) ); } } return(features); }
protected WireMockServer(IWireMockServerSettings settings) { _settings = settings; // Set default values if not provided _settings.Logger = settings.Logger ?? new WireMockNullLogger(); _settings.FileSystemHandler = settings.FileSystemHandler ?? new LocalFileSystemHandler(); _settings.Logger.Info("WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)"); _settings.Logger.Debug("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented)); HostUrlOptions urlOptions; if (settings.Urls != null) { urlOptions = new HostUrlOptions { Urls = settings.Urls }; } else { urlOptions = new HostUrlOptions { UseSSL = settings.UseSSL == true, Port = settings.Port }; } _options.FileSystemHandler = _settings.FileSystemHandler; _options.PreWireMockMiddlewareInit = _settings.PreWireMockMiddlewareInit; _options.PostWireMockMiddlewareInit = _settings.PostWireMockMiddlewareInit; _options.Logger = _settings.Logger; _options.DisableJsonBodyParsing = _settings.DisableJsonBodyParsing; _matcherMapper = new MatcherMapper(_settings); _mappingConverter = new MappingConverter(_matcherMapper); #if USE_ASPNETCORE _httpServer = new AspNetCoreSelfHost(_options, urlOptions); #else _httpServer = new OwinSelfHost(_options, urlOptions); #endif var startTask = _httpServer.StartAsync(); using (var ctsStartTimeout = new CancellationTokenSource(settings.StartTimeout)) { while (!_httpServer.IsStarted) { // Throw exception if service start fails if (_httpServer.RunningException != null) { throw new WireMockException($"Service start failed with error: {_httpServer.RunningException.Message}", _httpServer.RunningException); } if (ctsStartTimeout.IsCancellationRequested) { // In case of an aggregate exception, throw the exception. if (startTask.Exception != null) { throw new WireMockException($"Service start failed with error: {startTask.Exception.Message}", startTask.Exception); } // Else throw TimeoutException throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}"); } ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelayInMs); } Urls = _httpServer.Urls.ToArray(); Ports = _httpServer.Ports; } if (settings.AllowBodyForAllHttpMethods == true) { _options.AllowBodyForAllHttpMethods = _settings.AllowBodyForAllHttpMethods; _settings.Logger.Info("AllowBodyForAllHttpMethods is set to True"); } if (settings.AllowOnlyDefinedHttpStatusCodeInResponse == true) { _options.AllowOnlyDefinedHttpStatusCodeInResponse = _settings.AllowOnlyDefinedHttpStatusCodeInResponse; _settings.Logger.Info("AllowOnlyDefinedHttpStatusCodeInResponse is set to True"); } if (settings.AllowPartialMapping == true) { AllowPartialMapping(); } if (settings.StartAdminInterface == true) { if (!string.IsNullOrEmpty(settings.AdminUsername) && !string.IsNullOrEmpty(settings.AdminPassword)) { SetBasicAuthentication(settings.AdminUsername, settings.AdminPassword); } InitAdmin(); } if (settings.ReadStaticMappings == true) { ReadStaticMappings(); } if (settings.WatchStaticMappings == true) { WatchStaticMappings(); } if (settings.ProxyAndRecordSettings != null) { InitProxyAndRecord(settings); } if (settings.RequestLogExpirationDuration != null) { SetRequestLogExpirationDuration(settings.RequestLogExpirationDuration); } if (settings.MaxRequestLogCount != null) { SetMaxRequestLogCount(settings.MaxRequestLogCount); } }