Exemple #1
0
        public void ImportAuthorList_EmptyExcel_ShouldReturnEmptyAuthorsList()
        {
            // 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 authors = dataImport.ImportAuthorsList();

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

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

            data.CatalogTestsDataList.Add(data.CatalogTestsDataList[0]);
            package.CreateTestsExcel(data);
            using var dataImport = new SpreadsheetDataImport(data.FileName);
            // Act
            var authors = dataImport.ImportAuthorsList();

            // Assert
            authors.Should().HaveCount(data.CatalogTestsDataList.Count - 1);
            authors.Should().OnlyHaveUniqueItems();

            package.File.Delete();
        }
Exemple #3
0
        public void ImportAuthorsList_ShouldReturnAuthorsList()
        {
            // Arrange
            using var package = new ExcelPackage();
            var data = new TestExcelData();

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

            // Assert
            authors.Should().HaveSameCount(data.CatalogTestsDataList);
            for (int i = 0; i < authors.Count; i++)
            {
                var author      = authors[i];
                var catalogData = data.CatalogTestsDataList[i];
                author.Id.Should().NotBeEmpty();
                author.FirstName.Should().Be(catalogData.AuthorFirstName);
                author.LastName.Should().Be(catalogData.AuthorLastName);
            }

            package.File.Delete();
        }