Ejemplo n.º 1
0
        /// <summary>
        /// Inject javascript into the report
        /// </summary>
        /// <param name="Script">JavaScript</param>
        /// <returns>ReportConfig object</returns>
        public ReportConfig InsertJs(string Script)
        {
            Script = "<script type='text/javascript'>" + Script + "</script>";
            report.UpdateSource(report.Source.Replace(ExtentFlag.GetPlaceHolder("customscript"), Script + ExtentFlag.GetPlaceHolder("customscript")));

            return(this);
        }
Ejemplo n.º 2
0
        public static string GetSource <T>(List <T> MediaList, string type)
        {
            string source = "";

            if (MediaList == null || MediaList.Count == 0)
            {
                source = SourceBuilder.Build(
                    ObjectEmbedHtml.GetFullWidth(),
                    new string[] { ExtentFlag.GetPlaceHolder("objectViewValue"), ExtentFlag.GetPlaceHolder("objectViewNull") },
                    new string[] { "No media was embed for the tests in this report.", ExtentFlag.GetPlaceHolder("objectViewNull" + type) }
                    );

                return(source);
            }

            foreach (Object sc in MediaList)
            {
                source += ObjectEmbedHtml.GetColumn();

                if (sc is ScreenCapture)
                {
                    source = source.Replace(ExtentFlag.GetPlaceHolder("objectViewParam"), ((ScreenCapture)sc).TestName)
                             .Replace(ExtentFlag.GetPlaceHolder("objectViewValue"), ((ScreenCapture)sc).Source);
                }

                if (sc is Screencast)
                {
                    source = source.Replace(ExtentFlag.GetPlaceHolder("objectViewParam"), ((Screencast)sc).TestName)
                             .Replace(ExtentFlag.GetPlaceHolder("objectViewValue"), ((Screencast)sc).Source);
                }
            }

            return(source);
        }
Ejemplo n.º 3
0
        public static string GetQuickSummary(Test Test)
        {
            string source = TestHtml.GetQuickSummarySource();

            int passed  = Test.Logs.Count(x => x.LogStatus == LogStatus.Pass);
            int failed  = Test.Logs.Count(x => x.LogStatus == LogStatus.Fail);
            int fatal   = Test.Logs.Count(x => x.LogStatus == LogStatus.Fatal);
            int error   = Test.Logs.Count(x => x.LogStatus == LogStatus.Error);
            int warning = Test.Logs.Count(x => x.LogStatus == LogStatus.Warning);
            int skipped = Test.Logs.Count(x => x.LogStatus == LogStatus.Skip);
            int info    = Test.Logs.Count(x => x.LogStatus == LogStatus.Info);
            int unknown = Test.Logs.Count(x => x.LogStatus == LogStatus.Unknown);

            source = source.Replace(ExtentFlag.GetPlaceHolder("testName"), Test.Name)
                     .Replace(ExtentFlag.GetPlaceHolder("testWarnings"), TestHtml.GetWarningSource(Test.InternalWarning))
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestPassedCount"), "" + passed)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestFailedCount"), "" + failed)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestFatalCount"), "" + fatal)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestErrorCount"), "" + error)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestWarningCount"), "" + warning)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestInfoCount"), "" + info)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestSkippedCount"), "" + skipped)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestUnknownCount"), "" + unknown)
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestRunStatus"), "" + Test.Status.ToString().ToLower())
                     .Replace(ExtentFlag.GetPlaceHolder("currentTestRunStatusU"), "" + Test.Status.ToString());

            return(source);
        }
