Exemple #1
0
        public THeaderRowType NewHeaderRow()
        {
            var row = new THeaderRowType();

            HeaderRows.Add(row);
            return(row);
        }
Exemple #2
0
 private void SetHeaderRows(int nStartRow, int nHeaderRowCount)
 {
     for (int i = nStartRow; i < nStartRow + nHeaderRowCount; i++)
     {
         if (!HeaderRows.Contains(i))
         {
             this.HeaderRows.Add(i);
         }
     }
 }
Exemple #3
0
        internal FunctionsTable(IWebElement element)
            : base(element)
        {
            TableRow headerRow = HeaderRows.Single();

            if (!string.Equals("FUNCTION NAME", headerRow[0].RawElement.Text) ||
                !string.Equals("STATISTICS", headerRow[1].RawElement.Text))
            {
                throw new ArgumentException("Table is not a functions table", "element");
            }
        }
Exemple #4
0
        internal FunctionArgumentsTable(IWebElement element)
            : base(element)
        {
            TableRow headerRow = HeaderRows.Single();

            if (!string.Equals("PARAMETER", headerRow[0].RawElement.Text) ||
                !string.Equals("VALUE", headerRow[1].RawElement.Text) ||
                !string.Equals("NOTES", headerRow[2].RawElement.Text))
            {
                throw new ArgumentException("Table is not a function arguments table", "element");
            }
        }
Exemple #5
0
        internal JobsTable(IWebElement element)
            : base(element)
        {
            TableRow headerRow = HeaderRows.Single();

            if (!string.Equals("NAME", headerRow[0].RawElement.Text) ||
                !string.Equals("STATUS", headerRow[1].RawElement.Text) ||
                !string.Equals("LAST RUN TIME", headerRow[2].RawElement.Text))
            {
                throw new ArgumentException("Table is not a jobs table", "element");
            }
        }
Exemple #6
0
        internal InvocationsTable(IWebElement element)
            : base(element)
        {
            TableRow headerRow = HeaderRows.Single();

            if (!headerRow[0].RawElement.Text.StartsWith("FUNCTION") ||
                !string.Equals("STATUS", headerRow[1].RawElement.Text) ||
                !string.Equals("STATUS DETAIL", headerRow[2].RawElement.Text))
            {
                throw new ArgumentException("Table is not an invocations table", "element");
            }
        }
        public static Tuple <HeaderRows, IReadOnlyCollection <ICell> > GetHeaderRowsForTesting()
        {
            var row1Cells        = Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList();
            var row2SlottedCells = new[]
            {
                (INotSlottedCell)A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                (INotSlottedCell)A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                (INotSlottedCell)A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
            };
            var row2Cells = new ICell[]
            {
                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                new SlottedCell(
                    new Dictionary <string, INotSlottedCell>
                {
                    { "first", row2SlottedCells[0] },
                },
                    "first"),
                new SlottedCell(
                    new Dictionary <string, INotSlottedCell>
                {
                    { "second", row2SlottedCells[1] },
                    { "third", row2SlottedCells[2] },
                },
                    "second"),
            };
            var row3Cells = Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList();

            var allHeaderRows = new[]
            {
                new FlatRow(row1Cells, "1"),
                new FlatRow(row2Cells, "2"),
                new FlatRow(row3Cells, "3"),
            };

            var allCells = new ICell[0]
                           .Concat(row1Cells)
                           .Concat(row2SlottedCells)
                           .Concat(row2Cells)
                           .Concat(row3Cells)
                           .ToList();

            var headerRows = new HeaderRows(allHeaderRows);

            var result = new Tuple <HeaderRows, IReadOnlyCollection <ICell> >(headerRows, allCells);

            return(result);
        }
