public void WriteToStreamAsync_WithSimpleTestItem_WritesExcelDocumentToStream()
        {
            var data = new SimpleTestItem {
                Value1 = "2,1", Value2 = "2,2"
            };

            var expected = new[] { new[] { "Value1", "Value2" },
                                   new[] { data.Value1, data.Value2 } };

            GenerateAndCompareWorksheet(data, expected);
        }
示例#2
0
        public void WriteToStreamAsync_WithSimpleTestItem_WritesExcelDocumentToStream()
        {
            var data = new SimpleTestItem {
                Value1 = "2,1", Value2 = "2,2"
            };

            var sheet = GetWorksheetFromStream(new XlsxMediaTypeFormatter(), data);

            sheet.Dimension.Should().NotBeNull("Worksheet has no cells.");
            sheet.Dimension.End.Row.Should().Be(2, "Worksheet should have two rows (including header column).");
            sheet.Dimension.End.Column.Should().Be(2, "Worksheet should have two columns.");
            sheet.GetValue <string>(1, 1).Should().Be("Value1", "Header in A1 is incorrect.");
            sheet.GetValue <string>(1, 2).Should().Be("Value2", "Header in B1 is incorrect.");
            sheet.GetValue <string>(2, 1).Should().Be(data.Value1, "Value in A2 is incorrect.");
            sheet.GetValue <string>(2, 2).Should().Be(data.Value2, "Value in B2 is incorrect.");
        }