コード例 #1
0
        public void Build_DateTimeColumnWithFormat_CorrectDisplayValue()
        {
            VerticalReportSchemaBuilder <DateTime> reportBuilder = new VerticalReportSchemaBuilder <DateTime>();

            reportBuilder.AddColumn("The Date", d => d);            // .SetValueFormatter(new DateTimeValueFormatter("MM/dd/yyyy"));
            reportBuilder.AddColumn("Next Day", d => d.AddDays(1)); // .SetValueFormatter(new DateTimeValueFormatter("MM/dd/yyyy"));

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                new DateTime(2020, 10, 24, 20, 25, 00),
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0][0].Value.Should().Be("The Date");
            headerCells[0][0].ValueType.Should().Be(typeof(string));
            headerCells[0][1].Value.Should().Be("Next Day");
            headerCells[0][1].ValueType.Should().Be(typeof(string));

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(1);
            cells[0][0].Value.Should().Be("10/24/2020");
            cells[0][0].ValueType.Should().Be(typeof(DateTime));
            cells[0][1].Value.Should().Be("10/25/2020");
            cells[0][1].ValueType.Should().Be(typeof(DateTime));
        }
コード例 #2
0
        public void Build_FromDataReader_Correct()
        {
            VerticalReportSchemaBuilder <IDataReader> builder = new VerticalReportSchemaBuilder <IDataReader>();

            builder.AddColumn("Name", x => x.GetString(0));
            builder.AddColumn("Age", x => x.GetInt32(1));

            DataTable dataTable = new DataTable();

            dataTable.Columns.AddRange(new[]
            {
                new DataColumn("Name", typeof(string)),
                new DataColumn("Age", typeof(int)),
            });
            dataTable.Rows.Add("John", 23);
            dataTable.Rows.Add("Jane", 22);
            IDataReader dataReader = new DataTableReader(dataTable);
            IReportTable <ReportCell> reportTable = builder.BuildSchema().BuildReportTable(dataReader);

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

            cells[0][0].GetValue <string>().Should().Be("John");
            cells[0][1].GetValue <int>().Should().Be(23);
            cells[1][0].GetValue <string>().Should().Be("Jane");
            cells[1][1].GetValue <int>().Should().Be(22);
        }
コード例 #3
0
        private IReportTable <ReportCell> BuildReport()
        {
            VerticalReportSchemaBuilder <Entity> builder = new VerticalReportSchemaBuilder <Entity>();

            builder.AddColumn("First name", e => e.FirstName);
            builder.AddColumn("Last name", e => e.LastName);
            builder.AddColumn("Email", e => e.Email);
            builder.AddColumn("Age", e => e.Age);

            return(builder.BuildSchema().BuildReportTable(this.GetData()));
        }
