コード例 #1
0
        public static HtmlDocument CreateAllTestsGroupedByClassesTable(HtmlDocument doc, TestLoadResult testLoadResult)
        {
            //create main table
            Table table = new Table("ReportsTable", "centerTable", "All Tests Grouped By Classes");

            //create table header row
            Row tableHeadRow = new Row("", "");

            Cell[] tableHeadRowCells = new Cell[]
            {
                new Cell("", "", "", true),
                new Cell("", "", "", true),
                new Cell("Class Name", "summaryClassTests", "", true),
                new Cell("All", "", "all", true),
                new Cell("Passed", "", "passed", true),
                new Cell("Failed", "", "failed", true),
                new Cell("Warning", "", "warning", true),
                new Cell("Inconclusive", "", "inconclusive", true),
                new Cell("Not Executed", "", "not executed", true),
                new Cell("", "", "", true),
                new Cell("", "", "", true)
            };

            tableHeadRow.Add(tableHeadRowCells);
            table.Add(tableHeadRow);

            //create table show-hide rows
            foreach (string testedClass in testLoadResult.AllTestedClasses)
            {
                //create head row for show-hide row
                string resultColor  = summaryResultColor(testedClass, testLoadResult);
                Row    headRow      = new Row("", testedClass);
                Cell[] headRowCells = new Cell[]
                {
                    new Cell("", "marginCell", "", false),
                    new Cell("", resultColor, "", false),
                    new Cell(testedClass, "leftAlign", "", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Count().ToString(), "statusCount", "number", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Where(t => t.Result == "Passed").Count().ToString(), "statusCount", "number", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Where(t => t.Result == "Failed").Count().ToString(), "statusCount", "number", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Where(t => t.Result == "Warning").Count().ToString(), "statusCount", "number", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Where(t => t.Result == "Inconclusive").Count().ToString(), "statusCount", "number", false),
                    new Cell(testLoadResult.tests.Where(c => c.ClassName == testedClass).Where(t => t.Result == "NotExecuted").Count().ToString(), "statusCount", "number", false),
                    new Cell("", "ex", "", false)
                };
                headRow.Add(headRowCells);

                //create container table and its head row
                Row    contentHeadRow      = new Row("", "");
                string tableId             = testedClass + "Table";
                Cell[] contentHeadRowCells = new Cell[]
                {
                    new Cell("Status", "TestsTableHeaderFirst", "", true, onClick: $"sortTable(0, '{tableId}', this)"),
                    new Cell("Test", "TestsTableHeader", "", true, onClick: $"sortTable(1, '{tableId}', this)"),
                    new Cell("Start Time", "TestsTableHeader", "", true, onClick: $"sortTable(2, '{tableId}', this)"),
                    new Cell("Duration", "TestsTableHeaderLast", "", true, onClick: $"sortTable(3, '{tableId}', this)")
                };
                contentHeadRow.Add(contentHeadRowCells);

                Table containerTable = new Table(tableId, "showHideTable", contentHeadRow);

                //create container table body
                foreach (Test test in testLoadResult.tests.Where(PredicateCreator(t => t.ClassName, testedClass)))
                {
                    Row    testRow   = new Row("Test", test.ID);
                    Cell[] testCells = new Cell[]
                    {
                        new Cell(CreateColoredResult(test.Result, test.Message), test.Result, "", false),
                        new Cell(test.MethodName, "leftAlign", "", false),
                        new Cell(DateTime.Parse(test.StartTime.ToString()).ToString(), "StartTime", "", false),
                        new Cell(test.Duration, "statusCount", "", false)
                    };

                    testRow.Add(testCells);
                    containerTable.Add(testRow);

                    if (test.Message != "")
                    {
                        Row    msgRow   = new Row("Test", test.ID);
                        Cell[] msgCells = new Cell[]
                        {
                            new Cell("Message", "hiddenMessageTitle", "", false),
                            new Cell(test.Message, "hiddenMessage", "", false),
                            new Cell("", "hiddenMessage", "", false),
                            new Cell("", "hiddenMessage", "", false)
                        };

                        msgRow.Add(msgCells);
                        containerTable.Add(msgRow);
                    }
                }

                ShowHideTableBody tableBody = new ShowHideTableBody(headRow, containerTable);
                table.Add(tableBody);
            }
            doc.DocumentNode.SelectSingleNode("/html/body").AppendChild(table.Export());
            return(doc);
        }
コード例 #2
0
        public static HtmlDocument CreateAllFailedTestsTable(HtmlDocument doc, TestLoadResult testLoadResult)
        {
            Table table = new Table("AllFailedTestsTable", "centerTable", "All Failed Tests");

            Row headRow = new Row("", "");

            Cell[] headRowCells = new Cell[]
            {
                new Cell("", "marginCell", "", false),
                new Cell("", "Failed", "", false),
                new Cell("Failed Tests", "leftAlign", "", false),
                new Cell(testLoadResult.totalTestsProp.Failed, "", "number", false)
            };

            headRow.Add(headRowCells);
            if (testLoadResult.totalTestsProp.Failed != "0")
            {
                Row    contentHeadRow      = new Row("", "");
                Cell[] contentHeadRowCells = new Cell[]
                {
                    new Cell("Status", "TestsTableHeaderFirst", "", true, onClick: "sortTable(0, 'AllFailedTestsTableContent', this)"),
                    new Cell("Test", "TestsTableHeader", "", true, onClick: "sortTable(1, 'AllFailedTestsTableContent', this)"),
                    new Cell("Class Name", "TestsTableHeader", "", true, onClick: "sortTable(2, 'AllFailedTestsTableContent', this)"),
                    new Cell("Start Time", "TestsTableHeader", "", true, onClick: "sortTable(3, 'AllFailedTestsTableContent', this)"),
                    new Cell("Duration", "TestsTableHeaderLast", "", true, onClick: "sortTable(4, 'AllFailedTestsTableContent', this)"),
                };
                contentHeadRow.Add(contentHeadRowCells);

                Table content = new Table("AllFailedTestsTableContent", "showHideTable", contentHeadRow);

                Row contentBodyRow = new Row("", "");
                var failedResults  = PredicateCreator(t => t.Result, "Failed");
                foreach (Test test in testLoadResult.tests.Where(PredicateCreator(t => t.Result, "Failed")))
                {
                    Row    testRow   = new Row("Test", test.ID);
                    Cell[] testCells = new Cell[]
                    {
                        new Cell(CreateColoredResult(test.Result, test.Message), test.Result, "", false),
                        new Cell(test.MethodName, "leftAlign", "", false),
                        new Cell(test.ClassName, "ClassName", "", false),
                        new Cell(DateTime.Parse(test.StartTime.ToString()).ToString(), "StartTime", "", false),
                        new Cell(test.Duration, "statusCount", "", false)
                    };
                    testRow.Add(testCells);
                    content.Add(testRow);

                    if (test.Message != "")
                    {
                        Row    msgRow   = new Row("Test", test.ID);
                        Cell[] msgCells = new Cell[]
                        {
                            new Cell("Message", "hiddenMessageTitle", "", false),
                            new Cell(test.Message, "hiddenMessage", "", false),
                            new Cell("", "hiddenMessage", "", false),
                            new Cell("", "hiddenMessage", "", false),
                            new Cell("", "hiddenMessage", "", false)
                        };

                        msgRow.Add(msgCells);
                        content.Add(msgRow);
                    }
                }

                ShowHideTableBody tableBody = new ShowHideTableBody(headRow, content);

                doc.DocumentNode.SelectSingleNode("/html/body").AppendChild(table.Export()).AppendChild(tableBody.Export());
            }
            else
            {
                table.Add(headRow);
                doc.DocumentNode.SelectSingleNode("/html/body").AppendChild(table.Export());
            }

            return(doc);
        }