Beispiel #1
0
        public void DealerGetsTwoCardsInTheDealRound()
        {
            //Arrange
            IBlackjackGameRound gameRound;

            //Act
            gameRound = new BlackjackGameRound(_cards, _numberOfPlayers);
            gameRound.DealCards();

            //Assert
            if (gameRound.DealersFirstPlayedCard.Value == 0 || gameRound.DealersSecondPlayedCard.Value == 0)
            {
                string errorMessage = $"Dealer should have 2 cards after the deal round, but it doesn't!";
                Assert.Fail(errorMessage);
            }
        }
        public void ScenarioFour_PlayerCardsSummedCorrectly()
        {
            //Arrange
            int         numberOfPlayers = 3;
            List <Card> cardsForRound   = CardsForScenarioFour();

            //Player one's cards : Ace of Clubs, Ace of Clubs, Spades 7 => Sum is 11 + 1 + 7 = 19
            //Player two's cards : Ace of Diamonds, Hearts 4, Ace of Hearts => Sum is 11 + 4 + 1 = 16
            //Player three's cards : Diamonds 3, Clubs 2, Diamonds 9 => Sum is 14
            //Dealers' cards : Hearts 8, Hearts 9 => Sum is 17

            //Act
            IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers);

            gameRound.DealCards();

            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand);

            gameRound.FinalizeRoundResults();

            //Assert
            if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 19)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 16)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 14)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 17)
            {
                Assert.Fail();
            }
        }
        public void ScenarioThree_PlayerCardsSummedCorrectly()
        {
            //Arrange
            int         numberOfPlayers = 3;
            List <Card> cardsForRound   = CardsForScenarioThree();

            //Player one's cards : Clubs 6, Spades 10, Hearts 5 => Sum is 21
            //Player two's cards : Diamonds 10, Jack of Hearts => Sum is 20
            //Player three's cards : Diamonds 3, Clubs 2, Diamonds 9 => Sum is 14
            //Dealers' cards : Ace of Spades, Hearts 9 => Sum is 20

            //Act
            IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers);

            gameRound.DealCards();

            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand);

            gameRound.FinalizeRoundResults();

            //Assert
            if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 21)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 20)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 14)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 20)
            {
                Assert.Fail();
            }
        }
        public void ScenarioOne_PlayerCardsSummedCorrectly()
        {
            //Arrange
            int         numberOfPlayers = 3;
            List <Card> cardsForRound   = CardsForScenarioOne();

            //Player one's cards : Hearts 7, Queens of Spades => Sum is 17
            //Player two's cards : Jack of Diamonds, Jack of Hearts => Sum is 20
            //Player three's cards : Diamonds 2, Spades 4, Diamonds 9 => Sum is 15
            //Dealers' cards : Clubs 5, Clubs 9 => Sum is 14

            //Act
            IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers);

            gameRound.DealCards();

            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand);

            gameRound.FinalizeRoundResults();

            //Assert
            if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 18)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 20)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 19)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 17)
            {
                Assert.Fail();
            }
        }
        public void ScenarioTwo_PlayerCardsSummedCorrectly()
        {
            //Arrange
            int         numberOfPlayers = 3;
            List <Card> cardsForRound   = CardsForScenarioTwo();
            //Player one's cards : Clubs 2, Spades 3, Diamonds 7  => Sum is 12
            //Player two's cards : Spades 4, Jack of Diamonds => Sum is 14
            //Player three's cards : King of Diamonds, Spades 2, Clubs 5 => Sum is 17
            //Dealers' cards : Diamonds 8, King of Spades => Sum is 18

            //Act
            IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers);

            gameRound.DealCards();

            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit);
            gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand);

            gameRound.FinalizeRoundResults();

            //Assert
            if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 12)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 14)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 17)
            {
                Assert.Fail();
            }

            if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 18)
            {
                Assert.Fail();
            }
        }
Beispiel #6
0
        public void PlayerGetsTwoCardsInTheDealRound()
        {
            //Arrange
            IBlackjackGameRound gameRound;
            int numberOfCardsPerPlayer = 2;

            //Act
            gameRound = new BlackjackGameRound(_cards, _numberOfPlayers);
            gameRound.DealCards();
            int playerOneCards   = gameRound.PlayerCards[EPlayers.Player1].Count;
            int playerTwoCards   = gameRound.PlayerCards[EPlayers.Player2].Count;
            int playerThreeCards = gameRound.PlayerCards[EPlayers.Player3].Count;

            //Assert
            if (playerOneCards != numberOfCardsPerPlayer || playerTwoCards != numberOfCardsPerPlayer || playerThreeCards != numberOfCardsPerPlayer)
            {
                string errorMessage = $"Players should have 2 cards after the deal round. Actual number of cards for Player1 : {playerTwoCards} - Player2 : {playerTwoCards} - Player3 : {playerThreeCards}";
                Assert.Fail(errorMessage);
            }
        }