コード例 #4
0
        private IReportTable <ReportCell> BuildReport()
        {
            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder.AddColumn("Name", e => e.Name);
            reportBuilder.AddColumn("Last Score", e => e.LastScore);
            reportBuilder.AddColumn("Score", e => e.Score);

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #5
0
        private IReportTable <ReportCell> BuildReport()
        {
            HighlightCellProcessor highlightCellProcessor = new HighlightCellProcessor();

            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder.AddColumn("Name", e => e.Name).AddProcessors(highlightCellProcessor);
            reportBuilder.AddColumn("Score", e => e.Score).AddProcessors(highlightCellProcessor);

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #6
0
        private IReportTable <ReportCell> BuildReport()
        {
            HeatmapProperty heatmapProperty = new HeatmapProperty(0, Color.IndianRed, 100, Color.SkyBlue);

            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder.AddColumn("Name", e => e.Name);
            reportBuilder.AddColumn("Score", e => e.Score)
            .AddProperties(heatmapProperty);

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #7
0
        private IReportTable <ReportCell> BuildReport()
        {
            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder.AddColumn("Name", e => e.Name)
            .AddHeaderProperties(new AlignmentProperty(Alignment.Right));
            reportBuilder.AddColumn("Email", e => e.Email)
            .AddHeaderProperties(new ColorProperty(Color.Blue));
            reportBuilder.AddColumn("Score", e => e.Score)
            .AddHeaderProperties(new AlignmentProperty(Alignment.Center));

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #8
0
        private IReportTable <ReportCell> BuildReport()
        {
            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder
            .AddColumn("First Name", e => e.FirstName)
            .AddColumn("Last Name", e => e.LastName)
            .AddColumn("Email", e => e.Email)
            .AddProperties(new ReplaceEmptyProperty("-"));
            reportBuilder.AddColumn("Score", e => e.Score)
            .AddProperties(new ReplaceEmptyProperty("(no score)"));

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #9
0
        public void Build_WithCustomPropertyForComplexHeaderUsingAddHeaderProperty_CorrectProperties()
        {
            VerticalReportSchemaBuilder <string> reportBuilder = new VerticalReportSchemaBuilder <string>();

            reportBuilder.AddColumn("Value", s => s);
            reportBuilder.AddComplexHeader(0, "Complex", "Value");
            reportBuilder.AddComplexHeaderProperties("Complex", new CustomHeaderProperty());

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new string[] { });

            ReportCell[][] cells = this.GetCellsAsArray(table.HeaderRows);
            cells.Should().HaveCount(2);
            cells[0][0].Properties.Should()
            .HaveCount(1).And
            .ContainItemsAssignableTo <CustomHeaderProperty>();
        }
コード例 #10
0
        public async Task <IActionResult> Index()
        {
            await using SqliteConnection connection = new SqliteConnection("Data Source=Test.db");
            IDataReader dataReader = await connection.ExecuteReaderAsync("SELECT Id, Title FROM Products", CommandBehavior.CloseConnection);

            VerticalReportSchemaBuilder <IDataReader> builder = new VerticalReportSchemaBuilder <IDataReader>();

            builder.AddColumn("ID", x => x.GetInt32(0));
            builder.AddColumn("Title", x => x.GetString(1));
            IReportTable <HtmlReportCell> reportTable = this.htmlConverter.Convert(builder.BuildSchema().BuildReportTable(dataReader));
            string tableHtml = await this.stringWriter.WriteToStringAsync(reportTable);

            return(this.View(new IndexViewModel()
            {
                ReportHtml = tableHtml,
            }));
        }
コード例 #11
0
        public void Build_CustomPropertyUsingProcessor_CorrectProperties()
        {
            VerticalReportSchemaBuilder <string> reportBuilder = new VerticalReportSchemaBuilder <string>();

            reportBuilder.AddColumn("Value", s => s)
            .AddProcessors(new CustomPropertyProcessor());

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                "Test",
            });

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(1);
            cells[0][0].Properties.Should()
            .HaveCount(1).And
            .ContainSingle(p => p is CustomProperty && ((CustomProperty)p).Assigned);
        }
コード例 #12
0
        private IReportTable <ReportCell> BuildReport()
        {
            ThreeColorHeatmapProperty scoreHeatmapProperty     = new ThreeColorHeatmapProperty(0, Color.Red, 50, Color.Yellow, 100, Color.Lime);
            ThreeColorHeatmapProperty lastScoreHeatmapProperty = new ThreeColorHeatmapProperty(0, Color.Red, 5, Color.Yellow, 10, Color.Lime);

            VerticalReportSchemaBuilder <Entity> reportBuilder = new VerticalReportSchemaBuilder <Entity>();

            reportBuilder
            .AddColumn("Name", e => e.Name)
            .AddColumn("Last Score", e => e.LastScore)
            .AddProperties(lastScoreHeatmapProperty);
            reportBuilder.AddColumn("Score", e => e.Score)
            .AddProperties(scoreHeatmapProperty);

            IReportTable <ReportCell> reportTable = reportBuilder.BuildSchema().BuildReportTable(this.GetData());

            return(reportTable);
        }
コード例 #13
0
        public void Build_OneColumnTwoHeaderRows_CorrectCells()
        {
            VerticalReportSchemaBuilder <int> reportBuilder = new VerticalReportSchemaBuilder <int>();

            reportBuilder.AddColumn("Value", i => i);
            reportBuilder.AddComplexHeader(0, "Statistics", "Value");

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[] { 1 });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(2);
            headerCells[0][0].GetValue <string>().Should().Be("Statistics");
            headerCells[1][0].GetValue <string>().Should().Be("Value");

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(1);
            cells[0][0].GetValue <int>().Should().Be(1);
        }
        public void Build_SequentialNumberValueProviderWithNonDefaultStartValue_CorrectValues()
        {
            VerticalReportSchemaBuilder <string> reportBuilder = new VerticalReportSchemaBuilder <string>();

            reportBuilder.AddColumn("#", new SequentialNumberValueProvider(15));

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                "John Doe",
                "Jane Doe",
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0][0].GetValue <string>().Should().Be("#");

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(2);
            cells[0][0].GetValue <int>().Should().Be(15);
            cells[1][0].GetValue <int>().Should().Be(16);
        }
