Ejemplo n.º 1
0
 public CardSuit(ECardSuitTypes suitType)
 {
     _suitType = suitType;
     _cardDeckConfiguration = new CardDeckConfigurationProvider().GetRules();
     _cards = new List <Card>();
     CreateSuit();
 }
Ejemplo n.º 2
0
        public void NumericalCardCanBeCreated()
        {
            //Act
            int            value        = 7;
            ECardSuitTypes cardSuitType = ECardSuitTypes.Spades;
            ECardType      cardType     = ECardType.Numerical;
            Card           testCard;

            //Arrange
            testCard = new Card(value, cardSuitType, cardType);

            //Assert
            if (testCard.Value != value)
            {
                string errorMessage = $"Card is created with the wrong value. Expected card value is {value}. Actual card value is {testCard.Value}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardSuit != cardSuitType)
            {
                string errorMessage = $"Card is created with the wrong card suit type. Expected card suit type is {cardSuitType}. Actual card suit type is {testCard.CardSuit}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardType != cardType)
            {
                string errorMessage = $"Card is created with the wrong card type. Expected card type is {cardType}. Actual card suit type is {testCard.CardType}";
                Assert.Fail(errorMessage);
            }
        }
Ejemplo n.º 3
0
        public void FaceCardQueenCanBeCreated()
        {
            //Act
            int            value        = 10;
            ECardSuitTypes cardSuitType = ECardSuitTypes.Clubs;
            ECardType      cardType     = ECardType.Queen;
            Card           testCard;

            //Arrange
            testCard = new FaceCard(cardSuitType, cardType);

            //Assert
            if (testCard.Value != value)
            {
                string errorMessage = $"Card is created with the wrong value. Expected card value is {value}. Actual card value is {testCard.Value}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardSuit != cardSuitType)
            {
                string errorMessage = $"Card is created with the wrong card suit type. Expected card suit type is {cardSuitType}. Actual card suit type is {testCard.CardSuit}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardType != cardType)
            {
                string errorMessage = $"Card is created with the wrong card type. Expected card type is {cardType}. Actual card suit type is {testCard.CardType}";
                Assert.Fail(errorMessage);
            }
        }
Ejemplo n.º 4
0
        public void FaceCardWithModifiedValueCanBeCreated()
        {
            //Act
            int            value        = 5;
            ECardSuitTypes cardSuitType = ECardSuitTypes.Diamonds;
            ECardType      cardType     = ECardType.King;
            Card           testCard;

            //Arrange
            testCard = new Card(value, cardSuitType, cardType);

            //Assert
            if (testCard.Value != value)
            {
                string errorMessage = $"Card is created with the wrong value. Expected card value is {value}. Actual card value is {testCard.Value}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardSuit != cardSuitType)
            {
                string errorMessage = $"Card is created with the wrong card suit type. Expected card suit type is {cardSuitType}. Actual card suit type is {testCard.CardSuit}";
                Assert.Fail(errorMessage);
            }

            if (testCard.CardType != cardType)
            {
                string errorMessage = $"Card is created with the wrong card type. Expected card type is {cardType}. Actual card suit type is {testCard.CardType}";
                Assert.Fail(errorMessage);
            }
        }
Ejemplo n.º 5
0
        public Card GetNumericalCard(int value, ECardSuitTypes cardSuitType)
        {
            if (value <= 10)
            {
                return(new Card(value, cardSuitType, ECardType.Numerical));
            }

            throw new ArgumentException();
        }
Ejemplo n.º 6
0
        public FaceCard(ECardSuitTypes cardSuitType, ECardType cardType) : base(10, cardSuitType, cardType)
        {
            if (cardType != ECardType.Jack && cardType != ECardType.Queen && cardType != ECardType.King)
            {
                throw new ArgumentException($@"Card type for face card must be either: 1) {ECardType.Jack} 2) {ECardType.Queen} 3) {ECardType.King}", nameof(cardType));
            }

            CardDeckConfiguration config = new CardDeckConfigurationProvider().GetRules();

            _value = config.FaceCardValue;
        }
Ejemplo n.º 7
0
        public AceCard(ECardSuitTypes cardSuitType) : base(11, cardSuitType, ECardType.Ace)
        {
            CardDeckConfiguration config = new CardDeckConfigurationProvider().GetRules();

            _value = config.DefaultAceValue;
        }
Ejemplo n.º 8
0
 public NumericalCard(int value, ECardSuitTypes cardSuitType) : base(value, cardSuitType, ECardType.Numerical)
 {
 }
Ejemplo n.º 9
0
 public Card(int value, ECardSuitTypes cardSuitType, ECardType cardType)
 {
     _value        = value;
     _cardSuitType = cardSuitType;
     _cardType     = cardType;
 }
Ejemplo n.º 10
0
 public PlayedCard(int value, ECardSuitTypes cardSuitType, ECardType cardType) : base(value, cardSuitType, cardType)
 {
 }