Esempio n. 1
0
        public void GetCardsBackTest()
        {
            Dealer          dealer    = new Dealer();
            Gamester        gamester  = new Gamester();
            List <Gamester> gamesters = new List <Gamester>()
            {
                gamester
            };
            Deck deck = new Deck();

            for (int k = 0; k < gamesters.Count; k++)
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int i = 0; i < 50; i += 10)
                    {
                        gamester.ReceiveCard(deck[i], j);
                    }
                }
            }

            dealer.GetCardsBack(gamesters);
            for (int k = 0; k < gamesters.Count; k++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (gamesters[k][j].Count != 0)
                    {
                        Assert.Fail();
                    }
                }
            }

            Assert.Pass();
        }
Esempio n. 2
0
        public void ReceiveCardTest()
        {
            Dealer dealer = new Dealer();

            Gamester gamester = new Gamester();

            for (int j = 1; j < 5; j++)
            {
                for (int i = 1; i < 14; i++)
                {
                    Card testCard = new Card((CardSuit)j, (CardRank)i);
                    gamester.ReceiveCard(testCard, 0);
                    if (//gamester.ScanHand(0)[0].GetCardInfo()[0] != i + 1 ||
                        //gamester.ScanHand(0)[0].GetCardInfo()[1] != j + 1 ||
                        (gamester.GetSum(0) != i && i <= 10) ||
                        (gamester.GetSum(0) != 10 && i > 10) ||
                        gamester[0][0].GetCardValue() != gamester.GetSum(0))
                    {
                        Assert.Fail(i.ToString());
                    }
                    dealer.GetCardsBack(new List <Gamester> {
                        gamester
                    });
                }
            }

            Assert.Pass();
        }
Esempio n. 3
0
        public void AskTest()
        {
            Shoes  shoes  = new Shoes();
            Dealer dealer = new Dealer();

            shoes.Fill(8);
            Gamester        player      = new Gamester();
            List <Gamester> testPlayers = new List <Gamester> {
                player
            };

            PlayerMove[,] testCondition = new PlayerMove[1, 4] {
                { 0, 0, 0, 0 }
            };
            for (int j = 0; j < 3; j++)
            {
                foreach (PlayerMove move in Enum.GetValues(typeof(PlayerMove)))
                {
                    if (move == PlayerMove.Show)
                    {
                        continue;
                    }
                    testCondition[0, j] = move;
                    player.ChangeBank(1000);
                    player.ReceiveCard(new Card(CardSuit.Clubs, (CardRank)10), j);
                    for (int k = 0; k < 4; k++)
                    {
                        player.SetBet(k, (int)move * 100);
                    }

                    switch (move)
                    {
                    case PlayerMove.Pass:
                    {
                        dealer.Ask(testPlayers, shoes, testCondition);
                        if (player[j].Count != 1 ||
                            player.GetBet(j) != (int)move * 100)
                        {
                            Assert.Fail("1");
                        }
                        break;
                    }

                    case PlayerMove.Call:
                    {
                        dealer.Ask(testPlayers, shoes, testCondition);
                        if (player[j].Count != 2 ||
                            player.GetBet(j) != (int)move * 100)
                        {
                            Assert.Fail("2");
                        }
                        break;
                    }

                    case PlayerMove.Double:
                    {
                        dealer.Ask(testPlayers, shoes, testCondition);
                        if (player[j].Count != 2 ||
                            player.GetBet(j) != (int)move * 200)
                        {
                            Assert.Fail("3");
                        }

                        break;
                    }

                    case PlayerMove.Split:
                    {
                        player.ReceiveCard(new Card(CardSuit.Diamonds, (CardRank)10), j);
                        dealer.Ask(testPlayers, shoes, testCondition);
                        if (player.GetBet(j + 1) != (int)move * 100 ||
                            player[j][0] == new Card(CardSuit.Clubs, (CardRank)10) ||
                            player[j + 1][0] == new Card(CardSuit.Diamonds, (CardRank)10) ||
                            player[j].Count != player[j + 1].Count)
                        {
                            Assert.Fail("4");
                        }
                        break;
                    }

                    case PlayerMove.Surrender:
                    {
                        dealer.Ask(testPlayers, shoes, testCondition);
                        if (player[j].Count != 1 ||
                            player.GetBet(j) != 0)
                        {
                            Assert.Fail("5");
                        }
                        break;
                    }
                    }
                    dealer.GetCardsBack(testPlayers);
                }
            }
            Assert.Pass();
        }