Ejemplo n.º 4
0
        private void UpdateCategoryList()
        {
            string catsAdded   = "";
            string c           = "";
            var    placeholder = "";

            for (int ix = categoryList.Categories.Count - 1; ix > -1; ix--)
            {
                c           = categoryList.GetItem(ix);
                placeholder = ExtentFlag.GetPlaceHolder("categoryAdded" + c);

                if (extentSource.IndexOf(placeholder) == -1 && catsAdded.IndexOf(placeholder) == -1)
                {
                    catsAdded += ExtentFlag.GetPlaceHolder("categoryAdded" + c);
                }
                else
                {
                    categoryList.Categories.RemoveAt(ix);
                }
            }

            string source = CategoryOptionBuilder.Build(categoryList.Categories);

            if (source != "")
            {
                lock (sourcelock)
                {
                    extentSource = SourceBuilder.Build(extentSource,
                                                       new string[] { ExtentFlag.GetPlaceHolder("categoryListOptions"), ExtentFlag.GetPlaceHolder("categoryAdded") },
                                                       new string[] { source + ExtentFlag.GetPlaceHolder("categoryListOptions"), catsAdded + ExtentFlag.GetPlaceHolder("categoryAdded") });
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Inject custom CSS into the report
        /// </summary>
        /// <param name="Styles">CSS styles</param>
        /// <returns>ReportConfig object</returns>
        public ReportConfig InsertStyles(string Styles)
        {
            Styles = "<style type='text/css'>" + Styles + "</style>";
            report.UpdateSource(report.Source.Replace(ExtentFlag.GetPlaceHolder("customcss"), Styles + ExtentFlag.GetPlaceHolder("customcss")));

            return(this);
        }
        internal static string Build(List <TestAttribute> Categories)
        {
            string source = "";

            var list = new List <string>();

            Categories
            .ToList()
            .ForEach(c => list.Add(c.GetName()));

            list.Sort();

            var catParams = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            list.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), catParams, catValues);
            });

            return(source);
        }
Ejemplo n.º 7
0
        private void UpdateSuiteExecutionTime()
        {
            string[] flags  = { ExtentFlag.GetPlaceHolder("suiteStartTime"), ExtentFlag.GetPlaceHolder("suiteEndTime") };
            string[] values = { runInfo.StartedTime.ToString(), runInfo.EndedTime.ToString() };

            lock (sourcelock)
            {
                extentSource = SourceBuilder.BuildRegex(extentSource, flags, values);
            }
        }
