private static void AddRow(
            this CellCursor cursor,
            DataStructure.Row row,
            ReportToWorkbookProjectionContext context,
            PassKind passKind,
            DataRowsFormat dataRowsFormat)
        {
            cursor.AddRowBase(row, context, passKind);

            if (cursor.HasMarker(BottomRightNonSummaryDataCellMarker))
            {
                cursor.RemoveMarker(BottomRightNonSummaryDataCellMarker);
            }

            cursor.AddMarker(BottomRightNonSummaryDataCellMarker);

            if ((row.ChildRows != null) && row.ChildRows.Any())
            {
                foreach (var childRow in row.ChildRows)
                {
                    cursor.ResetColumn();

                    cursor.MoveDown();

                    if (passKind == PassKind.Formatting)
                    {
                        cursor.CanvassedRowRange.ApplyDataRowsFormat(dataRowsFormat);
                    }

                    cursor.AddRow(childRow, context, passKind, dataRowsFormat);
                }
            }

            if (row.CollapsedSummaryRows != null && row.CollapsedSummaryRows.Any())
            {
                throw new NotSupportedException("collapsed summary rows are not supported");
            }

            if (row.ExpandedSummaryRows != null)
            {
                foreach (var expandedSummaryRow in row.ExpandedSummaryRows)
                {
                    cursor.ResetColumn();

                    cursor.MoveDown();

                    if (passKind == PassKind.Formatting)
                    {
                        cursor.CanvassedRowRange.ApplyDataRowsFormat(dataRowsFormat);
                    }

                    cursor.AddFlatRow(expandedSummaryRow, context, passKind);
                }
            }
        }
        private static void ApplyDataRowsFormat(
            this Range range,
            DataRowsFormat format)
        {
            if (format == null)
            {
                return;
            }

            var implementedProperties = new[]
            {
                nameof(DataRowsFormat.RowsFormat),
            };

            format.ThrowOnNotImplementedProperty(implementedProperties);

            range.ApplyRowFormat(format.RowsFormat);
        }
Exemplo n.º 3
0
        static DataRowsFormatTest()
        {
            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <DataRowsFormat>
            {
                Name             = "constructor should throw ArgumentException when parameter 'rowsRepeatingFormat' is an empty enumerable scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <DataRowsFormat>();

                    var result = new DataRowsFormat(
                        referenceObject.OuterBorders,
                        referenceObject.InnerBorders,
                        referenceObject.RowsFormat,
                        new List <RowFormat>());

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

                    var result = new DataRowsFormat(
                        referenceObject.OuterBorders,
                        referenceObject.InnerBorders,
                        referenceObject.RowsFormat,
                        new RowFormat[0].Concat(referenceObject.RowsRepeatingFormat).Concat(new RowFormat[] { null }).Concat(referenceObject.RowsRepeatingFormat).ToList());

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "rowsRepeatingFormat", "contains at least one null element", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <DataRowsFormat>
            {
                Name             = "constructor should throw ArgumentException when parameter 'outerBorders' is an empty enumerable scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <DataRowsFormat>();

                    var result = new DataRowsFormat(
                        new List <OuterBorder>(),
                        referenceObject.InnerBorders,
                        referenceObject.RowsFormat,
                        referenceObject.RowsRepeatingFormat);

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

                    var result = new DataRowsFormat(
                        new OuterBorder[0].Concat(referenceObject.OuterBorders).Concat(new OuterBorder[] { null }).Concat(referenceObject.OuterBorders).ToList(),
                        referenceObject.InnerBorders,
                        referenceObject.RowsFormat,
                        referenceObject.RowsRepeatingFormat);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "outerBorders", "contains at least one null element", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <DataRowsFormat>
            {
                Name             = "constructor should throw ArgumentException when parameter 'innerBorders' is an empty enumerable scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <DataRowsFormat>();

                    var result = new DataRowsFormat(
                        referenceObject.OuterBorders,
                        new List <InnerBorder>(),
                        referenceObject.RowsFormat,
                        referenceObject.RowsRepeatingFormat);

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

                    var result = new DataRowsFormat(
                        referenceObject.OuterBorders,
                        new InnerBorder[0].Concat(referenceObject.InnerBorders).Concat(new InnerBorder[] { null }).Concat(referenceObject.InnerBorders).ToList(),
                        referenceObject.RowsFormat,
                        referenceObject.RowsRepeatingFormat);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "innerBorders", "contains at least one null element", },
            });
        }