public async Task Given_An_Article_If_Processed_And_Errors_Do_Not_Occur_IsSuccessfullyProcessed_Should_Be_True() { // Arrange var article = new Article(); _articleDataFlow.ProcessDataFlow(article).Returns(new ArticleCompletion { IsSuccessful = true }); // Act var result = await _sut.Process(article); // Assert result.IsSuccessfullyProcessed.Should().BeTrue(); }
public async Task <ArticleConsumerResult> Process(Article article) { var response = new ArticleConsumerResult { Article = article }; try { _logger.LogInformation($"{article.Title} processing... "); var result = await _articleDataFlow.ProcessDataFlow(article); if (result.IsSuccessful) { _logger.LogInformation($"{article.Title} processed successfully. "); response.IsSuccessfullyProcessed = true; } else { _logger.LogInformation($"{article.Title} processing failed. "); } } catch (ArticleCompletionException ex) { _logger.LogError(" {ArticleTitle} error. Exception: {@Exception}, Article: {Article}", article.Title, ex, article); response.Failed = new ArticleException { Article = article, Exception = ex }; } return(response); }
public async Task <ArticleConsumerResult> Process(Article article) { var articleJson = JsonConvert.SerializeObject(article); var response = new ArticleConsumerResult(); response.Article = articleJson; try { _logger.LogInformation($"{article.Title} processing... "); var result = await _articleDataFlow.ProcessDataFlow(article); if (result.IsSuccessful) { _logger.LogInformation($"{article.Title} processed successfully. "); response.IsSuccessfullyProcessed = true; } else { _logger.LogInformation($"{article.Title} processing failed. "); } } catch (Exception ex) { _logger.LogError(article.Title + " error. Exception: {@Exception}", ex); response.Failed = new ArticleException { Article = articleJson, Exception = ex }; } return(response); }