Ejemplo n.º 8
0
        private void UpdateMediaList()
        {
            string mediaSource = MediaViewBuilder.GetSource(mediaList.ScreenCapture, "img");

            string[] flags  = new string[] { ExtentFlag.GetPlaceHolder("imagesView") };
            string[] values = new string[] { mediaSource + ExtentFlag.GetPlaceHolder("imagesView") };

            if (!(infoWrite >= 1 && values[0].IndexOf("No media") >= 0))
            {
                lock (sourcelock)
                {
                    extentSource = SourceBuilder.BuildRegex(extentSource, flags, values);

                    if (mediaList.ScreenCapture.Count > 0)
                    {
                        try
                        {
                            string match = RegexMatcher.GetNthMatch(extentSource, ExtentFlag.GetPlaceHolder("objectViewNullImg") + ".*" + ExtentFlag.GetPlaceHolder("objectViewNullImg"), 0);
                            extentSource = extentSource.Replace(match, "");
                        }
                        catch { }
                    }

                    mediaList.ScreenCapture.Clear();
                }
            }

            mediaSource = MediaViewBuilder.GetSource(mediaList.Screencast, "vid");
            flags       = new string[] { ExtentFlag.GetPlaceHolder("videosView") };
            values      = new string[] { mediaSource + ExtentFlag.GetPlaceHolder("videosView") };

            if (!(infoWrite >= 1 && values[0].IndexOf("No media") >= 0))
            {
                lock (sourcelock)
                {
                    extentSource = SourceBuilder.BuildRegex(extentSource, flags, values);

                    if (mediaList.Screencast.Count > 0)
                    {
                        try
                        {
                            string match = RegexMatcher.GetNthMatch(extentSource, ExtentFlag.GetPlaceHolder("objectViewNullVid") + ".*" + ExtentFlag.GetPlaceHolder("objectViewNullVid"), 0);
                            extentSource = extentSource.Replace(match, "");
                        }
                        catch { }
                    }

                    mediaList.Screencast.Clear();
                }
            }

            infoWrite++;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Add a CSS stylesheet
        /// </summary>
        /// <param name="StylesheetPath">Path of .css file</param>
        /// <returns>ReportConfig object</returns>
        public ReportConfig AddStylesheet(string StylesheetPath)
        {
            string link = "<link href='file:///" + StylesheetPath + "' rel='stylesheet' type='text/css' />";

            if (StylesheetPath.StartsWith(".") || StylesheetPath.StartsWith("/"))
            {
                link = "<link href='" + StylesheetPath + "' rel='stylesheet' type='text/css' />";
            }

            report.UpdateSource(report.Source.Replace(ExtentFlag.GetPlaceHolder("customcss"), link + ExtentFlag.GetPlaceHolder("customcss")));

            return(this);
        }
Ejemplo n.º 10
0
        internal void WriteAllResources(List <ExtentTest> TestList, SystemInfo SystemInfo)
        {
            if (terminated)
            {
                throw new IOException("Stream closed");
            }

            if (SystemInfo != null)
            {
                UpdateSystemInfo(SystemInfo.GetInfo());
            }

            if (testSource == "")
            {
                return;
            }

            runInfo.EndedTime = DateTime.Now;

            UpdateCategoryList();
            UpdateSuiteExecutionTime();
            UpdateMediaList();

            if (this.displayOrder == DisplayOrder.OldestFirst)
            {
                lock (sourcelock)
                {
                    extentSource = SourceBuilder.Build(extentSource,
                                                       new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") },
                                                       new string[] { testSource + ExtentFlag.GetPlaceHolder("test"), quickSummarySource + ExtentFlag.GetPlaceHolder("quickTestSummary") });
                }
            }
            else
            {
                lock (sourcelock)
                {
                    extentSource = SourceBuilder.Build(extentSource,
                                                       new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") },
                                                       new string[] { ExtentFlag.GetPlaceHolder("test") + testSource, ExtentFlag.GetPlaceHolder("quickTestSummary") + quickSummarySource });
                }
            }

            using (var file = new StreamWriter(filePath))
            {
                TextWriter.Synchronized(file).WriteLine(extentSource);
            }

            testSource         = "";
            quickSummarySource = "";
        }
Ejemplo n.º 11
0
        public static string GetSource(Dictionary <string, string> Info)
        {
            string src = "";

            foreach (KeyValuePair <string, string> entry in Info)
            {
                src += SystemInfoHtml.GetColumn();

                src = src.Replace(ExtentFlag.GetPlaceHolder("systemInfoParam"), entry.Key)
                      .Replace(ExtentFlag.GetPlaceHolder("systemInfoValue"), entry.Value);
            }

            return(src);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Report headline
        /// </summary>
        /// <param name="Headline">A short headline</param>
        /// <returns>ReportConfig object</returns>
        public ReportConfig ReportHeadline(string Headline)
        {
            int maxlength = 70;

            if (Headline.Length >= maxlength)
            {
                Headline = Headline.Substring(0, maxlength - 1);
            }

            string pattern = ExtentFlag.GetPlaceHolder("headline") + ".*" + ExtentFlag.GetPlaceHolder("headline");

            Headline = pattern.Replace(".*", Headline);
            report.UpdateSource(report.Source.Replace(RegexMatcher.GetNthMatch(report.Source, pattern, 0), Headline));

            return(this);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Report Header
        /// </summary>
        /// <param name="Name">Header of the report</param>
        /// <returns>ReportConfig object</returns>
        public ReportConfig ReportName(string Name)
        {
            int maxlength = 20;

            if (Name.Length >= maxlength)
            {
                Name = Name.Substring(0, maxlength - 1);
            }

            string pattern = ExtentFlag.GetPlaceHolder("logo") + ".*" + ExtentFlag.GetPlaceHolder("logo");

            Name = pattern.Replace(".*", Name);
            report.UpdateSource(report.Source.Replace(RegexMatcher.GetNthMatch(report.Source, pattern, 0), Name));

            return(this);
        }
Ejemplo n.º 14
0
        public static string GetTestSource(Test Test)
        {
            string testSource = TestHtml.GetSource(3);
            string stepSource = StepHtml.GetSource(2);

            if (Test.Logs.Count > 0 && Test.Logs[0].StepName != "")
            {
                testSource = TestHtml.GetSource(4);
                stepSource = StepHtml.GetSource(-1);
            }

            if (Test.Description == "")
            {
                testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("descVis"), "style='display:none;'");
            }

            testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("testName"), Test.Name)
                         .Replace(ExtentFlag.GetPlaceHolder("testStatus"), Test.Status.ToString().ToLower())
                         .Replace(ExtentFlag.GetPlaceHolder("testStartTime"), Test.StartedTime.ToString())
                         .Replace(ExtentFlag.GetPlaceHolder("testEndTime"), Test.EndedTime.ToString())
                         .Replace(ExtentFlag.GetPlaceHolder("testTimeTaken"), (Test.EndedTime - Test.StartedTime).Minutes + "m " + (Test.EndedTime - Test.StartedTime).Seconds + "s")
                         .Replace(ExtentFlag.GetPlaceHolder("testDescription"), Test.Description)
                         .Replace(ExtentFlag.GetPlaceHolder("descVis"), "")
                         .Replace(ExtentFlag.GetPlaceHolder("category"), "")
                         .Replace(ExtentFlag.GetPlaceHolder("testWarnings"), TestHtml.GetWarningSource(Test.InternalWarning));

            foreach (TestAttribute t in Test.CategoryList)
            {
                testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("testCategory"), TestHtml.GetCategorySource() + ExtentFlag.GetPlaceHolder("testCategory"))
                             .Replace(ExtentFlag.GetPlaceHolder("category"), t.GetName());
            }

            foreach (var log in Test.Logs)
            {
                testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("step"), stepSource + ExtentFlag.GetPlaceHolder("step"))
                             .Replace(ExtentFlag.GetPlaceHolder("timeStamp"), log.Timestamp.ToShortTimeString())
                             .Replace(ExtentFlag.GetPlaceHolder("stepStatusU"), log.LogStatus.ToString().ToUpper())
                             .Replace(ExtentFlag.GetPlaceHolder("stepStatus"), log.LogStatus.ToString().ToLower())
                             .Replace(ExtentFlag.GetPlaceHolder("statusIcon"), Icon.GetIcon(log.LogStatus))
                             .Replace(ExtentFlag.GetPlaceHolder("stepName"), log.StepName)
                             .Replace(ExtentFlag.GetPlaceHolder("details"), log.Details);
            }

            testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("step"), "");

            return(testSource);
        }
