コード例 #1
0
        public async Task Given_An_Invalid_Normal_Monster_Url_IsSuccessfullyProcessed_Should_Be_False()
        {
            // Arrange
            _config.WikiaDomainUrl.Returns("http://www.yugioh.wikia.com");
            _cardWebPage.GetYugiohCard(Arg.Any <Uri>()).Returns((YugiohCard)null);

            // Act
            var result = await _sut.ProcessItem(new SemanticCard { Name = "NotACard", Url = "/wiki/Archetype" });

            // Assert
            result.IsSuccessfullyProcessed.Should().BeFalse();
        }
コード例 #2
0
        public async Task <SemanticSearchTaskResult> ProcessItem(SemanticCard semanticCard)
        {
            var response = new SemanticSearchTaskResult {
                Card = semanticCard
            };

            var yugiohCard = _cardWebPage.GetYugiohCard(new Uri(new Uri(_config.WikiaDomainUrl), semanticCard.Url));

            if (yugiohCard != null)
            {
                response.YugiohCard = yugiohCard;

                const string flip = "Flip";
                if (!yugiohCard.Types.ToLower().Contains(flip.ToLower()))
                {
                    yugiohCard.Types = $"{yugiohCard.Types} / {flip}";
                }


                var card = await _yugiohCardService.AddOrUpdate(yugiohCard);

                if (card != null)
                {
                    response.IsSuccessfullyProcessed = true;
                }
            }

            return(response);
        }
コード例 #3
0
        public async Task Given_A_Valid_Article_Should_Execute_GetYugiohCard()
        {
            // Arrange
            var article = new UnexpandedArticle {
                Title = "Blue-Eyes", Url = "/wiki/Blue-Eyes"
            };

            _config.WikiaDomainUrl.Returns("http://yugioh.wikia.com");
            _cardWebPage.GetYugiohCard(Arg.Any <string>()).Returns((YugiohCard)null);

            // Act
            await _sut.ProcessItem(article);

            // Assert
            _cardWebPage.Received(1).GetYugiohCard(Arg.Any <Uri>());
        }
コード例 #4
0
        public async Task <ArticleCompletion> ProcessDataFlow(Article article)
        {
            var articleProcessed     = _cardWebPage.GetYugiohCard(article);
            var yugiohCardCompletion = await _yugiohCardQueue.Publish(articleProcessed);

            if (yugiohCardCompletion.IsSuccessful)
            {
                return(new ArticleCompletion {
                    IsSuccessful = true, Message = yugiohCardCompletion.Article
                });
            }

            var exceptionMessage = $"Card Article with id '{yugiohCardCompletion.Article.Id}' and correlation id {yugiohCardCompletion.Article.CorrelationId} not processed.";

            throw new ArticleCompletionException(exceptionMessage);
        }
コード例 #5
0
        public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item)
        {
            var response = new ArticleTaskResult {
                Article = item
            };

            var yugiohCard = _cardWebPage.GetYugiohCard(new Uri(new Uri(_config.WikiaDomainUrl), item.Url));

            if (yugiohCard != null)
            {
                var card = await _yugiohCardService.AddOrUpdate(yugiohCard);

                if (card != null)
                {
                    response.IsSuccessfullyProcessed = true;
                }
            }

            return(response);
        }