Beispiel #1
0
        public void CalculateBetsTest()
        {
            Bot             testBot   = new Bot(1);
            List <Gamester> gamesters = new List <Gamester> {
                testBot
            };
            Dealer dealer = new Dealer();


            for (int i = 3; i < 30; i++)
            {
                for (int j = 3; j < 30; j++)
                {
                    GiveBotMoney(testBot);
                    for (int k = 0; k < i; k++)
                    {
                        testBot.ReceiveCard(new Card(CardSuit.Clubs, CardRank.Ace), 0);
                    }
                    for (int k = 0; k < j; k++)
                    {
                        dealer.ReceiveCard(new Card(CardSuit.Clubs, CardRank.Ace), 0);
                    }

                    dealer.CalculateBets(gamesters);

                    if (testBot.GetBet(0) != 0)
                    {
                        Assert.Fail();
                    }

                    switch (testBot.GiveResponce())
                    {
                    case 0:
                    {
                        if (j < i && i < 21)
                        {
                            Assert.Fail();
                        }
                        break;
                    }

                    case 100:
                    {
                        if (i != j)
                        {
                            Assert.Fail();
                        }
                        break;
                    }

                    case 200:
                    {
                        if ((i < j && j < 21) || i > 21)
                        {
                            Assert.Fail();
                        }
                        break;
                    }

                    default:
                    {
                        Assert.Fail();
                        break;
                    }
                    }

                    testBot.Discard();
                    dealer.Discard();
                }
            }

            testBot.Discard();
            dealer.GiveBlackJack(testBot, 0);

            for (int i = 2; i < 21; i++)
            {
                for (int k = 0; k < i; k++)
                {
                    dealer.ReceiveCard(new Card(CardSuit.Clubs, CardRank.Ace), 0);
                }
                GiveBotMoney(testBot);
                dealer.CalculateBets(gamesters);
                if ((testBot.GiveResponce() != 250 || testBot.GetBet(0) != 0) && i != 11)
                {
                    Assert.Fail();
                }
                dealer.Discard();
            }

            dealer.Discard();
            dealer.GiveBlackJack(dealer, 0);

            GiveBotMoney(testBot);

            dealer.CalculateBets(gamesters);
            if (testBot.GiveResponce() != 100 || testBot.GetBet(0) != 0)
            {
                Assert.Fail();
            }

            dealer.GetCardsBack(gamesters);
            dealer.GiveBlackJack(dealer, 0);

            for (int i = 2; i < 21; i++)
            {
                for (int k = 0; k < i; k++)
                {
                    testBot.ReceiveCard(new Card(CardSuit.Clubs, CardRank.Ace), 0);
                }
                GiveBotMoney(testBot);
                dealer.CalculateBets(gamesters);
                if (testBot.GiveResponce() != 0 || testBot.GetBet(0) != 0)
                {
                    Assert.Fail();
                }
                testBot.Discard();
            }
            Assert.Pass();
        }