public void Extract_Null_ShouldReturnYear() { // Arrange string text = null; // Act var year = YearExtractor.Extract(text); // Assert year.Should().BeNull(); }
public void Extract_Empty_ShouldReturnYear() { // Arrange var text = string.Empty; // Act var year = YearExtractor.Extract(text); // Assert year.Should().BeNull(); }
public void Extract_DotPause_ShouldReturnYear() { // Arrange var text = ".-"; // Act var year = YearExtractor.Extract(text); // Assert year.Should().BeNull(); }
public void Extract_PauseAndApostrophe_ShouldReturnYear() { // Arrange var text = "'-"; // Act var year = YearExtractor.Extract(text); // Assert year.Should().BeNull(); }
public void Extract_ShouldReturnYear() { // Arrange var expectedYear = 1995; var text = expectedYear.ToString(); // Act var year = YearExtractor.Extract(text); // Assert year.Should().Be(expectedYear); }
public List <Book> ImportBooksList() { var authors = ImportAuthorsList(); var seriesInfos = ImportSeriesListInfo(); var publishingHouses = ImportPublishingHousesList(); var storagePlaces = ImportStoragePlacesList(); var categories = ImportCategoriesList(); var seriesList = seriesInfos .GroupBy(a => a.SeriesName) .Select(a => a.First()) .Where(a => !string.IsNullOrEmpty(a.SeriesName)) .Select(a => a.ToSeries()) .ToList(); List <Book> books = new List <Book>(); foreach (var spreadsheetCatalogData in CatalogData) { var bookCategories = new List <Category>() { CategoryExtractor.Extract(spreadsheetCatalogData.Category) }; bookCategories = bookCategories.Where(a => a != null).ToList(); var bookSeriesInfo = SeriesInfoExtractor.Extract(spreadsheetCatalogData.Series); var book = new Book { Id = Guid.NewGuid(), Title = TitleExtractor.Extract(spreadsheetCatalogData.Title), Authors = AuthorExtractor.Extract(spreadsheetCatalogData.Author), Series = bookSeriesInfo?.ToSeries(), PublishingHouse = PublishingHouseExtractor.Extract(spreadsheetCatalogData.PublishingHouse), PublishmentYear = YearExtractor.Extract(spreadsheetCatalogData.Year), ISBN = IsbnExtractor.Extract(spreadsheetCatalogData.ISBN), Language = LanguageExtractor.Extract(spreadsheetCatalogData.Language), StoragePlace = StoragePlaceExtractor.Extract(spreadsheetCatalogData.StoragePlace), Comment = CommentExtractor.Extract(spreadsheetCatalogData.Comment), Categories = bookCategories, VolumeNumber = bookSeriesInfo?.VolumeNumber }; ImportBookValidator.CheckAuthors(authors, book.Authors); ImportBookValidator.CheckSeries(seriesList, book.Series); ImportBookValidator.CheckPublishingHouse(publishingHouses, book.PublishingHouse); ImportBookValidator.CheckStoragePlace(storagePlaces, book.StoragePlace); ImportBookValidator.CheckCategory(categories, book.Categories); books.Add(book); } return(books); }