Exemple #1
0
        public async Task ShouldFindAnyWithDate()
        {
            await articles.Add(new Article[] { ArticleBuilder.CreateOne(), ArticleBuilder.CreateOne() });

            var actual = await articles.AnyWithDate(DateTime.UtcNow.Date);

            actual.Should().Be(true);
        }
Exemple #2
0
        public async Task ShouldSaveAnArticle()
        {
            var article = ArticleBuilder.CreateOne();
            await articles.Add(new Article[] { article,
                                               ArticleBuilder.CreateOne() });

            var(isAddedArticle, countAddedAuthors) = await WhenAllWrapper(IsArticleAdded(article.Id), CountArticle(article.Id));

            isAddedArticle.Should().Be(true);
            countAddedAuthors.Should().Be(2);
        }
 public Results AddAnArticle(Articles article)
 {
     try
     {
         results.Result       = articles.Add(article);
         results.Code         = 0;
         results.ErrorMessage = string.Empty;
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         results.Code         = 1;
         results.ErrorMessage = ex.Message;
     }
     return(results);
 }
        public async Task HandleAsync(CrawlerCommand command)
        {
            var entities = new List <Article>();

            for (var i = 1; i <= command.PageLimit; i++)
            {
                var page = await morningBrewClient.GetPageAsync(i);

                var extractedArticles = MorningBrewMapperPage.Map(page);
                var newArticles       = await GetNewArticlesAsync(extractedArticles);

                entities.AddRange(newArticles.Articles);
                if (!newArticles.HasMore)
                {
                    break;
                }
            }
            await articles.Add(entities);
        }