Example #1
0
        public async Task Given_A_Valid_CardTriviaInformationConsumer_Should_Execute_Send_Method_Once()
        {
            // Arrange
            var cardTriviaInformationConsumer = new CardTriviaInformationConsumer
            {
                Message = "{\"Id\":703544,\"CorrelationId\":\"3e2bf3ca-d903-440c-8cd5-be61c95ae1fc\",\"Title\":\"Tenyi\",\"Url\":\"https://yugioh.fandom.com/wiki/Card_Trivia:Tenyi\"}"
            };

            _mediator.Send(Arg.Any <CardInformationConsumer>(), Arg.Any <CancellationToken>()).Returns(new CardInformationConsumerResult());

            // Act
            await _sut.Handle(cardTriviaInformationConsumer, CancellationToken.None);

            // Assert
            await _mediator.Received(1).Send(Arg.Any <CardInformationConsumer>(), Arg.Any <CancellationToken>());
        }
Example #2
0
        public async Task Given_An_Invalid_CardTriviaInformationConsumer_IsSuccessful_Should_Be_False()
        {
            // Arrange
            var cardTriviaInformationConsumer = new CardTriviaInformationConsumer();

            _mediator.Send(Arg.Any <CardInformationConsumer>(), Arg.Any <CancellationToken>()).Returns(new CardInformationConsumerResult {
                Errors = new List <string>
                {
                    "Something went horriblely wrong."
                }
            });

            // Act
            var result = await _sut.Handle(cardTriviaInformationConsumer, CancellationToken.None);

            // Assert
            result.IsSuccessful.Should().BeFalse();
        }
Example #3
0
        public async Task Given_An_Invalid_CardTriviaInformationConsumer_Errors_List_Should_Not_Be_Null_Or_Empty()
        {
            // Arrange
            var cardTriviaInformationConsumer = new CardTriviaInformationConsumer();

            _mediator.Send(Arg.Any <CardInformationConsumer>(), Arg.Any <CancellationToken>()).Returns(new CardInformationConsumerResult
            {
                Errors = new List <string>
                {
                    "Something went horriblely wrong."
                }
            });

            // Act
            var result = await _sut.Handle(cardTriviaInformationConsumer, CancellationToken.None);

            // Assert
            result.Errors.Should().NotBeNullOrEmpty();
        }
Example #4
0
        public async Task Given_A_Valid_CardTriviaInformationConsumer_If_Not_Processed_Successfully_Errors_Should_Not_Be_Null_Or_Empty()
        {
            // Arrange
            var cardInformationConsumer = new CardTriviaInformationConsumer
            {
                Message = "{\"Id\":703544,\"CorrelationId\":\"3e2bf3ca-d903-440c-8cd5-be61c95ae1fc\",\"Title\":\"Tenyi\",\"Url\":\"https://yugioh.fandom.com/wiki/Card_Trivia:Tenyi\"}"
            };

            _mediator.Send(Arg.Any <CardInformationConsumer>(), Arg.Any <CancellationToken>()).Returns(new CardInformationConsumerResult {
                Errors = new List <string> {
                    "Something went horribly wrong"
                }
            });

            // Act
            var result = await _sut.Handle(cardInformationConsumer, CancellationToken.None);

            // Assert
            result.Errors.Should().NotBeNullOrEmpty();
        }