public void Given_A_Valid_A_Link_Monster_YugiohCard_With_Types_Should_Map_To_SubCategoryIds_Property()
        {
            // Arrange
            var expected = new List <int> {
                2, 14
            };

            var yugiohCard = new YugiohCard
            {
                Name        = "Decode Talker",
                Description = "Amazing card!",
                CardNumber  = "01861629",
                Attribute   = "Dark",
                Types       = "Cyberse / Link / Effect",
                CardType    = "Monster",
                LinkArrows  = "	Bottom-Left, Top, Bottom-Right",
                ImageUrl    = "https://vignette.wikia.nocookie.net/yugioh/images/5/5d/DecodeTalker-YS18-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180712163921"
            };
            var monsterCategory      = TestData.AllCategories().Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase));
            var monsterSubCategories = TestData.AllSubCategories().Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id);

            // Act
            var result = MonsterCardHelper.MonsterSubCategoryIds(yugiohCard, monsterSubCategories);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
        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 Given_A_Valid_A_Link_Monster_YugiohCard_With_Types_Should_Map_To_TypeIds_Property()
        {
            // Arrange
            var expected = new List <int> {
                5
            };

            var yugiohCard = new YugiohCard
            {
                Name        = "Decode Talker",
                Description = "Amazing card!",
                CardNumber  = "01861629",
                Attribute   = "Dark",
                Types       = "Cyberse / Link / Effect",
                CardType    = "Monster",
                LinkArrows  = "	Bottom-Left, Top, Bottom-Right",
                ImageUrl    = "https://vignette.wikia.nocookie.net/yugioh/images/5/5d/DecodeTalker-YS18-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180712163921"
            };

            // Act
            var result = MonsterCardHelper.MonsterTypeIds(yugiohCard, TestData.AllTypes());

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Beispiel #4
0
        public void Given_A_Valid_A_Monster_YugiohCard_Should_Map_To_CardInputModel()
        {
            // Arrange
            var yugiohCard = new YugiohCard
            {
                Name        = "Decode Talker",
                Description = "Amazing card!",
                CardNumber  = "01861629",
                Attribute   = "Dark",
                Types       = "Cyberse / Link / Effect",
                CardType    = "Monster",
                LinkArrows  = "	Bottom-Left, Top, Bottom-Right",
                AtkDef      = "2300 / 3",
                ImageUrl    = "https://vignette.wikia.nocookie.net/yugioh/images/5/5d/DecodeTalker-YS18-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180712163921"
            };
            var cardInputModel       = new CardInputModel();
            var monsterCategory      = TestData.AllCategories().Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase));
            var monsterSubCategories = TestData.AllSubCategories().Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id);

            // Act
            var result = MonsterCardHelper.MapMonsterCard(yugiohCard, cardInputModel, TestData.AllAttributes(), monsterSubCategories, TestData.AllTypes(), TestData.AllLinkArrows());

            // Assert
            result.Should().NotBeNull();
        }
Beispiel #5
0
        public void Given_A_Valid_YugiohCard_With_A_Level_Should_Map_To_CardLevel_Property()
        {
            // Arrange
            const int expected = 8;

            var yugiohCard = new YugiohCard
            {
                Name        = "Darkness Dragon",
                Description = "Amazing card!",
                CardNumber  = "543534",
                Attribute   = "Dark",
                Types       = "Effect/Ritual/Dragon",
                CardType    = "Monster",
                Level       = 8,
                ImageUrl    = "https://vignette.wikia.nocookie.net/yugioh/images/b/b4/BlueEyesWhiteDragon-LED3-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180928161125"
            };

            var cardInputModel       = new CardInputModel();
            var monsterCategory      = TestData.AllCategories().Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase));
            var monsterSubCategories = TestData.AllSubCategories().Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id);

            // Act
            var result = MonsterCardHelper.MapMonsterCard(yugiohCard, cardInputModel, TestData.AllAttributes(), monsterSubCategories, TestData.AllTypes(), TestData.AllLinkArrows());

            // Assert
            result.CardLevel.Should().Be(expected);
        }
Beispiel #6
0
        public void Given_A_Category_That_Is_A_Monster_Card_Should_Return_True()
        {
            // Arrange
            const string category = "Monster";

            // Act
            var result = MonsterCardHelper.IsMonsterCard(category);

            // Assert
            result.Should().BeTrue();
        }
Beispiel #7
0
        public void Given_Category_That_Is_Not_A_Monster_Card_Should_Return_False()
        {
            // Arrange
            const string category = "FakeCategory";

            // Act
            var result = MonsterCardHelper.IsMonsterCard(category);

            // Assert
            result.Should().BeFalse();
        }