Exemple #8
0
 protected override void RenderContent(String innerText, String rawInnerText)
 {
     if (HasHeader)
     {
         CurrentContext.Document.RenderBeginTag("thead");
         HeaderRows.RenderChildren(CurrentContext);
         CurrentContext.Document.RenderEndTag();
     }
     CurrentContext.Document.RenderBeginTag("tbody");
     base.RenderContent("", "");
     if (HasFooter)
     {
         CurrentContext.Document.RenderBeginTag("tfooter");
         FooterRows.RenderChildren(CurrentContext);
         CurrentContext.Document.RenderEndTag();
     }
     CurrentContext.Document.RenderEndTag();
 }
        private static TableRows BuildTableRows(
            int numberOfColumns)
        {
            var allHeaderRows = BuildFlatRows(numberOfColumns);

            var headerRows = new HeaderRows(allHeaderRows, A.Dummy <HeaderRowsFormat>());

            var allFooterRows = BuildFlatRows(numberOfColumns);

            var footerRows = new FooterRows(allFooterRows, A.Dummy <FooterRowsFormat>());

            var allDataRows = BuildDataRows(numberOfColumns);

            var dataRows = new DataRows(allDataRows, A.Dummy <DataRowsFormat>());

            var result = new TableRows(headerRows, dataRows, footerRows, A.Dummy <RowFormat>());

            return(result);
        }
        static HeaderRowsTest()
        {
            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <HeaderRows>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'rows' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <HeaderRows>();

                    var result = new HeaderRows(
                        null,
                        referenceObject.Format);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "rows", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <HeaderRows>
            {
                Name             = "constructor should throw ArgumentException when parameter 'rows' contains a null element scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <HeaderRows>();

                    var result = new HeaderRows(
                        new FlatRow[0].Concat(referenceObject.Rows).Concat(new FlatRow[] { null }).Concat(referenceObject.Rows).ToList(),
                        referenceObject.Format);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "rows", "contains at least one null element", },
            });
        }
        private static void AddHeaderRows(
            this CellCursor cursor,
            HeaderRows headerRows,
            ReportToWorkbookProjectionContext context,
            PassKind passKind)
        {
            if (headerRows == null)
            {
                return;
            }

            if (headerRows.Rows.Any())
            {
                for (var x = 0; x < headerRows.Rows.Count; x++)
                {
                    cursor.ResetColumn();

                    cursor.MoveDown();

                    if ((x == 0) && (passKind == PassKind.Data))
                    {
                        cursor.AddMarker(TopLeftHeaderCellMarker);
                    }

                    if (passKind == PassKind.Formatting)
                    {
                        cursor.CanvassedRowRange.ApplyHeaderRowsFormat(headerRows.Format);
                    }

                    cursor.AddFlatRow(headerRows.Rows[x], context, passKind);
                }

                if (passKind == PassKind.Data)
                {
                    cursor.AddMarker(BottomRightHeaderCellMarker);
                }
            }
        }
Exemple #12
0
        public static void Constructor___Does_not_throw___When_all_rows_span_all_columns()
        {
            // Arrange
            var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList());

            var allHeaderRows = new[]
            {
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(3),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                }),
            };

            var headerRows = new HeaderRows(allHeaderRows);

            var allDataRows = new[]
            {
                new Row(new[] { A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(3) }),
                new Row(
                    Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(null)).ToList(),
                    childRows: new[]
                {
                    new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(null)).ToList()),
                    new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(null)).ToList()),
                    new Row(
                        new ICell[]
                    {
                        A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                        A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null),
                    }),
                }),
                new Row(
                    Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(null)).ToList(),
                    childRows: new[]
                {
                    new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                    new Row(
                        new ICell[]
                    {
                        A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                        A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                    }),
                    new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(1).Select(_ => _.DeepCloneWithColumnsSpanned(3)).ToList()),
                }),
            };

            var dataRows = new DataRows(allDataRows);

            var allFooterRows = new[]
            {
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(2),
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1),
                }),
                new FlatRow(
                    new ICell[]
                {
                    A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(3),
                }),
            };

            var footerRows = new FooterRows(allFooterRows);

            var tableRows = new TableRows(headerRows, dataRows, footerRows);

            // Act
            var actual = Record.Exception(() => new TreeTable(tableColumns, tableRows));

            // Assert
            actual.AsTest().Must().BeNull();
        }
