Esempio n. 1
0
        public void BuildVerticalReport_GlobalPropertiesWhenOverwrittenForHeader_Applied()
        {
            AttributeBasedBuilder helper = new AttributeBasedBuilder(
                Mocks.ServiceProvider,
                new[] { new CommonAttributeHandler() });

            IReportSchema <WithOverwrittenForHeaderGlobalProperties> schema = helper.BuildSchema <WithOverwrittenForHeaderGlobalProperties>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(
                new[]
            {
                new WithOverwrittenForHeaderGlobalProperties()
                {
                    Id = 1
                },
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.HeaderRows);

            headerCells[0][0].Properties.Should().HaveCount(1)
            .And.ContainSingle(p => p is AlignmentProperty && ((AlignmentProperty)p).Alignment == Alignment.Right);

            ReportCell[][] cells = this.GetCellsAsArray(reportTable.Rows);

            cells[0][0].Properties.Should().HaveCount(1)
            .And.ContainSingle(p => p is AlignmentProperty && ((AlignmentProperty)p).Alignment == Alignment.Center);
        }
        public void BuildVerticalReport_PropertiesWithoutAttribute_Ignored()
        {
            AttributeBasedBuilder builderHelper = new AttributeBasedBuilder(Mocks.ServiceProvider);
            IReportSchema <SomePropertiesWithoutAttribute> schema = builderHelper.BuildSchema <SomePropertiesWithoutAttribute>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(Enumerable.Empty <SomePropertiesWithoutAttribute>());

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0].Should().HaveCount(1);
            headerCells[0][0].GetValue <string>().Should().Be("Name");
        }
        public void BuildVerticalReport_SeveralProperties_CorrectOrder()
        {
            AttributeBasedBuilder builderHelper           = new AttributeBasedBuilder(Mocks.ServiceProvider);
            IReportSchema <SeveralPropertiesClass> schema = builderHelper.BuildSchema <SeveralPropertiesClass>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(Enumerable.Empty <SeveralPropertiesClass>());

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0].Should().HaveCount(2);
            headerCells[0][0].GetValue <string>().Should().Be("ID");
            headerCells[0][1].GetValue <string>().Should().Be("Name");
        }
        public void BuildVerticalReport_OneComplexHeader_CorrectTable()
        {
            AttributeBasedBuilder builderHelper          = new AttributeBasedBuilder(Mocks.ServiceProvider);
            IReportSchema <OneComplexHeaderClass> schema = builderHelper.BuildSchema <OneComplexHeaderClass>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(Enumerable.Empty <OneComplexHeaderClass>());

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.HeaderRows);
            headerCells.Should().HaveCount(2);
            headerCells[0].Should().HaveCount(3);
            headerCells[0][0].GetValue <string>().Should().Be("ID");
            headerCells[0][1].GetValue <string>().Should().Be("Personal");
            headerCells[0][2].Should().BeNull();
            headerCells[1].Should().HaveCount(3);
            headerCells[1][0].Should().BeNull();
            headerCells[1][1].GetValue <string>().Should().Be("Name");
            headerCells[1][2].GetValue <string>().Should().Be("Age");
        }
Esempio n. 5
0
        public void BuildVerticalReport_GlobalPropertiesWhenOverwritten_NotApplied()
        {
            AttributeBasedBuilder helper = new AttributeBasedBuilder(
                Mocks.ServiceProvider,
                new[] { new CommonAttributeHandler() });

            IReportSchema <WithOverwrittenGlobalProperties> schema = helper.BuildSchema <WithOverwrittenGlobalProperties>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(new[]
            {
                new WithOverwrittenGlobalProperties()
                {
                    Id = 1
                },
            });

            ReportCell[][] cells = this.GetCellsAsArray(reportTable.Rows);

            cells[0][0].Properties.Should().HaveCount(1)
            .And.ContainSingle(p => p is DecimalPrecisionProperty && ((DecimalPrecisionProperty)p).Precision == 0);
        }
