public async Task <ArticleTaskResult> ProcessItem(Article article) { var response = new ArticleTaskResult { Article = article }; var cardSectionMessage = await _cardSectionProcessor.ProcessItem(article); await _queues.Single(q => q.Handles(ArticleCategory.CardTrivia)).Publish(cardSectionMessage); return(response); }
public async Task Given_A_Valid_Article_Should_Process_Article_Successfully() { // Arrange var article = new Article { Title = "Call of the Haunted" }; _cardSectionProcessor.ProcessItem(Arg.Any <Article>()).Returns(new CardSectionMessage()); var handler = Substitute.For <IQueue>(); handler.Handles(Arg.Any <string>()).Returns(true); handler.Publish(Arg.Any <CardSectionMessage>()).Returns(Task.CompletedTask); _queues.GetEnumerator().Returns(new List <IQueue> { handler }.GetEnumerator()); // Act var result = await _sut.ProcessItem(article); // Assert result.Article.Should().Be(article); }