public async Task Given_A_Valid_ArticleList_Collection_Should_Execute_Process()
        {
            // Arrange
            var fixture = new Fixture {
                RepeatCount = 4
            };
            var          articles          = fixture.Create <UnexpandedArticle[]>();
            const string aCategory         = "a category";
            var          unexpandedArticle = new UnexpandedArticle();

            _articleProcessor
            .Process(aCategory, unexpandedArticle)
            .ReturnsForAnyArgs
            (
                x => new ArticleTaskResult {
                IsSuccessfullyProcessed = true
            },
                x => new ArticleTaskResult {
                IsSuccessfullyProcessed = true
            },
                x => null,
                x => null
            );

            // Act
            await _sut.Process(aCategory, articles);

            // Assert
            await _articleProcessor.Received(4).Process(Arg.Any <string>(), Arg.Any <UnexpandedArticle>());
        }
예제 #2
0
        public async Task Given_A_banlistType_Should_Invoke_Process_Method_Twice()
        {
            // Arrange
            const int expected = 2;

            _banlistUrlDataSource
            .GetBanlists(Arg.Any <BanlistType>(), Arg.Any <string>())
            .Returns
            (
                new Dictionary <int, List <int> >
            {
                [2017] = new List <int> {
                    1, 2
                }
            }
            );
            _articleProcessor
            .Process(Arg.Any <string>(), Arg.Any <UnexpandedArticle>())
            .Returns(new ArticleTaskResult {
                IsSuccessfullyProcessed = true
            });

            // Act
            await _sut.Process(BanlistType.Tcg);

            // Assert
            await _articleProcessor.Received(expected).Process(Arg.Any <string>(), Arg.Any <UnexpandedArticle>());
        }
        public async Task Given_A_Category_And_A_SemanticCard_Should_Execute_Process()
        {
            // Arrange
            var category          = "Flip";
            var unexpandedArticle = new UnexpandedArticle {
                Title = "Red-Eyes Black Dragon"
            };

            _articleProcessor.Process(Arg.Any <string>(), Arg.Any <UnexpandedArticle>()).Returns(new ArticleTaskResult());

            // Act
            await _sut.Process(category, unexpandedArticle);

            // Assert
            await _articleProcessor.Received(1).Process(Arg.Any <string>(), Arg.Any <UnexpandedArticle>());
        }
예제 #4
0
        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));
            _articleProcessor.Process(Arg.Any <string>(), Arg.Any <Article>()).Returns(new ArticleTaskResult());

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

            // Assert
            await _articleProcessor.Received(1).Process(Arg.Any <string>(), Arg.Any <Article>());
        }
예제 #5
0
        public async Task Given_An_Valid_BanlistInformationConsumer_Should_Invoke_ArticleProcessor_Process_Once()
        {
            // Arrange
            var banlistInformationConsumer = new BanlistInformationConsumer
            {
                Message = $"{{\"Id\":16022,\"CorrelationId\":\"0606a974-ea5f-436b-a263-ee638762e019\",\"Title\":\"Historic Forbidden/Limited Chart\",\"Url\":null}}"
            };

            _validator
            .Validate(Arg.Is(banlistInformationConsumer))
            .Returns(new BanlistInformationConsumerValidator().Validate(banlistInformationConsumer));

            _articleProcessor.Process(Arg.Any <Article>())
            .Returns(new ArticleConsumerResult {
                IsSuccessfullyProcessed = true
            });

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

            // Assert
            await _articleProcessor.Received(1).Process(Arg.Any <Article>());
        }
        public async Task Given_An_Valid_CardInformationConsumer_Should_Invoke_ArticleProcessor_Process_Once()
        {
            // Arrange
            var cardInformationConsumer = new CardInformationConsumer
            {
                Message = "{\"Id\":10917,\"Title\":\"Amazoness Archer\",\"Url\":\"https://yugioh.fandom.com/wiki/Amazoness_Archer\"}"
            };

            _validator
            .Validate(Arg.Is(cardInformationConsumer))
            .Returns(new CardInformationConsumerValidator().Validate(cardInformationConsumer));

            _articleProcessor.Process(Arg.Any <Article>())
            .Returns(new ArticleConsumerResult {
                IsSuccessfullyProcessed = true
            });

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

            // Assert
            await _articleProcessor.Received(1).Process(Arg.Any <Article>());
        }