Beispiel #1
0
        public async Task Given_An_Invalid_CardInformationTask_Should_Not_Execute_Process()
        {
            // Arrange
            var task = new CardInformationTask();

            _articleCategoryProcessor.Process(Arg.Any <string>(), Arg.Any <int>()).Returns(new ArticleBatchTaskResult());

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

            // Assert
            await _articleCategoryProcessor.DidNotReceive().Process(Arg.Any <string>(), Arg.Any <int>());
        }
Beispiel #2
0
        public async Task <CardInformationTaskResult> Handle(CardInformationTask request, CancellationToken cancellationToken)
        {
            var response = new CardInformationTaskResult();

            var validationResults = _validator.Validate(request);

            if (validationResults.IsValid)
            {
                foreach (var category in request.Categories)
                {
                    var categoryResult = await _articleCategoryProcessor.Process(category, request.PageSize);

                    response.ArticleTaskResults.Add(categoryResult);
                }

                await _semanticSearchProcessor.ProcessUrl(SemanticSearchCategory.NormalMonsters, SemanticSearchUrls.NormalMonsterCardsSearch);

                await _semanticSearchProcessor.ProcessUrl(SemanticSearchCategory.FlipMonsters, SemanticSearchUrls.FlipMonsterCardsSearch);
            }
            else
            {
                response.Errors = validationResults.Errors.Select(err => err.ErrorMessage).ToList();
            }

            return(response);
        }
        public async Task Given_An_Valid_ArchetypeInformationTask_Should_Execute_Process()
        {
            // Arrange
            var task = new ArchetypeInformationTask
            {
                Category = "category",
                PageSize = 1
            };

            _articleCategoryProcessor.Process(Arg.Any <string>(), Arg.Any <int>()).Returns(new ArticleBatchTaskResult());

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

            // Assert
            await _articleCategoryProcessor.Received(1).Process(Arg.Any <string>(), Arg.Any <int>());
        }
        public async Task <CardRulingsTaskResult> Handle(CardRulingsTask request, CancellationToken cancellationToken)
        {
            var response = new CardRulingsTaskResult();

            var validationResults = _validator.Validate(request);

            if (validationResults.IsValid)
            {
                var categoryResult = await _articleCategoryProcessor.Process(request.Category, request.PageSize);

                response.ArticleTaskResults = categoryResult;
            }
            else
            {
                response.Errors = validationResults.Errors.Select(err => err.ErrorMessage).ToList();
            }

            return(response);
        }
        public async Task <ArchetypeInformationTaskResult> Handle(ArchetypeInformationTask request, CancellationToken cancellationToken)
        {
            var archetypeInformationTaskResult = new ArchetypeInformationTaskResult();

            var validationResults = await _validator.ValidateAsync(request, cancellationToken);

            if (validationResults.IsValid)
            {
                var results = await _articleCategoryProcessor.Process(request.Category, request.PageSize);

                archetypeInformationTaskResult.ArticleTaskResult = results;
            }
            else
            {
                archetypeInformationTaskResult.Errors = validationResults.Errors.Select(err => err.ErrorMessage).ToList();
            }

            return(archetypeInformationTaskResult);
        }
Beispiel #6
0
        public async Task <BanlistInformationTaskResult> Handle(BanlistInformationTask request, CancellationToken cancellationToken)
        {
            var response = new BanlistInformationTaskResult();

            var validationResults = _validator.Validate(request);

            if (validationResults.IsValid)
            {
                var categoryResult = await _articleCategoryProcessor.Process(request.Category, request.PageSize);

                await _banlistProcessor.Process(BanlistType.Tcg);

                await _banlistProcessor.Process(BanlistType.Ocg);

                response.ArticleTaskResults = categoryResult;
                response.IsSuccessful       = true;
            }
            else
            {
                response.Errors = validationResults.Errors.Select(err => err.ErrorMessage).ToList();
            }

            return(response);
        }