コード例 #15
0
        public void Build_CustomPropertyUsingAddProperty_CorrectProperties()
        {
            VerticalReportSchemaBuilder <string> reportBuilder = new VerticalReportSchemaBuilder <string>();

            reportBuilder.AddColumn("Value", s => s)
            .AddProperties(new CustomProperty());

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                "Test",
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0][0].Properties.Should().BeEmpty();

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(1);
            cells[0][0].Properties.Should()
            .HaveCount(1).And
            .AllBeOfType <CustomProperty>();
        }
コード例 #16
0
        public void Build_DifferentTypes_CorrectValue()
        {
            VerticalReportSchemaBuilder <int> reportBuilder = new VerticalReportSchemaBuilder <int>();

            reportBuilder.AddColumn("#", i => i);
            reportBuilder.AddColumn("Today", new CallbackValueProvider <DateTime>(() => DateTime.Today));
            reportBuilder.AddColumn("ToString()", i => i.ToString());

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                3,
                6,
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0][0].ValueType.Should().Be(typeof(string));
            headerCells[0][0].GetValue <string>().Should().Be("#");
            headerCells[0][1].ValueType.Should().Be(typeof(string));
            headerCells[0][1].GetValue <string>().Should().Be("Today");
            headerCells[0][2].ValueType.Should().Be(typeof(string));
            headerCells[0][2].GetValue <string>().Should().Be("ToString()");

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(2);
            cells[0][0].ValueType.Should().Be(typeof(int));
            cells[0][0].GetValue <int>().Should().Be(3);
            cells[0][1].ValueType.Should().Be(typeof(DateTime));
            cells[0][1].GetValue <DateTime>().Should().Be(DateTime.Today);
            cells[0][2].ValueType.Should().Be(typeof(string));
            cells[0][2].GetValue <string>().Should().Be("3");
            cells[1][0].ValueType.Should().Be(typeof(int));
            cells[1][0].GetValue <int>().Should().Be(6);
            cells[1][1].ValueType.Should().Be(typeof(DateTime));
            cells[1][1].GetValue <DateTime>().Should().Be(DateTime.Today);
            cells[1][2].ValueType.Should().Be(typeof(string));
            cells[1][2].GetValue <string>().Should().Be("6");
        }
コード例 #17
0
        public void Build_DecimalColumnWithRounding_CorrectDisplayValue()
        {
            VerticalReportSchemaBuilder <decimal> reportBuilder = new VerticalReportSchemaBuilder <decimal>();

            reportBuilder.AddColumn("Score", d => d); // .SetValueFormatter(new DecimalValueFormatter(0));

            IReportTable <ReportCell> table = reportBuilder.BuildSchema().BuildReportTable(new[]
            {
                3m,
                6.5m,
            });

            ReportCell[][] headerCells = this.GetCellsAsArray(table.HeaderRows);
            headerCells.Should().HaveCount(1);
            headerCells[0][0].Value.Should().Be("Score");
            headerCells[0][0].ValueType.Should().Be(typeof(string));

            ReportCell[][] cells = this.GetCellsAsArray(table.Rows);
            cells.Should().HaveCount(2);
            cells[0][0].Value.Should().Be("3");
            cells[0][0].ValueType.Should().Be(typeof(decimal));
            cells[1][0].Value.Should().Be("7");
            cells[1][0].ValueType.Should().Be(typeof(decimal));
        }