public async Task Given_A_CardsByArchetype_Article_Should_Execute_ArchetypeWebPage_Cards()
        {
            // Arrange
            var article = new UnexpandedArticle {
                Title = "Clear Wing", Url = "/wiki/List_of_\"Clear_Wing\"_cards"
            };

            _config.WikiaDomainUrl.Returns("http://yugioh.wikia.com");
            _archetypeService.ArchetypeByName(Arg.Any <string>()).Returns(new Archetype());
            _archetypeWebPage.Cards(Arg.Any <Uri>()).Returns(new List <string> {
                "Blue-Eyes White Dragon"
            });
            _archetypeCardsService.Update(Arg.Any <UpdateArchetypeCardsCommand>()).Returns((IEnumerable <ArchetypeCard>)null);

            // Act
            await _sut.ProcessItem(article);

            // Assert
            _archetypeWebPage.Received(1).Cards(Arg.Any <Uri>());
        }
示例#2
0
        public async Task <ArchetypeDataTaskResult <ArchetypeCardMessage> > Process(ArchetypeCardMessage archetypeData)
        {
            var articleDataTaskResult = new ArchetypeDataTaskResult <ArchetypeCardMessage>
            {
                ArchetypeData = archetypeData
            };

            var existingArchetype = await _archetypeService.ArchetypeByName(archetypeData.ArchetypeName);

            if (existingArchetype != null && archetypeData.Cards.Any())
            {
                await _archetypeCardsService.Update(existingArchetype.Id, archetypeData.Cards);
            }

            return(articleDataTaskResult);
        }
示例#3
0
        public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item)
        {
            var response = new ArticleTaskResult {
                Article = item
            };
            var archetypeName = StringHelpers.ArchetypeNameFromListTitle(item.Title);

            var archetypeUrl = new Uri(new Uri(_config.WikiaDomainUrl), item.Url);

            var existingArchetype = await _archetypeService.ArchetypeByName(archetypeName);

            if (existingArchetype != null)
            {
                var archetype = await _archetypeCardsService.Update(new UpdateArchetypeCardsCommand { ArchetypeId = existingArchetype.Id, Cards = _archetypeWebPage.Cards(archetypeUrl) });

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

            return(response);
        }