Ejemplo n.º 15
0
        public static string GetQuickSummary(Test test)
        {
            if (test.IsChildNode)
            {
                return("");
            }

            string src = TestHtml.GetSourceQuickView();
            var    lc  = new LogCounts().GetLogCounts(test);

            string[] flags =
            {
                ExtentFlag.GetPlaceHolder("testName"),
                ExtentFlag.GetPlaceHolder("testWarnings"),
                ExtentFlag.GetPlaceHolder("currentTestPassedCount"),
                ExtentFlag.GetPlaceHolder("currentTestFailedCount"),
                ExtentFlag.GetPlaceHolder("currentTestFatalCount"),
                ExtentFlag.GetPlaceHolder("currentTestErrorCount"),
                ExtentFlag.GetPlaceHolder("currentTestWarningCount"),
                ExtentFlag.GetPlaceHolder("currentTestInfoCount"),
                ExtentFlag.GetPlaceHolder("currentTestSkippedCount"),
                ExtentFlag.GetPlaceHolder("currentTestUnknownCount"),
                ExtentFlag.GetPlaceHolder("currentTestRunStatus"),
                ExtentFlag.GetPlaceHolder("currentTestRunStatusU")
            };
            string[] values =
            {
                test.Name,
                TestHtml.GetWarningSource(test.InternalWarning),
                lc.Pass.ToString(),
                lc.Fail.ToString(),
                lc.Fatal.ToString(),
                lc.Error.ToString(),
                lc.Warning.ToString(),
                lc.Info.ToString(),
                lc.Skip.ToString(),
                lc.Unknown.ToString(),
                test.Status.ToString().ToLower(),
                test.Status.ToString().ToUpper()
            };

            src = SourceBuilder.Build(src, flags, values);

            return(src);
        }
Ejemplo n.º 16
0
        private void UpdateCategoryView(Test test)
        {
            string s = "", testSource = "";
            string addedFlag = "";

            string[] sourceKeys = { ExtentFlag.GetPlaceHolder("categoryViewName"),
                                    ExtentFlag.GetPlaceHolder("categoryViewTestDetails") };
            string[] testKeys = { ExtentFlag.GetPlaceHolder("categoryViewTestRunTime"),
                                  ExtentFlag.GetPlaceHolder("categoryViewTestName"),
                                  ExtentFlag.GetPlaceHolder("categoryViewTestStatus") };
            string[] testValues = { test.StartedTime.ToString(),
                                    test.Name,
                                    test.Status.ToString().ToLower() };

            foreach (TestAttribute attr in test.CategoryList)
            {
                addedFlag = ExtentFlag.GetPlaceHolder("categoryViewTestDetails" + attr.GetName());

                if (!extentSource.Contains(addedFlag))
                {
                    string[] sourceValues = { attr.GetName(), addedFlag };

                    s         += SourceBuilder.Build(CategoryHtml.GetCategoryViewSource(), sourceKeys, sourceValues);
                    testSource = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), testKeys, testValues);
                    s          = SourceBuilder.Build(s, new string[] { addedFlag }, new string[] { testSource + addedFlag });
                }
                else
                {
                    testSource = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), testKeys, testValues);

                    lock (sourcelock)
                    {
                        extentSource = SourceBuilder.Build(extentSource, new string[] { addedFlag }, new string[] { testSource + addedFlag });
                    }
                }
            }

            lock (sourcelock)
            {
                extentSource = SourceBuilder.Build(extentSource,
                                                   new string[] { ExtentFlag.GetPlaceHolder("extentCategoryDetails") },
                                                   new string[] { s + ExtentFlag.GetPlaceHolder("extentCategoryDetails") });
            }
        }
