Пример #1
0
        public async Task Given_An_AllTypes_Query_Should_Return_All_Types()
        {
            // Arrange
            const int expected = 2;

            _typesService.AllTypes().Returns(new List <Type> {
                new Type(), new Type()
            });

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

            // Assert
            result.Should().HaveCount(expected);
        }
Пример #2
0
        private async Task <CardInputModel> MapToCardInputModel(YugiohCard yugiohCard, CardInputModel cardInputModel, ICollection <Category> categories, ICollection <SubCategory> subCategories)
        {
            CardHelper.MapBasicCardInformation(yugiohCard, cardInputModel);
            CardHelper.MapCardImageUrl(yugiohCard, cardInputModel);

            if (cardInputModel.CardType.Equals(YgoCardType.Spell))
            {
                SpellCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, categories, subCategories);
            }
            else if (cardInputModel.CardType.Equals(YgoCardType.Trap))
            {
                TrapCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, categories, subCategories);
            }
            else
            {
                ICollection <Type> types = await _typeService.AllTypes();

                ICollection <Attribute> attributes = await _attributeService.AllAttributes();

                ICollection <LinkArrow> linkArrows = await _linkArrowService.AllLinkArrows();

                var monsterCategory      = categories.Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase));
                var monsterSubCategories = subCategories.Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id);

                MonsterCardHelper.MapMonsterCard(yugiohCard, cardInputModel, attributes, monsterSubCategories, types, linkArrows);
            }

            return(cardInputModel);
        }
        public void SetUp()
        {
            _categoryService    = Substitute.For <ICategoryService>();
            _subCategoryService = Substitute.For <ISubCategoryService>();
            _typeService        = Substitute.For <ITypeService>();
            _attributeService   = Substitute.For <IAttributeService>();
            _linkArrowService   = Substitute.For <ILinkArrowService>();

            _categoryService.AllCategories().Returns(TestData.AllCategories());
            _subCategoryService.AllSubCategories().Returns(TestData.AllSubCategories());
            _typeService.AllTypes().Returns(TestData.AllTypes());
            _attributeService.AllAttributes().Returns(TestData.AllAttributes());
            _linkArrowService.AllLinkArrows().Returns(TestData.AllLinkArrows());

            _sut = new CardCommandMapper
                   (
                _categoryService,
                _subCategoryService,
                _typeService,
                _attributeService,
                _linkArrowService
                   );
        }
Пример #4
0
        public async Task <IEnumerable <TypeOutputModel> > Handle(AllTypesQuery request, CancellationToken cancellationToken)
        {
            var types = await _typeService.AllTypes();

            return(types.MapToOutputModels());
        }