Esempio n. 1
0
        public void Test_WinnerIfOnePlayerHasFourOfAKind_ShouldFail()
        {
            IDealer            dealer         = new Poker.Table.Dealer();
            IList <ICharacter> playersOnTable = new List <ICharacter>();

            tableCards.Add(new Card(CardSuit.Clubs, CardRank.Ace));
            tableCards.Add(new Card(CardSuit.Hearts, CardRank.Ace));
            tableCards.Add(new Card(CardSuit.Hearts, CardRank.Ten));

            tableCards[0].IsVisible = true;
            tableCards[1].IsVisible = true;
            tableCards[2].IsVisible = true;

            firstPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.Ace));
            firstPlayerCards.Add(new Card(CardSuit.Spades, CardRank.Ace));

            secondPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.Three));
            secondPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.Ace));

            thirdPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            thirdPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            fourthPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            fourthPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            fifthPlayerCards.Add(new Card(CardSuit.Spades, CardRank.Ace));
            fifthPlayerCards.Add(new Card(CardSuit.Hearts, CardRank.Six));


            dealer.SetGameRules(firstPlayerCards, tableCards, firstPlayer);
            dealer.SetGameRules(secondPlayerCards, tableCards, secondPlayer);
            dealer.SetGameRules(thirdPlayerCards, tableCards, thirdPlayer);
            dealer.SetGameRules(fourthPlayerCards, tableCards, fourthPlayer);
            dealer.SetGameRules(fifthPlayerCards, tableCards, fifthPlayer);

            playersOnTable.Add(firstPlayer);
            playersOnTable.Add(secondPlayer);
            playersOnTable.Add(thirdPlayer);
            playersOnTable.Add(fourthPlayer);
            playersOnTable.Add(fifthPlayer);

            int           pot    = 1000;
            string        result = playersOnTable[1].Name + " " + playersOnTable[0].CardsCombination.Type;
            PrivateObject obj    = new PrivateObject(typeof(Poker.Table.Dealer));

            string winner = (string)(obj.Invoke("DetermineTheWinner",
                                                playersOnTable, pot));

            Assert.AreNotEqual(result, winner);
        }
        public void Test_DetermineWinnerByHightCard_TwoPlayersHasThreeOfAKind_ShouldPass()
        {
            IDealer dealer = new Poker.Table.Dealer();
            IList<ICharacter> playersOnTable = new List<ICharacter>();

            tableCards.Add(new Card(CardSuit.Spades, CardRank.Queen));
            tableCards.Add(new Card(CardSuit.Hearts, CardRank.Queen));
            tableCards.Add(new Card(CardSuit.Spades, CardRank.Ten));

            tableCards[0].IsVisible = true;
            tableCards[1].IsVisible = true;
            tableCards[2].IsVisible = true;

            firstPlayerCards.Add(new Card(CardSuit.Spades, CardRank.Ace));
            firstPlayerCards.Add(new Card(CardSuit.Spades, CardRank.Queen));

            secondPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.Three));
            secondPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.Five));

            thirdPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            thirdPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            fourthPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            fourthPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            fifthPlayerCards.Add(new Card(CardSuit.Hearts, CardRank.Six));
            fifthPlayerCards.Add(new Card(CardSuit.Hearts, CardRank.Seven));


            dealer.SetGameRules(firstPlayerCards, tableCards, firstPlayer);
            dealer.SetGameRules(secondPlayerCards, tableCards, secondPlayer);
            dealer.SetGameRules(thirdPlayerCards, tableCards, thirdPlayer);
            dealer.SetGameRules(fourthPlayerCards, tableCards, fourthPlayer);
            dealer.SetGameRules(fifthPlayerCards, tableCards, fifthPlayer);

            playersOnTable.Add(firstPlayer);
            playersOnTable.Add(secondPlayer);
            playersOnTable.Add(thirdPlayer);
            playersOnTable.Add(fourthPlayer);
            playersOnTable.Add(fifthPlayer);

            int pot = 1000;
            string result = playersOnTable[0].Name + " " + playersOnTable[0].CardsCombination.Type;
            PrivateObject obj = new PrivateObject(typeof(Poker.Table.Dealer));

            string winner = (string)(obj.Invoke("DetermineTheWinner",
                playersOnTable, pot));

            Assert.AreEqual(result, winner);
        }