Exemple #13
0
        static TreeTableTest()
        {
            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'tableColumns' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TreeTable>();

                    var result = new TreeTable(
                        null,
                        referenceObject.TableRows,
                        referenceObject.Format);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "tableColumns", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when parameter 'tableRows' contains a header row that does not span all of the columns in tableColumns",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList());

                    var rows = new[]
                    {
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).ToList()),
                    };

                    var headerRows = new HeaderRows(rows, null);

                    var tableRows = new TableRows(headerRows, null);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when parameter 'tableRows' contains a data row that does not span all of the columns in tableColumns",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList());

                    var rows = new[]
                    {
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new Row(
                            Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(),
                            childRows: new[]
                        {
                            new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                            new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3)),
                            new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        }),
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                    };

                    var dataRows = new DataRows(rows, null);

                    var tableRows = new TableRows(null, dataRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when parameter 'footerRows' contains a footer row that does not span all of the columns in tableColumns",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList());

                    var rows = new[]
                    {
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).ToList()),
                    };

                    var footerRows = new FooterRows(rows, null);

                    var tableRows = new TableRows(footerRows: footerRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when two columns have the same identifier",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(new[]
                    {
                        new Column("column-1"),
                        new Column("column-2"),
                        new Column("column-1"),
                    });

                    var headerRows = new HeaderRows(
                        new[]
                    {
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                    },
                        null);

                    var dataRows = new DataRows(
                        new[]
                    {
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new Row(
                            Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(),
                            childRows:
                            new[]
                        {
                            new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        }),
                    });

                    var tableRows = new TableRows(headerRows, dataRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when two rows have the same identifier",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList());

                    var headerRows = new HeaderRows(
                        new[]
                    {
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-1"),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-2"),
                    },
                        null);

                    var dataRows = new DataRows(
                        new[]
                    {
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-3"),
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows:
                                new[]
                        {
                            new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-1"),
                        }),
                    });

                    var tableRows = new TableRows(headerRows, dataRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when two cells have the same identifier",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList());

                    var headerRows = new HeaderRows(
                        new[]
                    {
                        new FlatRow(
                            new ICell[]
                        {
                            A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null),
                            A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId("cell-1"),
                            A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null),
                        }),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                    },
                        null);

                    var dataRows = new DataRows(
                        new[]
                    {
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new Row(
                            Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(),
                            childRows:
                            new[]
                        {
                            new Row(
                                new ICell[]
                            {
                                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null),
                                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null),
                                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId("cell-1"),
                            }),
                        }),
                    });

                    var tableRows = new TableRows(headerRows, dataRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TreeTable>
            {
                Name             = "constructor should throw ArgumentException when a cell object is used multiple times",
                ConstructionFunc = () =>
                {
                    var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList());

                    var cell = A.Dummy <CellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null);

                    var headerRows = new HeaderRows(
                        new[]
                    {
                        new FlatRow(
                            new ICell[]
                        {
                            A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null),
                            cell,
                            A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null),
                        }),
                        new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                    },
                        null);

                    var dataRows = new DataRows(
                        new[]
                    {
                        new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()),
                        new Row(
                            Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(),
                            childRows:
                            new[]
                        {
                            new Row(
                                new ICell[]
                            {
                                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null),
                                A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null),
                                cell,
                            }),
                        }),
                    });

                    var tableRows = new TableRows(headerRows, dataRows);

                    var result = new TreeTable(
                        tableColumns,
                        tableRows);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "One or more ICell objects are used multiple times in the tree table.", },
            });

            DeepCloneWithTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new DeepCloneWithTestScenario <TreeTable>
            {
                Name             = "DeepCloneWithTableColumns should deep clone object and replace TableColumns with the provided tableColumns",
                WithPropertyName = "TableColumns",
                SystemUnderTestDeepCloneWithValueFunc = () =>
                {
                    var systemUnderTest = A.Dummy <TreeTable>();

                    var referenceObject = A.Dummy <TreeTable>().ThatIs(_ => !systemUnderTest.TableColumns.IsEqualTo(_.TableColumns) && (_.TableColumns.Columns.Count == systemUnderTest.TableColumns.Columns.Count));

                    var result = new SystemUnderTestDeepCloneWithValue <TreeTable>
                    {
                        SystemUnderTest    = systemUnderTest,
                        DeepCloneWithValue = referenceObject.TableColumns,
                    };

                    return(result);
                },
            })
            .AddScenario(() =>
                         new DeepCloneWithTestScenario <TreeTable>
            {
                Name             = "DeepCloneWithTableRows should deep clone object and replace TableRows with the provided tableRows",
                WithPropertyName = "TableRows",
                SystemUnderTestDeepCloneWithValueFunc = () =>
                {
                    var systemUnderTest = A.Dummy <TreeTable>();

                    var referenceObject = A.Dummy <TreeTable>().ThatIs(_ =>
                                                                       !systemUnderTest.TableRows.IsEqualTo(_.TableRows) &&
                                                                       ((!_.TableRows.GetAllRowsInOrder().Any()) || (_.TableRows.GetAllRowsInOrder().First().GetNumberOfColumnsSpanned() == systemUnderTest.TableColumns.Columns.Count)));

                    var result = new SystemUnderTestDeepCloneWithValue <TreeTable>
                    {
                        SystemUnderTest    = systemUnderTest,
                        DeepCloneWithValue = referenceObject.TableRows,
                    };

                    return(result);
                },
            })
            .AddScenario(() =>
                         new DeepCloneWithTestScenario <TreeTable>
            {
                Name             = "DeepCloneWithFormat should deep clone object and replace Format with the provided format",
                WithPropertyName = "Format",
                SystemUnderTestDeepCloneWithValueFunc = () =>
                {
                    var systemUnderTest = A.Dummy <TreeTable>();

                    var referenceObject = A.Dummy <TreeTable>().ThatIs(_ => !systemUnderTest.Format.IsEqualTo(_.Format));

                    var result = new SystemUnderTestDeepCloneWithValue <TreeTable>
                    {
                        SystemUnderTest    = systemUnderTest,
                        DeepCloneWithValue = referenceObject.Format,
                    };

                    return(result);
                },
            });

            EquatableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new EquatableTestScenario <TreeTable>
            {
                Name            = "Default Code Generated Scenario",
                ReferenceObject = ReferenceObjectForEquatableTestScenarios,
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new TreeTable[]
                {
                    new TreeTable(
                        ReferenceObjectForEquatableTestScenarios.TableColumns,
                        ReferenceObjectForEquatableTestScenarios.TableRows,
                        ReferenceObjectForEquatableTestScenarios.Format),
                },
                ObjectsThatAreNotEqualToReferenceObject = new TreeTable[]
                {
                    new TreeTable(
                        A.Dummy <TreeTable>().Whose(_ => !_.TableColumns.IsEqualTo(ReferenceObjectForEquatableTestScenarios.TableColumns) && (_.TableColumns.Columns.Count == ReferenceObjectForEquatableTestScenarios.TableColumns.Columns.Count)).TableColumns,
                        ReferenceObjectForEquatableTestScenarios.TableRows,
                        ReferenceObjectForEquatableTestScenarios.Format),
                    new TreeTable(
                        ReferenceObjectForEquatableTestScenarios.TableColumns,
                        A.Dummy <TreeTable>().Whose(_ => (!_.TableRows.IsEqualTo(ReferenceObjectForEquatableTestScenarios.TableRows) && ((!_.TableRows.GetAllRowsInOrder().Any()) || (_.TableRows.GetAllRowsInOrder().First().GetNumberOfColumnsSpanned() == ReferenceObjectForEquatableTestScenarios.TableColumns.Columns.Count)))).TableRows,
                        ReferenceObjectForEquatableTestScenarios.Format),
                    new TreeTable(
                        ReferenceObjectForEquatableTestScenarios.TableColumns,
                        ReferenceObjectForEquatableTestScenarios.TableRows,
                        A.Dummy <TreeTable>().Whose(_ => !_.Format.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Format)).Format),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                },
            });
        }
        public DataStructureDummyFactory()
        {
            // <------------------- ENUMS ------------------------>
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(Availability.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(AvailabilityCheckStatus.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(AvailabilityCheckStepAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BorderStyle.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BorderWeight.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BytesPayloadLinkedResourceKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CellOpExecutionOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CellOpExecutionStatus.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CompareOperator.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(FillPatternStyle.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(HorizontalAlignment.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(InnerBorderEdges.None);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(LinkTarget.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(MediaReferenceKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(MessageFormatKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatDigitGroupKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatNegativeDisplayKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatPercentDisplayKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(OuterBorderSides.None);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(SlotSelectionStrategy.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(StringPayloadLinkedResourceKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(UrlLinkedResourceKind.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(ValidationStatus.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(ValidationStepAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(Validity.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(VerticalAlignment.Unknown);

            // <------------------- INTERFACES ------------------------>
            AutoFixtureBackedDummyFactory.AddDummyCreator <IAvailabilityCheckCell>(A.Dummy <NotSlottedCellBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <ICell>(A.Dummy <CellBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <INotSlottedCell>(A.Dummy <NotSlottedCellBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <IValidationCell>(A.Dummy <NotSlottedCellBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <ICellValueFormat <Version> >(A.Dummy <CellValueFormatBase <Version> >);
            AutoFixtureBackedDummyFactory.AddDummyCreator <IHoverOver>(A.Dummy <HoverOverBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <ILink>(A.Dummy <SimpleLink>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <ILinkedResource>(A.Dummy <LinkedResourceBase>);
            AutoFixtureBackedDummyFactory.AddDummyCreator <IOperationOutputCell <Version> >(A.Dummy <OperationCell <Version> >);

            // <------------------- OPERATIONS ------------------------>
            RegisterReturningOperation <bool>();
            RegisterReturningOperation <decimal>();
            RegisterReturningOperation <string>();
            RegisterReturningOperation <ValidationResult>();
            RegisterReturningOperation <AvailabilityCheckResult>();
            RegisterReturningOperation <Availability>();
            RegisterReturningOperation <Validity>();
            RegisterReturningOperation <CellLocatorBase>();
            RegisterReturningOperation <CompareOperator>();

            // <------------------- MODELS ------------------------>

            // Report
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var numberOfSections = ThreadSafeRandom.Next(1, 4);

                var result = new Report(A.Dummy <string>(), Some.ReadOnlyDummies <Section>(numberOfSections).ToList(), A.Dummy <string>(), A.Dummy <UtcDateTime>(), Some.ReadOnlyDummies <SimpleLink>().ToList(), A.Dummy <AdditionalReportInfo>(), A.Dummy <ReportFormat>());

                return(result);
            });

            // TreeTable
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var numberOfColumns = GetRandomNumberOfColumns();

                var columns = Some.ReadOnlyDummies <Column>(numberOfColumns).ToList();

                var tableColumns = new TableColumns(columns, A.Dummy <ColumnFormat>());

                var tableRows = BuildTableRows(columns.Count);

                var result = new TreeTable(tableColumns, tableRows, A.Dummy <TableFormat>());

                return(result);
            });

            // TableRows
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = BuildTableRows(GetRandomNumberOfColumns());

                return(result);
            });

            // HeaderRows
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var headerRows = BuildFlatRows(GetRandomNumberOfColumns());

                var result = new HeaderRows(headerRows, A.Dummy <HeaderRowsFormat>());

                return(result);
            });

            // DataRows
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var allDataRows = BuildDataRows(GetRandomNumberOfColumns());

                var result = new DataRows(allDataRows, A.Dummy <DataRowsFormat>());

                return(result);
            });

            // FooterRows
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var footerRows = BuildFlatRows(GetRandomNumberOfColumns());

                var result = new FooterRows(footerRows, A.Dummy <FooterRowsFormat>());

                return(result);
            });

            // Row
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = BuildDataRow(GetRandomNumberOfColumns());

                return(result);
            });

            // FlatRow
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = BuildFlatRow(GetRandomNumberOfColumns(), allowSpanningCells: true);

                return(result);
            });

            // SlottedCell
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var columnsSpanned = GetRandomColumnsSpannedByCell();

                var cells = Some.ReadOnlyDummies <NotSlottedCellBase>().Select(_ => _.DeepCloneWithColumnsSpanned(columnsSpanned)).Cast <NotSlottedCellBase>().ToList();

                var slotIdToCellMap = cells.ToDictionary(_ => A.Dummy <string>(), _ => (INotSlottedCell)_);

                var defaultSlotId = slotIdToCellMap.ElementAt(ThreadSafeRandom.Next(0, slotIdToCellMap.Count)).Key;

                var result = new SlottedCell(slotIdToCellMap, defaultSlotId, A.Dummy <string>(), columnsSpanned, A.Dummy <string>());

                return(result);
            });

            // InputCell<Version>
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new InputCell <Version>(
                    A.Dummy <string>(),
                    GetRandomColumnsSpannedByCell(),
                    A.Dummy <string>(),
                    A.Dummy <Validation>(),
                    Some.ReadOnlyDummies <CellValidationEventBase>().ToList(),
                    A.Dummy <Availability>(),
                    A.Dummy <AvailabilityCheck>(),
                    Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(),
                    Some.ReadOnlyDummies <CellInputEventBase>().ToList(),
                    A.Dummy <ICellValueFormat <Version> >(),
                    A.Dummy <CellFormat>(), A.Dummy <IHoverOver>());

                return(result);
            });

            // NullCell
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new NullCell(
                    A.Dummy <string>(),
                    GetRandomColumnsSpannedByCell(),
                    A.Dummy <string>(),
                    A.Dummy <Validation>(),
                    Some.ReadOnlyDummies <CellValidationEventBase>().ToList(),
                    A.Dummy <Availability>(),
                    A.Dummy <AvailabilityCheck>(),
                    Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(),
                    A.Dummy <CellFormat>(),
                    A.Dummy <IHoverOver>(),
                    A.Dummy <ILink>());

                return(result);
            });

            // ConstCell<Version>
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new ConstCell <Version>(
                    A.Dummy <Version>(),
                    A.Dummy <string>(),
                    GetRandomColumnsSpannedByCell(),
                    A.Dummy <string>(),
                    A.Dummy <Validation>(),
                    Some.ReadOnlyDummies <CellValidationEventBase>().ToList(),
                    A.Dummy <Availability>(),
                    A.Dummy <AvailabilityCheck>(),
                    Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(),
                    A.Dummy <ICellValueFormat <Version> >(),
                    A.Dummy <CellFormat>(),
                    A.Dummy <IHoverOver>(),
                    A.Dummy <ILink>());

                return(result);
            });

            // OperationOutputCell<Version>
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new OperationCell <Version>(
                    A.Dummy <IReturningOperation <Version> >(),
                    A.Dummy <string>(),
                    GetRandomColumnsSpannedByCell(),
                    A.Dummy <string>(),
                    A.Dummy <Validation>(),
                    Some.ReadOnlyDummies <CellValidationEventBase>().ToList(),
                    A.Dummy <Availability>(),
                    A.Dummy <AvailabilityCheck>(),
                    Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(),
                    Some.ReadOnlyDummies <CellOpExecutionEventBase>().ToList(),
                    A.Dummy <ICellValueFormat <Version> >(),
                    A.Dummy <CellFormat>(),
                    A.Dummy <IHoverOver>(),
                    A.Dummy <ILink>());

                return(result);
            });

            // DateTimeFormat
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var localize = A.Dummy <bool>();

                var result = new DateTimeFormat(A.Dummy <DateTimeFormatKind>(), A.Dummy <CultureKind>(), localize, localize ? A.Dummy <StandardTimeZone>() : (StandardTimeZone?)null);

                return(result);
            });

            // ReportFormat
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var displayTimestamp = A.Dummy <bool>();

                var result = new ReportFormat(displayTimestamp, displayTimestamp ? A.Dummy <DateTimeFormat>() : null, A.Dummy <ReportFormatOptions>());

                return(result);
            });

            // Color
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = Color.FromArgb(A.Dummy <byte>(), A.Dummy <byte>(), A.Dummy <byte>());

                return(result);
            });

            // Events
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellAvailabilityCheckClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellAvailabilityCheckDeterminedCellDisabledEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellAvailabilityCheckDeterminedCellEnabledEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellAvailabilityCheckFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellInputAppliedEvent <Version>(A.Dummy <UtcDateTime>(), A.Dummy <Version>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellInputClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellOpExecutionAbortedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellOpExecutionClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellOpExecutionCompletedEvent <Version>(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <Version>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellOpExecutionDeemedNotApplicableEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellOpExecutionFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationAbortedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationDeemedNotApplicableEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationDeterminedCellInvalidEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationDeterminedCellValidEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>());

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var result = new CellValidationFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>());

                return(result);
            });
        }
