public void Extractor_Null_ShouldReturnEmptyPublishingHouse()
        {
            // Arrange
            string text = null;
            // Act
            var publishingHouse = PublishingHouseExtractor.Extract(text);

            // Assert
            publishingHouse.Should().BeNull();
        }
        public void Extractor_EmptyName_ShouldReturnEmptyPublishingHouse()
        {
            // Arrange
            var text = string.Empty;
            // Act
            var publishingHouse = PublishingHouseExtractor.Extract(text);

            // Assert
            publishingHouse.Should().BeNull();
        }
        public void Extractor_ApostropheAndPause_ShouldReturnEmptyPublishingHouse()
        {
            // Arrange
            var text = "'-";
            // Act
            var publishingHouse = PublishingHouseExtractor.Extract(text);

            // Assert
            publishingHouse.Should().BeNull();
        }
        public void Extractor_ShouldReturnPublishingHouse()
        {
            // Arrange
            var text = "Zakład wydawniczo-propagandowy PTTK";
            // Act
            var publishingHouse = PublishingHouseExtractor.Extract(text);

            // Assert
            publishingHouse.Id.Should().NotBeEmpty();
            publishingHouse.PublisherName.Should().Be(text);
        }
示例#5
0
        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);
        }
示例#6
0
        public List <PublishingHouse> ImportPublishingHousesList()
        {
            List <PublishingHouse> publishingHousesList = new List <PublishingHouse>();

            foreach (var spreadsheetData in CatalogData)
            {
                var publishingHouse = PublishingHouseExtractor.Extract(spreadsheetData.PublishingHouse);
                if (publishingHouse != null)
                {
                    publishingHousesList.Add(publishingHouse);
                }
            }

            var publisherWithoutDoubles = publishingHousesList
                                          .GroupBy(a => a.PublisherName)
                                          .Select(a => a.First())
                                          .ToList();

            return(publisherWithoutDoubles);
        }