public async Task Given_A_Valid_Article_If_An_Exception_Is_Thrown_IsSuccessfullyProcessed_Variable_Should_False() { // Arrange var article = new UnexpandedArticle(); _cardArticleQueue.Publish(Arg.Any <UnexpandedArticle>()).Throws(new Exception()); // Act var result = await _sut.ProcessItem(article); // Assert result.IsSuccessfullyProcessed.Should().BeFalse(); }
public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var articleTaskResult = new ArticleTaskResult { Article = item }; try { await _cardArticleQueue.Publish(item); articleTaskResult.IsSuccessfullyProcessed = true; } catch (Exception ex) { articleTaskResult.Failed = new ArticleException { Article = item, Exception = ex }; } return(articleTaskResult); }