Exemplo n.º 1
0
        public void PokerGame_Test_Tie_Breaker_Same_Hand_Type_Flush()
        {
            List <PlayingCard> testHand = new List <PlayingCard> {
                new PlayingCard(1, Suits.C), new PlayingCard(2, Suits.C), new PlayingCard(3, Suits.C), new PlayingCard(4, Suits.C), new PlayingCard(5, Suits.C)
            };
            List <PlayingCard> testHandTwo = new List <PlayingCard> {
                new PlayingCard(6, Suits.C), new PlayingCard(2, Suits.C), new PlayingCard(3, Suits.C), new PlayingCard(4, Suits.C), new PlayingCard(5, Suits.C)
            };
            Player        testWinner = new Player("W test");
            Player        testPlayer = new Player("P test");
            List <Player> players    = new List <Player>();

            players.Add(new Player("Mark"));
            players.Add(new Player("Jessie"));
            PokerGame testGame = new PokerGame(players);

            foreach (PlayingCard testCard in testHand)
            {
                testWinner.SetHand(testCard);
            }

            foreach (PlayingCard testCard in testHandTwo)
            {
                testPlayer.SetHand(testCard);
            }

            testWinner.HandName  = testGame.CheckHand(testWinner);
            testWinner.HandValue = testGame.CheckHandValue(testWinner);
            testPlayer.HandName  = testGame.CheckHand(testPlayer);
            testPlayer.HandValue = testGame.CheckHandValue(testPlayer);

            Assert.That(() => testGame.BreakTie(testWinner, testPlayer), Is.EqualTo(testWinner));
            Assert.That(() => testGame.GameWinners.Count(), Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void PokerGame_Test_CheckHand_For_One_Pair()
        {
            Hands              expectedResult = Hands.OnePair;
            List <Player>      players        = new List <Player>();
            List <PlayingCard> handTest       = new List <PlayingCard> {
                new PlayingCard(1, Suits.C), new PlayingCard(1, Suits.D), new PlayingCard(2, Suits.H), new PlayingCard(4, Suits.C), new PlayingCard(5, Suits.C)
            };
            Player mark = new Player("Mark");

            for (int i = 0; i < 5; i++)
            {
                mark.SetHand(handTest[i]);
            }

            players.Add(new Player("Jessie"));
            players.Add(new Player("Allison"));
            players.Add(new Player("Mahesh"));

            PokerGame testGame = new PokerGame(players);

            Assert.That(testGame.CheckHand(mark), Is.EqualTo(expectedResult));
        }