Beispiel #1
0
        public void ShowTableTest()
        {
            Dealer          dealer    = new Dealer();
            List <Gamester> gamesters = new List <Gamester>(10);

            PlayerMove[,] condition = new PlayerMove[10, 4];

            Shoes shoes = new Shoes();

            shoes.Fill(8);

            for (int i = 0; i < 10; i++)
            {
                gamesters.Add(new Gamester());
            }

            Game JackBlack = new Game(gamesters);

            for (int i = 0; i < 10; i++)
            {
                dealer.InitialDistribution(gamesters, shoes, condition);
                try
                {
                    Game.ShowTable(dealer[0], gamesters);
                }
                catch (Exception)
                {
                    Assert.Fail();
                }
                dealer.GetCardsBack(gamesters);
            }

            Assert.Pass();
        }
Beispiel #2
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();
        }