public async Task Given_A_Valid_Article_Should_Invoke_ProcessItem_Method_Once() { // Arrange const int expected = 1; 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 await _sut.ProcessItem(article); // Assert await _cardSectionProcessor.Received(expected).ProcessItem(Arg.Any <Article>()); }
public async Task Given_A_Valid_CardInformationConsumer_Should_Execute_Process_Method_Once() { // Arrange var cardInformationConsumer = new CardInformationConsumer { Category = "category", Message = "{\"Id\":703544,\"CorrelationId\":\"3e2bf3ca-d903-440c-8cd5-be61c95ae1fc\",\"Title\":\"Tenyi\",\"Url\":\"https://yugioh.fandom.com/wiki/Card_Tips:Tenyi\"}" }; _validator.Validate(Arg.Any <CardInformationConsumer>()) .Returns(new CardInformationConsumerValidator().Validate(cardInformationConsumer)); _cardSectionProcessor.Process(Arg.Any <string>(), Arg.Any <CardSectionMessage>()).Returns(new CardSectionDataTaskResult <CardSectionMessage>()); // Act await _sut.Handle(cardInformationConsumer, CancellationToken.None); // Assert await _cardSectionProcessor.Received(1).Process(Arg.Any <string>(), Arg.Any <CardSectionMessage>()); }