Exemple #15
0
        private void AdjustHeaderStyle()
        {
            if (this.HeaderRows.Count <= 0 || this.HeadersData == null)
            {
                return;
            }

            HeaderRows.Sort();

            this.HeadersData.SetHeadGridLine(this.PrintingTable, this.HeaderRows);

            int MinHeaderRow = HeaderRows[0];

            int MaxHeaderRow = HeaderRows[HeaderRows.Count - 1];

            #region UpdateHeadeStyle

            for (int row = MinHeaderRow; row <= MaxHeaderRow; row++)
            {
                int TableHeaderRow = row - MinHeaderRow;

                if (TableHeaderRow >= this.HeadersData.RowCount)
                {
                    break;
                }

                for (int col = 0; col < this.HeadersData.ColCount; col++)
                {
                    HeaderCell headerCell = this.HeadersData.GetCell(TableHeaderRow, col);

                    IWebbTableCell cell = PrintingTable.GetCell(row, col);

                    if (headerCell == null || cell == null)
                    {
                        continue;
                    }

                    if (headerCell.NeedChangeStyle)
                    {
                        cell.CellStyle = headerCell.CellStyle.Copy();
                    }
                }
            }

            #endregion

            #region Cols In Merge

            foreach (int col in this.HeadersData.ColsToMerge)
            {
                IWebbTableCell Mergedcell = PrintingTable.GetCell(MaxHeaderRow, col);

                this.PrintingTable.MergeCells(MinHeaderRow, MaxHeaderRow, col, col);

                IWebbTableCell bordercell = PrintingTable.GetCell(MinHeaderRow, col);

                if (this.HaveHeader)
                {
                    bordercell.Text = Mergedcell.Text;

                    bordercell.CellStyle.StringFormat = Mergedcell.CellStyle.StringFormat;
                }

                if ((bordercell.CellStyle.StringFormat & StringFormatFlags.DirectionVertical) != 0)
                {
                    bordercell.CellStyle.HorzAlignment = HorzAlignment.Far;
                    bordercell.CellStyle.VertAlignment = VertAlignment.Center;
                }
                else
                {
                    bordercell.CellStyle.HorzAlignment = HorzAlignment.Center;
                    bordercell.CellStyle.VertAlignment = VertAlignment.Center;
                }
            }
            #endregion
        }