Beispiel #8
0
        public void Given_A_BanlistCardSearch_That_Is_Not_A_Monster_Card_Should_Return_False()
        {
            // Arrange
            var deckCardDetail = new BanlistCardSearch {
                Category = "FakeCategory"
            };

            // Act
            var result = MonsterCardHelper.IsMonsterCard(deckCardDetail);

            // Assert
            result.Should().BeFalse();
        }
        public void Given_A_DeckCardDetail_That_Is_A_Monster_Card_Should_Return_True()
        {
            // Arrange
            var deckCardDetail = new DeckCardDetail {
                Category = "Monster"
            };

            // Act
            var result = MonsterCardHelper.IsMonsterCard(deckCardDetail);

            // Assert
            result.Should().BeTrue();
        }
        public void Given_A_DeckCardDetail_Should_Map_To_Monster_Card()
        {
            // Arrange
            var cardSearch = new DeckCardDetail
            {
                CategoryId    = 23424,
                Category      = "Monster",
                SubCategories = "Normal,Fairy",
            };

            // Act
            var result = MonsterCardHelper.MapToMonsterCard(cardSearch);

            // Assert
            result.Should().NotBeNull();
        }
        public void Given_A_BanlistCardSearch_Should_Map_To_Monster_CardOutputModel()
        {
            // Arrange
            var cardSearch = new BanlistCardSearch
            {
                CategoryId    = 23424,
                Category      = "Monster",
                SubCategories = "Normal,Fairy",
            };

            // Act
            var result = MonsterCardHelper.MapToCardOutputModel(_mapper, cardSearch);

            // Assert
            result.Should().NotBeNull();
        }
Beispiel #12
0
        public void Given_A_DeckCardDetail_Should_Map_To_Monster_CardDetailOutputModel()
        {
            // Arrange
            var deckCardDetail = new DeckCardDetail
            {
                CategoryId    = 23424,
                Category      = "Monster",
                SubCategories = "Normal,Fairy"
            };

            // Act
            var result = MonsterCardHelper.MapToCardOutputModel(_mapper, deckCardDetail);

            // Assert
            result.Should().NotBeNull();
        }
        public void Given_A_BanlistCardSearch_Should_Map_To_Monster_SubCategories_To_Types_()
        {
            // Arrange
            var expected = new List <string> {
                "Monster", "Normal", "Fairy"
            };

            var deckCardDetail = new BanlistCardSearch
            {
                CategoryId    = 23424,
                Category      = "Monster",
                SubCategories = "Normal,Fairy",
            };

            // Act
            var result = MonsterCardHelper.MapToCardOutputModel(_mapper, deckCardDetail);

            // Assert
            result.Types.Should().BeEquivalentTo(expected);
        }
Beispiel #14
0
        public void Given_A_Valid_A_Monster_YugiohCard_With_An_Atk_Should_Extract_Atk_Value()
        {
            // Arrange
            const string expected = "2300";

            var yugiohCard = new YugiohCard
            {
                Name        = "Decode Talker",
                Description = "Amazing card!",
                CardNumber  = "01861629",
                Attribute   = "Dark",
                Types       = "Cyberse / Link / Effect",
                CardType    = "Monster",
                LinkArrows  = "	Bottom-Left, Top, Bottom-Right",
                AtkDef      = "2300 / 3",
                ImageUrl    = "https://vignette.wikia.nocookie.net/yugioh/images/5/5d/DecodeTalker-YS18-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180712163921"
            };

            // Act
            var result = MonsterCardHelper.Atk(yugiohCard);

            // Assert
            result.Should().Be(expected);
        }
        public void Given_A_DeckCardDetail_Should_Map_To_Monster_SubCategories_To_CardSubCategory()
        {
            // Arrange
            var expected = new List <string> {
                "Normal", "Fairy"
            };

            var deckCardDetail = new DeckCardDetail
            {
                CategoryId    = 23424,
                Category      = "Monster",
                SubCategories = "Normal,Fairy",
                AttributeId   = 43,
                Attribute     = "Light",
                TypeId        = 234,
                Type          = "Ritual"
            };

            // Act
            var result = MonsterCardHelper.MapToMonsterCard(deckCardDetail);

            // Assert
            result.CardSubCategory.Select(c => c.SubCategory.Name).Should().BeEquivalentTo(expected);
        }
Beispiel #16
0
        public void Given_A_Monster_Card_With_A_SubCategory_Should_Return_BaseType(string subCategory, string expected)
        {
            // Arrange

            var card = new Card
            {
                CardSubCategory = new List <CardSubCategory>
                {
                    new CardSubCategory
                    {
                        SubCategory = new SubCategory
                        {
                            Name = subCategory
                        }
                    }
                }
            };

            // Act
            var result = MonsterCardHelper.BaseType(card);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }