Example #1
0
        public void ImportBooksList_ShouldReturnBooksList()
        {
            // Arrange
            using var package = new ExcelPackage();
            var data = new TestExcelData();

            package.CreateTestsExcel(data);
            using var dataImport = new SpreadsheetDataImport(data.FileName);
            // Act
            var books = dataImport.ImportBooksList();

            // Assert
            books.Should().HaveSameCount(data.CatalogTestsDataList);
            for (int i = 0; i < books.Count; i++)
            {
                var book        = books[i];
                var catalogData = data.CatalogTestsDataList[i];
                book.Id.Should().NotBeEmpty();
                book.Title.Should().Be(catalogData.Title);
                book.PublishmentYear.Should().Be(Convert.ToInt32(catalogData.Year));
                book.ISBN.Should().Be(catalogData.ISBN);
                book.Language.Should().Be(catalogData.LanguageEnum);
                book.Comment.Should().Be(catalogData.Comment);
            }

            package.File.Delete();
        }
Example #2
0
        public void ImportBooksList_EmptyExcel_ShouldReturnEmptyBooksList()
        {
            // Arrange
            using var package = new ExcelPackage();
            var data = new TestExcelData();

            data.CatalogTestsDataList.Clear();
            package.CreateTestsExcel(data);
            using var dataImport = new SpreadsheetDataImport(data.FileName);
            // Act
            var books = dataImport.ImportBooksList();

            // Assert
            books.Should().BeEmpty();

            package.File.Delete();
        }