protected override bool Visit(ITestSkipped testSkipped) { var testCase = testCases.Single(tc => tc.DisplayName == testSkipped.TestCase.DisplayName); testCase.State = TestState.Skipped; TestFinished?.Invoke(this, TestStateEventArgs.Skipped); return(!isCancelRequested()); }
private async Task TestConnection(ConnectionData connectionData) { ReportConnectionTestStarted(); var failed = false; if (connectionData.ConnectionType == ConnectionPluginType.Build) { var buildPlugin = _pluginRepository.FindBuildPlugin(connectionData.PluginType); if (buildPlugin == null) { ReportError("ConnectionTestFailed", "NoConnectionSetup"); failed = true; } if (buildPlugin != null && connectionData.PluginConfiguration != null) { var buildResult = await buildPlugin.TestConnection(connectionData.PluginConfiguration); if (!buildResult.IsSuccess) { failed = true; ReportError("BuildConnectionTestFailed", buildResult.ErrorMessage); } } } else if (connectionData.ConnectionType == ConnectionPluginType.SourceControl) { var sourcePlugin = _pluginRepository.FindSourceControlPlugin(connectionData.PluginType); if (sourcePlugin == null) { ReportError("ConnectionTestFailed", "NoConnectionSetup"); failed = true; } if (sourcePlugin != null && connectionData.PluginConfiguration != null) { var sourceResult = await sourcePlugin.TestConnection(connectionData.PluginConfiguration); if (!sourceResult.IsSuccess) { failed = true; ReportError("SourceConnectionTestFailed", sourceResult.ErrorMessage); } } } if (!failed) { ReportSuccess(); } DispatchOnUiThread(() => { TestFinished?.Invoke(this, EventArgs.Empty); }); }
public void Run() { try { IMGAlgoritm mgAlgoritm = new CLMGAlgoritm(SettingGen); DbMap outDbMap; string message; Stopwatch stopwatch = new Stopwatch(); stopwatch.Reset(); stopwatch.Start(); bool isSuccess = mgAlgoritm.Execute(Scale, DbMap, out outDbMap, out message); stopwatch.Stop(); TestResult testResult = new TestResult { IdTestCase = Id, Time = stopwatch.ElapsedMilliseconds, IsSuccess = isSuccess }; string dirResultTests = $"{ResourceModel.DIR_TESTS}\\Test_{Id}"; if (!Directory.Exists(dirResultTests)) { Directory.CreateDirectory(dirResultTests); } // Отрисовываем исходную карту. Methods.DeleteAllElementsOnDirectry(dirResultTests); DbMap.DrawToBMP($"{dirResultTests}\\{ResourceModel.FILENAME_BEFORE_BMP}"); // Отрисовываем результирующую карту. DbMap.DrawToBMP(mgAlgoritm.Clusters, $"{dirResultTests}\\{ResourceModel.FILENAME_AFTER_BMP}"); // Сохраняем в файл результаты теста с настройкой. string distScaleInfo = $"Масштаб теста: 1:{Scale}"; string testInfo = $"{DbMap}\n{distScaleInfo}\n{SettingGen}\n{testResult}"; File.WriteAllText($"{dirResultTests}\\{ResourceModel.FILENAME_TESTINFO}", testInfo); TestFinished?.Invoke(testResult); } catch (Exception ex) { } }
protected override bool Visit(ITestFailed testFailed) { var testCase = testCases.Single(tc => tc.DisplayName == testFailed.TestCase.DisplayName); testCase.State = TestState.Failed; var resultString = new StringBuilder(testFailed.TestCase.DisplayName); resultString.AppendLine(" FAILED:"); for (int i = 0; i < testFailed.ExceptionTypes.Length; i++) { resultString.AppendLine($"\tException type: '{testFailed.ExceptionTypes[i]}', number: '{i}', parent: '{testFailed.ExceptionParentIndices[i]}'"); resultString.AppendLine($"\tException message:"); resultString.AppendLine(testFailed.Messages[i]); resultString.AppendLine($"\tException stacktrace"); resultString.AppendLine(testFailed.StackTraces[i]); } resultString.AppendLine(); TestFinished?.Invoke(this, TestStateEventArgs.Failed(resultString.ToString())); return(!isCancelRequested()); }
void OnTestCase(XElement xml) { var testResult = ParseTestResult(xml); string output = null; if (testResult.Messages.Count > 0) { output = testResult.Messages[0]; } else if (testResult.Outcome != TestOutcome.None) { output = testResult.Outcome.ToString(); } TestFinished?.Invoke(this, new TestEventArgs(testResult.Test.FullyQualifiedName, output)); if (Options.DesignTime) { _sink?.SendTestResult(testResult); } }
public void OnTestEvent(string report) { XmlNode xmlNode = XmlHelper.CreateXmlNode(report); switch (xmlNode.Name) { case "start-test": TestStarting?.Invoke(new TestNodeEventArgs(TestAction.TestStarting, new TestNode(xmlNode))); break; case "start-suite": SuiteStarting?.Invoke(new TestNodeEventArgs(TestAction.SuiteStarting, new TestNode(xmlNode))); break; case "start-run": RunStarting?.Invoke(new RunStartingEventArgs(xmlNode.GetAttribute("count", -1))); break; case "test-case": ResultNode result = new ResultNode(xmlNode); _resultIndex[result.Id] = result; TestFinished?.Invoke(new TestResultEventArgs(TestAction.TestFinished, result)); break; case "test-suite": result = new ResultNode(xmlNode); _resultIndex[result.Id] = result; SuiteFinished?.Invoke(new TestResultEventArgs(TestAction.SuiteFinished, result)); break; case "test-run": result = new ResultNode(xmlNode); _resultIndex[result.Id] = result; RunFinished?.Invoke(new TestResultEventArgs(TestAction.RunFinished, result)); break; } }
private void TestFinishedAction(TestResult testResult) { TestFinished?.Invoke(testResult); }
protected virtual void OnTestFinished(UnitTestResultEventArgs e) => TestFinished?.Invoke(this, e);
public async Task Start(Uri targetUri) { if (!(await IsRemoteServerAlive(targetUri))) { throw new WebException("No response from external server"); } resultDetails = new ConcurrentBag <TestResultDetail>(); processedPages = new ConcurrentDictionary <string, byte>(); result = new TestResult() { Authority = targetUri.AbsoluteUri, TestDate = DateTime.Now, Status = 1 }; RepositoryInsertRequested?.Invoke(this, new TestResultArgs(result)); CrawlConfiguration configuration = new CrawlConfiguration() { MaxPagesToCrawl = MaxPagesToCrawl, MaxCrawlDepth = MaxCrawlDepth, IsExternalPageCrawlingEnabled = IsExternalPageCrawlingEnabled, IsExternalPageLinksCrawlingEnabled = IsExternalPageLinksCrawlingEnabled, NumberOfRecurrentRequests = NumberOfRecurrentRequests, MaxConcurrentThreads = MaxConcurrentThreads }; PoliteWebCrawler crawler = new PoliteWebCrawler(configuration, crawlDecisionMaker: null, memoryManager: null, scheduler: null, hyperLinkParser: null, domainRateLimiter: null, robotsDotTextFinder: null, threadManager: null, pageRequester: new PageRequesterWithRepeats(configuration)); crawler.PageRequestSent += Crawler_PageRequestSent; crawler.PageResponseReceived += Crawler_PageResponseReceived; crawler.PageCrawlCompleted += Crawler_ProcessPageCrawlCompleted; crawler.ShouldCrawlPage((pageToCrawl, crawlContext) => { CrawlDecision decision = new CrawlDecision { Allow = true }; MatchCollection mc = Regex.Matches((pageToCrawl.Uri.AbsoluteUri), @"http[s]?:\/\/"); if (mc.Count > 1) { return new CrawlDecision { Allow = false, Reason = "Dont want to crawl external pages" } } ; return(decision); }); TestStarted?.Invoke(this, new TestResultArgs(result)); crawler.Crawl(targetUri); result.TestResultDetails = resultDetails.ToList(); result.MinResponseTime = rootMinResponseTime; result.MaxResponseTime = rootMaxResponseTime; result.MeanResponseTime = rootMeanResponseTime / numberOfPagesCrawled; result.Status = 0; TestFinished?.Invoke(this, new TestResultArgs(result)); RepositoryInsertDetailsRequested?.Invoke(this, new TestResultArgs(result)); }
public void Start(TestResult root) { using (HttpClient client = new HttpClient()) { var testBlock = new ActionBlock <TestResultDetail>(async item => { Stopwatch timer = new Stopwatch(); double mean = 0; for (int i = 1; i <= NumberOfRecurrentRequests; ++i) { timer.Start(); await client.GetAsync(item.Uri); timer.Stop(); long responseTime = timer.ElapsedMilliseconds; timer.Reset(); if (i == 1) { ProcessFirstItem(item, responseTime); } else { ProcessItem(item, responseTime); } mean += responseTime / NumberOfRecurrentRequests; } item.MeanResponseTime = mean; PageTestingCompleted?.Invoke(this, new PageTestingCompletedArgs(item)); lock (mainLock) { rootMeanResponseTime += item.MeanResponseTime; if (item.MinResponseTime < rootMinResponseTime) { rootMinResponseTime = item.MinResponseTime; } if (item.MaxResponseTime > rootMaxResponseTime) { rootMaxResponseTime = item.MaxResponseTime; } } }, new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = MaxConcurrentThreads }); foreach (var item in root.TestResultDetails) { testBlock.Post(item); } testBlock.Complete(); root.TestDate = DateTime.Now; root.Status = 1; RepositoryUpdateRequested?.Invoke(this, new TestResultArgs(root)); TestStarted?.Invoke(this, new TestResultArgs(root)); testBlock.Completion.Wait(); } root.MinResponseTime = rootMinResponseTime; root.MaxResponseTime = rootMaxResponseTime; root.MeanResponseTime = rootMeanResponseTime / root.TestResultDetails.Count; root.Status = 0; TestFinished?.Invoke(this, new TestResultArgs(root)); RepositoryUpdateRequested?.Invoke(this, new TestResultArgs(root)); }
private void OnTestFinished() { TestFinished? .Invoke(this, EventArgs.Empty); }
private void OnTestFinished(System.EventArgs e) { TestFinished?.Invoke(this, e); }
private void OnTestFinished(object sender, System.EventArgs e) { TestFinished?.Invoke(sender, e); }
private void TestFinishedHandler(TestResult testResult) { TestFinished?.Invoke(testResult); }