Esempio n. 6
0
        public void BuildVerticalReport_CustomAttributeHandler_Applied()
        {
            AttributeBasedBuilder helper = new AttributeBasedBuilder(
                Mocks.ServiceProvider,
                new[] { new CustomAttributeHandler() });

            IReportSchema <EntityWithCustomAttribute> schema = helper.BuildSchema <EntityWithCustomAttribute>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(new[]
            {
                new EntityWithCustomAttribute()
                {
                    Title = "Test"
                },
            });

            ReportCell[][] cells = this.GetCellsAsArray(reportTable.Rows);

            cells[0][0].Properties.Should().HaveCount(1)
            .And.ContainItemsAssignableTo <CustomProperty>();
        }
        public void BuildVerticalReport_PropertiesWithAttribute_CorrectValueType()
        {
            AttributeBasedBuilder builderHelper             = new AttributeBasedBuilder(Mocks.ServiceProvider);
            IReportSchema <PropertiesWithAttributes> schema = builderHelper.BuildSchema <PropertiesWithAttributes>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(new[]
            {
                new PropertiesWithAttributes()
                {
                    Id = 1, Name = "John Doe", Salary = 1000m, DateOfBirth = new DateTime(2000, 4, 7)
                },
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.Rows);
            headerCells.Should().HaveCount(1);
            headerCells[0].Should().HaveCount(4);
            headerCells[0][0].ValueType.Should().Be(typeof(int));
            headerCells[0][1].ValueType.Should().Be(typeof(string));
            headerCells[0][2].ValueType.Should().Be(typeof(decimal));
            headerCells[0][3].ValueType.Should().Be(typeof(DateTime));
        }
        public void BuildVerticalReport_SeveralLevelsOfComplexHeader_CorrectTable()
        {
            AttributeBasedBuilder builderHelper = new AttributeBasedBuilder(Mocks.ServiceProvider);
            IReportSchema <SeveralLevelsOfComplexHeaderClass> schema = builderHelper.BuildSchema <SeveralLevelsOfComplexHeaderClass>();

            IReportTable <ReportCell> reportTable = schema.BuildReportTable(Enumerable.Empty <SeveralLevelsOfComplexHeaderClass>());

            ReportCell[][] headerCells = this.GetCellsAsArray(reportTable.HeaderRows);
            headerCells.Should().HaveCount(4);
            headerCells[0].Should().HaveCount(6);
            headerCells[0][0].GetValue <string>().Should().Be("ID");
            headerCells[0][1].GetValue <string>().Should().Be("Employee Info");
            headerCells[0][2].Should().BeNull();
            headerCells[0][3].Should().BeNull();
            headerCells[0][4].Should().BeNull();
            headerCells[0][5].GetValue <string>().Should().Be("Employee # in Department");
            headerCells[1].Should().HaveCount(6);
            headerCells[1][0].Should().BeNull();
            headerCells[1][1].GetValue <string>().Should().Be("Personal");
            headerCells[1][2].Should().BeNull();
            headerCells[1][3].GetValue <string>().Should().Be("Job Info");
            headerCells[1][4].Should().BeNull();
            headerCells[1][5].Should().BeNull();
            headerCells[2].Should().HaveCount(6);
            headerCells[2][0].Should().BeNull();
            headerCells[2][1].GetValue <string>().Should().Be("Name");
            headerCells[2][2].GetValue <string>().Should().Be("Age");
            headerCells[2][3].GetValue <string>().Should().Be("Job Title");
            headerCells[2][4].GetValue <string>().Should().Be("Sensitive");
            headerCells[2][5].Should().BeNull();
            headerCells[3].Should().HaveCount(6);
            headerCells[3][0].Should().BeNull();
            headerCells[3][1].Should().BeNull();
            headerCells[3][2].Should().BeNull();
            headerCells[3][3].Should().BeNull();
            headerCells[3][4].GetValue <string>().Should().Be("Salary");
            headerCells[3][5].Should().BeNull();
        }