Example #1
0
        public void ExportCollectionsToXlsx_ReturnFilledStreamWithCorrecctStructure()
        {
            var collections = new List <Collection>()
            {
                new Collection {
                    Id = "id1", Name = "collection1"
                },
                new Collection {
                    Id = "id2", Name = "collection2"
                }
            };

            var result = _exportManager.ExportCollectionsToXlsx(collections);

            Assert.IsTrue(result.Length > 0);
            using (var ms = new MemoryStream(result))
            {
                XSSFWorkbook s     = new XSSFWorkbook(ms);
                var          sheet = s.GetSheet("Collection");
                var          row1  = sheet.GetRow(0);
                var          row2  = sheet.GetRow(1);
                var          row3  = sheet.GetRow(2);
                Assert.IsNotNull(sheet);
                Assert.IsNotNull(row1);
                Assert.IsNotNull(row2);
                //row1 should contains header- property name
                Assert.AreEqual(row1.GetCell(0).StringCellValue, "Id");
                Assert.AreEqual(row1.GetCell(1).StringCellValue, "Name");
                Assert.AreEqual(row2.GetCell(0).StringCellValue, "id1");
                Assert.AreEqual(row2.GetCell(1).StringCellValue, "collection1");
                Assert.AreEqual(row3.GetCell(0).StringCellValue, "id2");
                Assert.AreEqual(row3.GetCell(1).StringCellValue, "collection2");
            }
        }