Ejemplo n.º 17
0
        private void UpdateSystemInfo(Dictionary <string, string> SystemInfo)
        {
            if (extentSource.IndexOf(ExtentFlag.GetPlaceHolder("systemInfoApplied")) > 0)
            {
                return;
            }

            if (SystemInfo.Count > 0)
            {
                string   systemSource = SourceBuilder.GetSource(SystemInfo) + ExtentFlag.GetPlaceHolder("systemInfoApplied");
                string[] flags        = new string[] { ExtentFlag.GetPlaceHolder("systemInfoView") };
                string[] values       = new string[] { systemSource + ExtentFlag.GetPlaceHolder("systemInfoView") };

                lock (sourcelock)
                {
                    extentSource = SourceBuilder.BuildRegex(extentSource, flags, values);
                }
            }
        }
Ejemplo n.º 18
0
        public static string buildOptions(List <string> Categories)
        {
            string source = "";

            Categories.Sort();

            var catFlags = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            Categories.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryHtml.GetOptionSource(), catFlags, catValues);
            });

            return(source);
        }
Ejemplo n.º 19
0
        private static string AddChildTests(Test test, String testSource, int nodeLevel)
        {
            string nodeSource, stepSrc = "";

            string[] testValues, stepValues;

            string[] testFlags =
            {
                ExtentFlag.GetPlaceHolder("nodeList"),
                ExtentFlag.GetPlaceHolder("nodeName"),
                ExtentFlag.GetPlaceHolder("nodeStartTime"),
                ExtentFlag.GetPlaceHolder("nodeEndTime"),
                ExtentFlag.GetPlaceHolder("nodeTimeTaken"),
                ExtentFlag.GetPlaceHolder("nodeLevel")
            };
            string[] stepFlags =
            {
                ExtentFlag.GetPlaceHolder("nodeStep"),
                ExtentFlag.GetPlaceHolder("timeStamp"),
                ExtentFlag.GetPlaceHolder("stepStatusU"),
                ExtentFlag.GetPlaceHolder("stepStatus"),
                ExtentFlag.GetPlaceHolder("statusIcon"),
                ExtentFlag.GetPlaceHolder("stepName"),
                ExtentFlag.GetPlaceHolder("details")
            };

            test.NodeList.ForEach(node =>
            {
                nodeSource = TestHtml.GetNodeSource(3);

                if (node.Logs.Count > 0 && node.Logs[0].StepName != "")
                {
                    nodeSource = TestHtml.GetNodeSource(4);
                }

                testValues = new string[] {
                    nodeSource + ExtentFlag.GetPlaceHolder("nodeList"),
                    node.Name,
                    node.StartedTime.ToString(),
                    node.EndedTime.ToString(),
                    (node.EndedTime - node.StartedTime).Minutes + "m " + (node.EndedTime - node.StartedTime).Seconds + "s",
                    "node-" + nodeLevel + "x"
                };

                testSource = SourceBuilder.Build(testSource, testFlags, testValues);

                if (node.Logs.Count > 0)
                {
                    testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("nodeStatus"), node.Status.ToString().ToLower());

                    stepSrc = StepHtml.GetSource(2);

                    if (node.Logs[0].StepName != "")
                    {
                        stepSrc = StepHtml.GetSource(3);
                    }

                    node.Logs.ForEach(log =>
                    {
                        stepValues = new string[] {
                            stepSrc + ExtentFlag.GetPlaceHolder("nodeStep"),
                            log.Timestamp.ToShortTimeString(),
                            log.LogStatus.ToString().ToUpper(),
                            log.LogStatus.ToString().ToLower(),
                            Icon.GetIcon(log.LogStatus),
                            log.StepName,
                            log.Details
                        };

                        testSource = SourceBuilder.Build(testSource, stepFlags, stepValues);
                    });
                }

                testSource = SourceBuilder.Build(testSource, new string[] { ExtentFlag.GetPlaceHolder("step"), ExtentFlag.GetPlaceHolder("nodeStep") }, new string[] { "", "" });

                if (node.HasChildNodes)
                {
                    testSource = AddChildTests(node, testSource, ++nodeLevel);
                    --nodeLevel;
                }
            });

            return(testSource);
        }
