private void UpdateCategoryList() { string text = string.Empty; for (int i = this.categoryList.Categories.Count - 1; i > -1; i--) { string item = this.categoryList.GetItem(i); string placeHolder = UnifiedReportFlag.GetPlaceHolder("categoryAdded" + item); if (this.unifiedReportSource.IndexOf(placeHolder) == -1 && text.IndexOf(placeHolder) == -1) { text += UnifiedReportFlag.GetPlaceHolder("categoryAdded" + item); } else { this.categoryList.Categories.RemoveAt(i); } } string text2 = CategoryOptionBuilder.Build(this.categoryList.Categories); if (!string.IsNullOrEmpty(text2)) { lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.Build(this.unifiedReportSource, new string[] { UnifiedReportFlag.GetPlaceHolder("categoryListOptions"), UnifiedReportFlag.GetPlaceHolder("categoryAdded") }, new string[] { text2 + UnifiedReportFlag.GetPlaceHolder("categoryListOptions"), text + UnifiedReportFlag.GetPlaceHolder("categoryAdded") }); } } }
public static string GetSource <T>(List <T> MediaList, string type) { string text = string.Empty; string result; if (MediaList == null || MediaList.Count == 0) { text = ObjectEmbedHtml.GetFullWidth().Replace(UnifiedReportFlag.GetPlaceHolder("objectViewValue"), "No media was embed for the tests in this report.").Replace(UnifiedReportFlag.GetPlaceHolder("objectViewNull"), UnifiedReportFlag.GetPlaceHolder("objectViewNull" + type)); result = text; } else { foreach (object obj in MediaList) { text += ObjectEmbedHtml.GetColumn(); if (obj is ScreenCapture) { text = text.Replace(UnifiedReportFlag.GetPlaceHolder("objectViewParam"), ((ScreenCapture)obj).TestName).Replace(UnifiedReportFlag.GetPlaceHolder("objectViewValue"), ((ScreenCapture)obj).Source); } if (obj is Screencast) { text = text.Replace(UnifiedReportFlag.GetPlaceHolder("objectViewParam"), ((Screencast)obj).TestName).Replace(UnifiedReportFlag.GetPlaceHolder("objectViewValue"), ((Screencast)obj).Source); } } result = text; } return(result); }
internal void WriteAllResources(List <UnifiedTest> TestList, SystemInfo SystemInfo) { if (this.terminated) { throw new IOException("Stream closed"); } if (SystemInfo != null) { this.UpdateSystemInfo(SystemInfo.GetInfo()); } if (!(this.testSource == "")) { this.runInfo.EndedTime = DateTime.Now; this.UpdateCategoryList(); this.UpdateSuiteExecutionTime(); this.UpdateMediaList(); if (this.displayOrder == DisplayOrder.OldestFirst) { lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.Build(this.unifiedReportSource, new string[] { UnifiedReportFlag.GetPlaceHolder("test"), UnifiedReportFlag.GetPlaceHolder("quickTestSummary") }, new string[] { this.testSource + UnifiedReportFlag.GetPlaceHolder("test"), this.quickSummarySource + UnifiedReportFlag.GetPlaceHolder("quickTestSummary") }); } } else { lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.Build(this.unifiedReportSource, new string[] { UnifiedReportFlag.GetPlaceHolder("test"), UnifiedReportFlag.GetPlaceHolder("quickTestSummary") }, new string[] { UnifiedReportFlag.GetPlaceHolder("test") + this.testSource, UnifiedReportFlag.GetPlaceHolder("quickTestSummary") + this.quickSummarySource }); } } using (StreamWriter streamWriter = new StreamWriter(this.filePath)) { TextWriter.Synchronized(streamWriter).WriteLine(this.unifiedReportSource); } this.testSource = string.Empty; this.quickSummarySource = string.Empty; } }
public ReportConfig AddStylesheet(string StylesheetPath) { string str = "<link href='file:///" + StylesheetPath + "' rel='stylesheet' type='text/css' />"; if (StylesheetPath.StartsWith(".") || StylesheetPath.StartsWith("/")) { str = "<link href='" + StylesheetPath + "' rel='stylesheet' type='text/css' />"; } this.report.UpdateSource(this.report.Source.Replace(UnifiedReportFlag.GetPlaceHolder("customcss"), str + UnifiedReportFlag.GetPlaceHolder("customcss"))); return(this); }
public static string GetSource(Dictionary <string, string> Info) { string text = string.Empty; foreach (KeyValuePair <string, string> current in Info) { text += SystemInfoHtml.GetColumn(); text = text.Replace(UnifiedReportFlag.GetPlaceHolder("systemInfoParam"), current.Key).Replace(UnifiedReportFlag.GetPlaceHolder("systemInfoValue"), current.Value); } return(text); }
public ReportConfig ReportName(string Name) { int num = 20; if (Name.Length >= num) { Name = Name.Substring(0, num - 1); } string text = UnifiedReportFlag.GetPlaceHolder("logo") + ".*" + UnifiedReportFlag.GetPlaceHolder("logo"); Name = text.Replace(".*", Name); this.report.UpdateSource(this.report.Source.Replace(RegexMatcher.GetNthMatch(this.report.Source, text, 0), Name)); return(this); }
public ReportConfig ReportRightSideText(string Headline) { int num = 30; if (Headline.Length >= num) { Headline = Headline.Substring(0, num - 1); } string text = UnifiedReportFlag.GetPlaceHolder("rightsidetext") + ".*" + UnifiedReportFlag.GetPlaceHolder("rightsidetext"); Headline = text.Replace(".*", Headline); this.report.UpdateSource(this.report.Source.Replace(RegexMatcher.GetNthMatch(this.report.Source, text, 0), Headline)); return(this); }
public static string GetQuickSummary(Test test) { string result; if (test.IsChildNode) { result = string.Empty; } else { string text = TestHtml.GetSourceQuickView(); LogCounts logCounts = new LogCounts().GetLogCounts(test); string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("testName"), UnifiedReportFlag.GetPlaceHolder("testWarnings"), UnifiedReportFlag.GetPlaceHolder("currentTestPassedCount"), UnifiedReportFlag.GetPlaceHolder("currentTestFailedCount"), UnifiedReportFlag.GetPlaceHolder("currentTestFatalCount"), UnifiedReportFlag.GetPlaceHolder("currentTestErrorCount"), UnifiedReportFlag.GetPlaceHolder("currentTestWarningCount"), UnifiedReportFlag.GetPlaceHolder("currentTestInfoCount"), UnifiedReportFlag.GetPlaceHolder("currentTestSkippedCount"), UnifiedReportFlag.GetPlaceHolder("currentTestUnknownCount"), UnifiedReportFlag.GetPlaceHolder("currentTestRunStatus"), UnifiedReportFlag.GetPlaceHolder("currentTestRunStatusU") }; string[] values = new string[] { test.Name, TestHtml.GetWarningSource(test.InternalWarning), logCounts.Pass.ToString(), logCounts.Fail.ToString(), logCounts.Fatal.ToString(), logCounts.Error.ToString(), logCounts.Warning.ToString(), logCounts.Info.ToString(), logCounts.Skip.ToString(), logCounts.Unknown.ToString(), test.Status.ToString().ToLower(), test.Status.ToString().ToUpper() }; text = SourceBuilder.Build(text, flags, values); result = text; } return(result); }
private void UpdateSuiteExecutionTime() { string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("suiteStartTime"), UnifiedReportFlag.GetPlaceHolder("suiteEndTime") }; string[] values = new string[] { this.runInfo.StartedTime.ToString(), this.runInfo.EndedTime.ToString() }; lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.BuildRegex(this.unifiedReportSource, flags, values); } }
public static string buildOptions(List <string> Categories) { string text = string.Empty; Categories.Sort(); foreach (var current in Categories) { text += SourceBuilder.Build(CategoryHtml.GetOptionSource(), new string[] { UnifiedReportFlag.GetPlaceHolder("testCategory"), UnifiedReportFlag.GetPlaceHolder("testCategoryU") }, new string[] { current, current.ToLower().Replace(" ", "") }); } return(text); }
private void UpdateSystemInfo(Dictionary <string, string> SystemInfo) { if (this.unifiedReportSource.IndexOf(UnifiedReportFlag.GetPlaceHolder("systemInfoApplied")) <= 0) { if (SystemInfo.Count > 0) { string str = SourceBuilder.GetSource(SystemInfo) + UnifiedReportFlag.GetPlaceHolder("systemInfoApplied"); string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("systemInfoView") }; string[] values = new string[] { str + UnifiedReportFlag.GetPlaceHolder("systemInfoView") }; lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.BuildRegex(this.unifiedReportSource, flags, values); } } } }
internal static string Build(List <TestAttribute> Categories) { string text = string.Empty; List <string> list = new List <string>(); Categories.ToList <TestAttribute>().ForEach(delegate(TestAttribute c) { list.Add(c.GetName()); }); list.Sort(); foreach (var current in list) { text += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), new string[] { UnifiedReportFlag.GetPlaceHolder("testCategory"), UnifiedReportFlag.GetPlaceHolder("testCategoryU") }, new string[] { current, current.ToLower().Replace(" ", "") }); } return(text); }
private void UpdateMediaList() { string source = MediaViewBuilder.GetSource <ScreenCapture>(this.mediaList.ScreenCapture, "img"); string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("imagesView") }; string[] array = new string[] { source + UnifiedReportFlag.GetPlaceHolder("imagesView") }; if (this.infoWrite < 1 || array[0].IndexOf("No media") < 0) { lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.BuildRegex(this.unifiedReportSource, flags, array); if (this.mediaList.ScreenCapture.Count > 0) { try { string nthMatch = RegexMatcher.GetNthMatch(this.unifiedReportSource, UnifiedReportFlag.GetPlaceHolder("objectViewNullImg") + ".*" + UnifiedReportFlag.GetPlaceHolder("objectViewNullImg"), 0); this.unifiedReportSource = this.unifiedReportSource.Replace(nthMatch, ""); } catch { } } this.mediaList.ScreenCapture.Clear(); } } source = MediaViewBuilder.GetSource <Screencast>(this.mediaList.Screencast, "vid"); flags = new string[] { UnifiedReportFlag.GetPlaceHolder("videosView") }; array = new string[] { source + UnifiedReportFlag.GetPlaceHolder("videosView") }; if (this.infoWrite < 1 || array[0].IndexOf("No media") < 0) { lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.BuildRegex(this.unifiedReportSource, flags, array); if (this.mediaList.Screencast.Count > 0) { try { string nthMatch = RegexMatcher.GetNthMatch(this.unifiedReportSource, UnifiedReportFlag.GetPlaceHolder("objectViewNullVid") + ".*" + UnifiedReportFlag.GetPlaceHolder("objectViewNullVid"), 0); this.unifiedReportSource = this.unifiedReportSource.Replace(nthMatch, ""); } catch { } } this.mediaList.Screencast.Clear(); } } this.infoWrite++; }
public static string GetSource(Test test) { string result; if (test.IsChildNode) { result = string.Empty; } else { string text = TestHtml.GetSource(3); string source = StepHtml.GetSource(2); if (test.Logs.Count > 0 && test.Logs[0].StepName != "") { text = TestHtml.GetSource(4); source = StepHtml.GetSource(-1); } if (string.IsNullOrEmpty(test.Description)) { text = text.Replace(UnifiedReportFlag.GetPlaceHolder("descVis"), "style='display:none;'"); } string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("testName"), UnifiedReportFlag.GetPlaceHolder("testStatus"), UnifiedReportFlag.GetPlaceHolder("testStartTime"), UnifiedReportFlag.GetPlaceHolder("testEndTime"), UnifiedReportFlag.GetPlaceHolder("testTimeTaken"), UnifiedReportFlag.GetPlaceHolder("testDescription"), UnifiedReportFlag.GetPlaceHolder("descVis"), UnifiedReportFlag.GetPlaceHolder("category"), UnifiedReportFlag.GetPlaceHolder("testWarnings") }; string[] values = new string[] { test.Name, test.Status.ToString().ToLower(), test.StartedTime.ToString(), test.EndedTime.ToString(), string.Concat(new object[] { (test.EndedTime - test.StartedTime).Minutes, "m ", (test.EndedTime - test.StartedTime).Seconds, "s" }), test.Description, "", "", TestHtml.GetWarningSource(test.InternalWarning) }; text = SourceBuilder.Build(text, flags, values); foreach (TestAttribute current in test.CategoryList) { text = text.Replace(UnifiedReportFlag.GetPlaceHolder("testCategory"), TestHtml.GetCategorySource() + UnifiedReportFlag.GetPlaceHolder("testCategory")).Replace(UnifiedReportFlag.GetPlaceHolder("category"), current.GetName()); } string source2 = StepHtml.GetSource(2); string[] flags2 = new string[] { UnifiedReportFlag.GetPlaceHolder("step"), UnifiedReportFlag.GetPlaceHolder("timeStamp"), UnifiedReportFlag.GetPlaceHolder("stepStatusU"), UnifiedReportFlag.GetPlaceHolder("stepStatus"), UnifiedReportFlag.GetPlaceHolder("statusIcon"), UnifiedReportFlag.GetPlaceHolder("stepName"), UnifiedReportFlag.GetPlaceHolder("details") }; if (test.Logs.Count > 0) { if (!string.IsNullOrEmpty(test.Logs[0].StepName)) { source2 = StepHtml.GetSource(3); } for (int i = 0; i < test.Logs.Count; i++) { string[] values2 = new string[] { source2 + UnifiedReportFlag.GetPlaceHolder("step"), test.Logs[i].Timestamp.ToShortTimeString(), test.Logs[i].LogStatus.ToString().ToUpper(), test.Logs[i].LogStatus.ToString().ToLower(), Icon.GetIcon(test.Logs[i].LogStatus), test.Logs[i].StepName, test.Logs[i].Details }; text = SourceBuilder.Build(text, flags2, values2); } } text = text.Replace(UnifiedReportFlag.GetPlaceHolder("step"), ""); text = TestBuilder.AddChildTests(test, text, 1); result = text; } return(result); }
private void UpdateCategoryView(Test test) { string text = string.Empty; string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("categoryViewName"), UnifiedReportFlag.GetPlaceHolder("categoryViewTestDetails") }; string[] flags2 = new string[] { UnifiedReportFlag.GetPlaceHolder("categoryViewTestRunTime"), UnifiedReportFlag.GetPlaceHolder("categoryViewTestName"), UnifiedReportFlag.GetPlaceHolder("categoryViewTestStatus") }; string[] values = new string[] { test.StartedTime.ToString(), test.Name, test.Status.ToString().ToLower() }; foreach (TestAttribute current in test.CategoryList) { string placeHolder = UnifiedReportFlag.GetPlaceHolder("categoryViewTestDetails" + current.GetName()); if (!this.unifiedReportSource.Contains(placeHolder)) { string[] values2 = new string[] { current.GetName(), placeHolder }; text += SourceBuilder.Build(CategoryHtml.GetCategoryViewSource(), flags, values2); string str = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), flags2, values); text = SourceBuilder.Build(text, new string[] { placeHolder }, new string[] { str + placeHolder }); } else { string str = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), flags2, values); lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.Build(this.unifiedReportSource, new string[] { placeHolder }, new string[] { str + placeHolder }); } } } lock (this.sourcelock) { this.unifiedReportSource = SourceBuilder.Build(this.unifiedReportSource, new string[] { UnifiedReportFlag.GetPlaceHolder("extentCategoryDetails") }, new string[] { text + UnifiedReportFlag.GetPlaceHolder("extentCategoryDetails") }); } }
public ReportConfig InsertStyles(string Styles) { Styles = "<style type='text/css'>" + Styles + "</style>"; this.report.UpdateSource(this.report.Source.Replace(UnifiedReportFlag.GetPlaceHolder("customcss"), Styles + UnifiedReportFlag.GetPlaceHolder("customcss"))); return(this); }
public ReportConfig InsertJs(string Script) { Script = "<script type='text/javascript'>" + Script + "</script>"; this.report.UpdateSource(this.report.Source.Replace(UnifiedReportFlag.GetPlaceHolder("customscript"), Script + UnifiedReportFlag.GetPlaceHolder("customscript"))); return(this); }
private static string AddChildTests(Test test, string testSource, int nodeLevel) { string[] flags = new string[] { UnifiedReportFlag.GetPlaceHolder("nodeList"), UnifiedReportFlag.GetPlaceHolder("nodeName"), UnifiedReportFlag.GetPlaceHolder("nodeStartTime"), UnifiedReportFlag.GetPlaceHolder("nodeEndTime"), UnifiedReportFlag.GetPlaceHolder("nodeTimeTaken"), UnifiedReportFlag.GetPlaceHolder("nodeLevel") }; string[] flags2 = new string[] { UnifiedReportFlag.GetPlaceHolder("nodeStep"), UnifiedReportFlag.GetPlaceHolder("timeStamp"), UnifiedReportFlag.GetPlaceHolder("stepStatusU"), UnifiedReportFlag.GetPlaceHolder("stepStatus"), UnifiedReportFlag.GetPlaceHolder("statusIcon"), UnifiedReportFlag.GetPlaceHolder("stepName"), UnifiedReportFlag.GetPlaceHolder("details") }; foreach (Test current in test.NodeList) { string nodeSource = TestHtml.GetNodeSource(3); if (current.Logs.Count > 0 && current.Logs[0].StepName != "") { nodeSource = TestHtml.GetNodeSource(4); } string[] values = new string[] { nodeSource + UnifiedReportFlag.GetPlaceHolder("nodeList"), current.Name, current.StartedTime.ToString(), current.EndedTime.ToString(), string.Concat(new object[] { (current.EndedTime - current.StartedTime).Minutes, "m ", (current.EndedTime - current.StartedTime).Seconds, "s" }), "node-" + nodeLevel + "x" }; testSource = SourceBuilder.Build(testSource, flags, values); if (current.Logs.Count > 0) { testSource = testSource.Replace(UnifiedReportFlag.GetPlaceHolder("nodeStatus"), current.Status.ToString().ToLower()); string source = StepHtml.GetSource(2); if (current.Logs[0].StepName != "") { source = StepHtml.GetSource(3); } for (int i = 0; i < current.Logs.Count; i++) { string[] values2 = new string[] { source + UnifiedReportFlag.GetPlaceHolder("nodeStep"), current.Logs[i].Timestamp.ToShortTimeString(), current.Logs[i].LogStatus.ToString().ToUpper(), current.Logs[i].LogStatus.ToString().ToLower(), Icon.GetIcon(current.Logs[i].LogStatus), current.Logs[i].StepName, current.Logs[i].Details }; testSource = SourceBuilder.Build(testSource, flags2, values2); } } testSource = SourceBuilder.Build(testSource, new string[] { UnifiedReportFlag.GetPlaceHolder("step"), UnifiedReportFlag.GetPlaceHolder("nodeStep") }, new string[] { string.Empty, string.Empty } ); if (current.HasChildNodes) { testSource = TestBuilder.AddChildTests(current, testSource, ++nodeLevel); nodeLevel--; } } return(testSource); }