예제 #1
0
        public void DeckOfCardsConstructorTest()
        {
            var deck = new DeckOfCards(countDecksInOne);

            Assert.IsNotNull(deck);
            Assert.IsTrue(deck.Deck.Count() == 52);

            for (int indexSuit = 0; indexSuit < 4; indexSuit++)
            {
                for (int indexName = 0; indexName < 9; indexName++)
                {
                    var numberCard = new UsualCard((CardNames)indexName, (CardSuits)indexSuit);

                    Assert.IsTrue(CheckIsCardInDeck(deck, numberCard));
                }

                for (int indexName = 9; indexName < 12; indexName++)
                {
                    var faceCard = new UsualCard((CardNames)indexName, (CardSuits)indexSuit);

                    Assert.IsTrue(CheckIsCardInDeck(deck, faceCard));
                }

                var aceCard = new AceCard((CardSuits)indexSuit);
                Assert.IsTrue(CheckIsCardInDeck(deck, aceCard));
            }
        }
예제 #2
0
        public void AceCardCanBeCreated()
        {
            //Act
            int            value        = 11;
            ECardSuitTypes cardSuitType = ECardSuitTypes.Spades;
            ECardType      cardType     = ECardType.Ace;
            Card           testCard;

            //Arrange
            testCard = new AceCard(cardSuitType);

            //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);
            }
        }
예제 #3
0
        public void DealerTakeCardTest()
        {
            var dealer = new Dealer();
            var card   = new AceCard(CardSuits.Club);

            dealer.TakeCard(card);

            Assert.AreEqual(dealer.CardsInHand[0], card);
        }
예제 #4
0
        public void AceCardTest()
        {
            for (int indexSuit = 0; indexSuit < 4; indexSuit++)
            {
                CardSuits exampleSuit = (CardSuits)indexSuit;
                var       card        = new AceCard(exampleSuit);

                Assert.IsTrue(card.CardSuit == exampleSuit && card.CardName == CardNames.Ace && card.CardNumber == 11);
            }
        }
예제 #5
0
        public void AceCardNumberChangingTest()
        {
            var listOfCards = new List <ACard>();

            listOfCards.Add(new UsualCard(CardNames.Jack, CardSuits.Diamond));
            listOfCards.Add(new UsualCard(CardNames.Jack, CardSuits.Diamond));
            var card = new AceCard(CardSuits.Heart);

            listOfCards.Add(card);
            card.CheckIsMoreThenTwentyOne(listOfCards);

            Assert.AreEqual(card.CardNumber, 1);
        }