Ejemplo n.º 20
0
        internal static string Build(List <TestAttribute> Categories)
        {
            string source = "";

            var list = new List <string>();

            Categories.ToList().ForEach(c => list.Add(c.GetName()));
            list.Sort();

            foreach (string c in list)
            {
                source += SourceBuilder.BuildSimple(CategoryFilterHtml.GetOptionSource(), new string[] { ExtentFlag.GetPlaceHolder("testCategory"), ExtentFlag.GetPlaceHolder("testCategoryU") }, new string[] { c, c.ToLower().Replace(" ", "") });
            }

            return(source);
        }
Ejemplo n.º 21
0
        public static string buildOptions(List <string> Categories)
        {
            string source = "";

            Categories.Sort();

            foreach (string c in Categories)
            {
                source += SourceBuilder.BuildSimple(CategoryHtml.GetOptionSource(), new string[] { ExtentFlag.GetPlaceHolder("testCategory"), ExtentFlag.GetPlaceHolder("testCategoryU") }, new string[] { c, c.ToLower().Replace(" ", "") });
            }

            return(source);
        }
Ejemplo n.º 22
0
        public static string GetSource(Test test)
        {
            if (test.IsChildNode)
            {
                return("");
            }

            var testSource = TestHtml.GetSource(3);
            var stepSource = StepHtml.GetSource(2);

            if (test.Logs.Count > 0 && test.Logs[0].StepName != "")
            {
                testSource = TestHtml.GetSource(4);
                stepSource = StepHtml.GetSource(-1);
            }

            if (test.Description == "")
            {
                testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("descVis"), "style='display:none;'");
            }

            string[] testFlags =
            {
                ExtentFlag.GetPlaceHolder("testName"),
                ExtentFlag.GetPlaceHolder("testStatus"),
                ExtentFlag.GetPlaceHolder("testStartTime"),
                ExtentFlag.GetPlaceHolder("testEndTime"),
                ExtentFlag.GetPlaceHolder("testTimeTaken"),
                ExtentFlag.GetPlaceHolder("testDescription"),
                ExtentFlag.GetPlaceHolder("descVis"),
                ExtentFlag.GetPlaceHolder("category"),
                ExtentFlag.GetPlaceHolder("testWarnings")
            };
            string[] testValues =
            {
                test.Name,
                test.Status.ToString().ToLower(),
                test.StartedTime.ToString(),
                test.EndedTime.ToString(),
                (test.EndedTime - test.StartedTime).Minutes + "m " + (test.EndedTime - test.StartedTime).Seconds + "s",
                test.Description,
                "",
                "",
                TestHtml.GetWarningSource(test.InternalWarning)
            };

            testSource = SourceBuilder.Build(testSource, testFlags, testValues);

            testFlags = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("category")
            };

            test.CategoryList.ForEach(attr =>
            {
                testValues = new string[] {
                    TestHtml.GetCategorySource() + ExtentFlag.GetPlaceHolder("testCategory"),
                    attr.GetName()
                };

                testSource = SourceBuilder.Build(testSource, testFlags, testValues);
            });

            var stepSrc = StepHtml.GetSource(2);

            string[] stepFlags =
            {
                ExtentFlag.GetPlaceHolder("step"),
                ExtentFlag.GetPlaceHolder("timeStamp"),
                ExtentFlag.GetPlaceHolder("stepStatusU"),
                ExtentFlag.GetPlaceHolder("stepStatus"),
                ExtentFlag.GetPlaceHolder("statusIcon"),
                ExtentFlag.GetPlaceHolder("stepName"),
                ExtentFlag.GetPlaceHolder("details")
            };
            string[] stepValues;

            if (test.Logs.Count > 0)
            {
                if (test.Logs[0].StepName != "")
                {
                    stepSrc = StepHtml.GetSource(3);
                }

                test.Logs.ForEach(log =>
                {
                    stepValues = new string[] {
                        stepSrc + ExtentFlag.GetPlaceHolder("step"),
                        log.Timestamp.ToShortTimeString(),
                        log.LogStatus.ToString().ToUpper(),
                        log.LogStatus.ToString().ToLower(),
                        Icon.GetIcon(log.LogStatus),
                        log.StepName,
                        log.Details
                    };

                    testSource = SourceBuilder.Build(testSource, stepFlags, stepValues);
                });
            }

            testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("step"), "");

            testSource = AddChildTests(test, testSource, 1);

            return(testSource);
        }