Esempio n. 3
0
        public void Test_WinnerIfOnePlayerHasRoyalStraightFlush()
        {
            IDealer dealer = new Dealer();
            IList<ICharacter> playersOnTable = new List<ICharacter>();

            ICharacter firstPlayer = new Bot(new Point(0, 0), 10);
            IList<ICard> firstPlayerCards = new List<ICard>();
            IList<ICard> firstPlayerTableCards = new List<ICard>();

            firstPlayerCards.Add(new Card(CardSuit.Spades, CardRank.Ace));
            firstPlayerCards.Add(new Card(CardSuit.Spades, CardRank.King));

            firstPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Queen));
            firstPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Jack));
            firstPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Ten));

            ICharacter secondPlayer = new Bot(new Point(0, 0), 10);
            IList<ICard> secondPlayerCards = new List<ICard>();
            IList<ICard> secondPlayerTableCards = new List<ICard>();

            secondPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.Ace));
            secondPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.Ace));

            secondPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.Ace));
            secondPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Ace));
            secondPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Ten));

            ICharacter thirdPlayer = new Bot(new Point(0, 0), 10);
            IList<ICard> thirdPlayerCards = new List<ICard>();
            IList<ICard> thirdPlayerTableCards = new List<ICard>();

            thirdPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            thirdPlayerCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            thirdPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.King));
            thirdPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Queen));
            thirdPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Queen));

            ICharacter fourthPlayer = new Bot(new Point(0, 0), 10);
            IList<ICard> fourthPlayerCards = new List<ICard>();
            IList<ICard> fourthPlayerTableCards = new List<ICard>();

            fourthPlayerCards.Add(new Card(CardSuit.Clubs, CardRank.King));
            fourthPlayerTableCards.Add(new Card(CardSuit.Diamonds, CardRank.King));

            fourthPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.King));
            fourthPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Queen));
            fourthPlayerTableCards.Add(new Card(CardSuit.Spades, CardRank.Ten));

            ICharacter fifthPlayer = new Bot(new Point(0, 0), 10);
            IList<ICard> fifthPlayerCards = new List<ICard>();
            IList<ICard> fifthPlayerTableCards = new List<ICard>();

            fifthPlayerCards.Add(new Card(CardSuit.Hearts, CardRank.Six));
            fifthPlayerCards.Add(new Card(CardSuit.Hearts, CardRank.Seven));
            fifthPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.Eight));
            fifthPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.Nine));
            fifthPlayerTableCards.Add(new Card(CardSuit.Hearts, CardRank.Ten));

            dealer.SetGameRules(firstPlayerCards, firstPlayerTableCards, firstPlayer);
            dealer.SetGameRules(secondPlayerCards, secondPlayerTableCards, secondPlayer);
            dealer.SetGameRules(thirdPlayerCards, thirdPlayerTableCards, thirdPlayer);
            dealer.SetGameRules(fourthPlayerCards, fourthPlayerTableCards, fourthPlayer);
            dealer.SetGameRules(fifthPlayerCards, fifthPlayerTableCards, fifthPlayer);

            playersOnTable.Add(fifthPlayer);
            playersOnTable.Add(secondPlayer);
            playersOnTable.Add(thirdPlayer);
            playersOnTable.Add(fourthPlayer);
            playersOnTable.Add(fifthPlayer);

            int pot = 1000;
            ICharacter winner = playersOnTable[0];
            PrivateObject obj = new PrivateObject(typeof(Dealer));

            ICharacter result = (Bot)(obj.Invoke("DetermineTheWinner",
                playersOnTable, pot));

            Assert.AreNotEqual(result, winner);
        }