public void Given_An_Invalid_CardType_Validation_Should_Fail(YgoCardType cardType)
        {
            // Arrange
            var cardInputModel = new CardInputModel {
                CardType = cardType
            };

            // Act
            Action act = () => _sut.ShouldHaveValidationErrorFor(c => c.CardType, cardInputModel);

            // Assert
            act.Invoke();
        }
        public void Given_A_Monster_CardType_Should_Return_Object_Of_Type_TrapCardDto()
        {
            // Arrange
            const YgoCardType cardType = YgoCardType.Monster;

            var card = new Card {
                Id = 23424
            };

            // Act
            var result = CommandMapperHelper.MapCardByCardType(_mapper, cardType, card);

            // Assert
            result.Should().BeOfType <MonsterCardDto>();
        }
        public void Given_An_Invalid_CardType_Should_Throw_ArgumentOutOfRange_Exception()
        {
            // Arrange
            const YgoCardType cardType = (YgoCardType)7;

            var card = new Card {
                Id = 23424
            };

            // Act
            Action act = () => CommandMapperHelper.MapCardByCardType(_mapper, cardType, card);

            // Assert
            act.Should().Throw <ArgumentOutOfRangeException>();
        }
Exemple #4
0
        public static object MapCardByCardType(IMapper mapper, YgoCardType cardCardType, Card cardUpdated)
        {
            switch (cardCardType)
            {
            case YgoCardType.Monster:
                return(mapper.Map <MonsterCardDto>(cardUpdated));

            case YgoCardType.Spell:
                return(mapper.Map <SpellCardDto>(cardUpdated));

            case YgoCardType.Trap:
                return(mapper.Map <TrapCardDto>(cardUpdated));

            default:
                throw new ArgumentOutOfRangeException(nameof(cardCardType), cardCardType, null);
            }
        }
 private int SubCategoryId(IEnumerable <Category> categories, IEnumerable <SubCategory> subCategories, YgoCardType cardType, string subCategory)
 {
     return
         ((
              from sc in subCategories
              join c in categories on sc.CategoryId equals c.Id
              where c.Name.Equals(cardType.ToString(), StringComparison.OrdinalIgnoreCase) && sc.Name.Equals(subCategory, StringComparison.OrdinalIgnoreCase)
              select sc.Id
              )
          .Single());
 }
        public void Given_A_Valid_Monster_CardType_Should_Map_CardType_To_Correct_YgoCardType(string cardType, YgoCardType expected)
        {
            // Arrange
            var yugiohCard = new YugiohCard
            {
                Attribute = "Dark",
                Types     = "Effect/Ritual",
                CardType  = cardType
            };
            var cardInputModel = new CardInputModel();

            // Act
            var result = CardHelper.MapBasicCardInformation(yugiohCard, cardInputModel);

            // Assert
            result.CardType.Should().Be(expected);
        }
        public void Given_A_Valid_SpellOrTrap_CardType_Should_Map_CardType_To_Correct_YgoCardType(string cardType, YgoCardType expected)
        {
            // Arrange
            var yugiohCard = new YugiohCard
            {
                Property = "Normal",
                CardType = cardType
            };
            var cardInputModel = new CardInputModel();

            // Act
            var result = CardHelper.MapBasicCardInformation(yugiohCard, cardInputModel);

            // Assert
            result.CardType.Should().Be(expected);
        }