public static bool AreEqual(SvgTestResult left, SvgTestResult right) { if (left == null && right == null) { return(true); } if (left == null && right != null) { return(false); } if (left != null && right == null) { return(false); } return(left.IsEqualTo(right)); }
public bool IsEqualTo(SvgTestResult other) { if (other == null) { return(false); } if (!string.Equals(this._version, other._version)) { return(false); } if (this._categories == null && other._categories == null) { return(true); } if (this._categories == null && other._categories != null) { return(false); } if (this._categories != null && other._categories == null) { return(false); } if (this._categories.Count != other._categories.Count) { return(false); } int itemCount = _categories.Count; for (int i = 0; i < itemCount; i++) { if (!SvgTestCategory.AreEqual(this._categories[i], other._categories[i])) { return(false); } } return(true); }
private void CreateDocument() { if (testDetailsDoc.Blocks.Count != 0) { var introBlock = testDetailsDoc.Blocks.FirstBlock; if (testDetailsDoc.Blocks.Count > 1) { testDetailsDoc.Blocks.Clear(); testDetailsDoc.Blocks.Add(introBlock); } } if (_testResults == null || _testResults.Count == 0) { testDetailsDoc.Blocks.Clear(); return; } Section noteSection = new Section(); //noteSection.Blocks.Add(CreateAlert("Note: Test Suite", // "These tests are based on SVG 1.1 First Edition Test Suite: 13 December 2006 (Full).")); this.CreateHorzLine(noteSection, false); testDetailsDoc.Blocks.Add(noteSection); _categoryLabels = new List <string>(); int resultCount = _testResults.Count; for (int i = 0; i < resultCount; i++) { SvgTestResult testResult = _testResults[i]; if (!testResult.IsValid) { continue; } IList <SvgTestCategory> testCategories = testResult.Categories; if (testCategories == null || testCategories.Count == 0) { continue; } if (i == 0) { for (int j = 0; j < testCategories.Count; j++) { _categoryLabels.Add(testCategories[j].Label); } } Section titleSection = new Section(); string headingText = string.Format("{0}. Test Results: SVGImage Version {1}", (i + 1), testResult.Version); Paragraph titlePara = new Paragraph(); titlePara.FontWeight = FontWeights.Bold; titlePara.FontSize = 18; titlePara.Inlines.Add(new Run(headingText)); titleSection.Blocks.Add(titlePara); Paragraph datePara = new Paragraph(); datePara.FontWeight = FontWeights.Bold; datePara.FontSize = 16; datePara.TextAlignment = TextAlignment.Center; datePara.Padding = new Thickness(3); datePara.Inlines.Add(new Run("Test Date: " + testResult.Date.ToString())); titleSection.Blocks.Add(datePara); testDetailsDoc.Blocks.Add(titleSection); Section resultSection = new Section(); Table resultTable = CreateResultTable(testCategories); resultSection.Blocks.Add(resultTable); if (resultCount > 1) { this.CreateHorzLine(resultSection, (i == (resultCount - 1))); } else { this.CreateHorzLine(resultSection); } testDetailsDoc.Blocks.Add(resultSection); } if (resultCount > 1) { Section summarySection = new Section(); Paragraph summaryPara = new Paragraph(); summaryPara.FontWeight = FontWeights.Bold; summaryPara.Margin = new Thickness(3, 3, 3, 10); summaryPara.FontSize = 18; summaryPara.Inlines.Add(new Run("Test Results: Summary")); summarySection.Blocks.Add(summaryPara); Table summaryTable = CreateSummaryTable(); summarySection.Blocks.Add(summaryTable); summarySection.Blocks.Add(CreateAlert("Note: Percentage", "The percentage calculations do not include partial success cases.")); this.CreateHorzLine(summarySection, true); testDetailsDoc.Blocks.Add(summarySection); } Section endSection = new Section(); Paragraph endPara = new Paragraph(); endPara.Inlines.Add(new LineBreak()); endSection.Blocks.Add(endPara); testDetailsDoc.Blocks.Add(endSection); }
private Table CreateSummaryTable() { int resultCount = _testResults.Count; Table summaryTable = new Table(); summaryTable.CellSpacing = 0; summaryTable.BorderBrush = Brushes.Gray; summaryTable.BorderThickness = new Thickness(1); summaryTable.Margin = new Thickness(16, 0, 16, 16); TableColumn categoryCol = new TableColumn(); categoryCol.Width = new GridLength(2, GridUnitType.Star); summaryTable.Columns.Add(categoryCol); TableColumn totalCol = new TableColumn(); totalCol.Width = new GridLength(1, GridUnitType.Star); summaryTable.Columns.Add(totalCol); for (int i = 0; i < resultCount; i++) { TableColumn successCol = new TableColumn(); successCol.Width = new GridLength(1, GridUnitType.Star); summaryTable.Columns.Add(successCol); } TableRowGroup headerGroup = new TableRowGroup(); headerGroup.Background = Brushes.LightGray; TableRow headerRow = new TableRow(); headerRow.Cells.Add(CreateHeaderCell("Category", false, false)); headerRow.Cells.Add(CreateHeaderCell("Total", false, false)); for (int i = 0; i < resultCount; i++) { SvgTestResult testResult = _testResults[i]; headerRow.Cells.Add(CreateHeaderCellEx(testResult.Version, (i == (resultCount - 1)), false)); } headerGroup.Rows.Add(headerRow); summaryTable.RowGroups.Add(headerGroup); int[] successValues = new int[resultCount]; int totalValue = 0; // Start with color of newer vesions Brush[] changedBrushes = { Brushes.LightCyan, Brushes.LightGoldenrodYellow, Brushes.LightGreen, Brushes.LightSalmon, Brushes.LightSeaGreen, // Version 1.2 Brushes.LightSkyBlue, // Version 1.1 Brushes.LightPink, Brushes.LightSteelBlue, Brushes.LightSkyBlue, Brushes.LightSkyBlue }; for (int k = 0; k < _categoryLabels.Count; k++) { TableRowGroup resultGroup = new TableRowGroup(); TableRow resultRow = new TableRow(); bool lastBottom = (k == (_categoryLabels.Count - 1)); resultRow.Cells.Add(CreateCell(_categoryLabels[k], false, lastBottom)); for (int i = 0; i < resultCount; i++) { SvgTestResult testResult = _testResults[i]; IList <SvgTestCategory> testCategories = testResult.Categories; SvgTestCategory testCategory = testCategories[k]; if (!testCategory.IsValid) { continue; } int total = testCategory.Total; if (i == 0) { resultRow.Cells.Add(CreateCell(total, false, lastBottom)); } successValues[i] = testCategory.Successes; totalValue = total; bool lastRight = (i == (resultCount - 1)); double percentValue = Math.Round(testCategory.Successes * 100.0d / total, 2); resultRow.Cells.Add(CreateCell(percentValue.ToString("00.00"), lastRight, lastBottom, false, false)); } int cellCount = resultRow.Cells.Count; if (IsAllZero(successValues)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.PaleVioletRed; } } else if (IsAllDone(successValues, totalValue)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.Silver; } } else { if (IsNowDone(successValues, totalValue)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.Silver; } } if (resultCount > 1) { int i = 0; for (int j = (resultCount - 1); j >= 1; j--) { var selectedBrush = changedBrushes[i]; i++; if (IsBetterResult(successValues, j)) { resultRow.Cells[cellCount - i].Background = selectedBrush; } } } } resultGroup.Rows.Add(resultRow); summaryTable.RowGroups.Add(resultGroup); } return(summaryTable); }