public void LoadData_ShouldReturnSpreadsheetDataList() { // Arrange using var package = new ExcelPackage(); var data = new TestExcelData(); package.CreateTestsExcel(data); using var dataImport = new SpreadsheetDataImport(data.FileName); var spreadsheetDataList = dataImport.CatalogData; // Act dataImport.LoadData(); // Assert spreadsheetDataList.Should().HaveSameCount(data.CatalogTestsDataList); for (int i = 0; i < spreadsheetDataList.Count; i++) { var spreadsheetData = spreadsheetDataList[i]; var catalogData = data.CatalogTestsDataList[i]; var color = spreadsheetData.Category.Substring(2).Insert(0, "#"); spreadsheetData.Title.Should().Be(catalogData.Title); spreadsheetData.Author.Should().Be(catalogData.Author); spreadsheetData.Series.Should().Be(catalogData.Series); spreadsheetData.PublishingHouse.Should().Be(catalogData.PublishingHouse); spreadsheetData.Town.Should().Be(catalogData.Town); spreadsheetData.Year.Should().Be(catalogData.Year); spreadsheetData.Language.Should().Be(catalogData.Language); spreadsheetData.ISBN.Should().Be(catalogData.ISBN); spreadsheetData.StoragePlace.Should().Be(catalogData.StoragePlace); spreadsheetData.Comment.Should().Be(catalogData.Comment); color.Should().Be(catalogData.ColorCode); } package.File.Delete(); }
public void LoadData_EmptyExcel_ShouldReturnEmptySpreadsheetDataList() { // Arrange using var package = new ExcelPackage(); var data = new TestExcelData(); data.CatalogTestsDataList.Clear(); package.CreateTestsExcel(data); using var dataImport = new SpreadsheetDataImport(data.FileName); var spreadsheetDataList = dataImport.CatalogData; // Act dataImport.LoadData(); // Assert spreadsheetDataList.Should().BeEmpty(); package.File.Delete(); }