public void TestFindBestHandFullHouse()
        {
            string[] testCardsString1 = { "8s", "8d", "13c", "12d", "8h", "12s", "12c" };
            Hand     testCards1       = ParseCards.parseCards(testCardsString1);

            Hand expectedMainHand1 = new Hand(new List <Card> {
                new Card(12, Suit.Diamonds), new Card(12, Suit.Spades), new Card(12, Suit.Clubs)
            });
            Hand expectedKickerHand1 = new Hand(new List <Card> {
                new Card(8, Suit.Spades), new Card(8, Suit.Diamonds)
            });

            SortedHand actual1 = testCards1.FindBestHand().Item1;

            string[] testCardsString2 = { "6s", "6d", "7c", "11d", "7h", "11s", "6h" };
            Hand     testCards2       = ParseCards.parseCards(testCardsString2);

            Hand expectedMainHand2 = new Hand(new List <Card> {
                new Card(6, Suit.Spades), new Card(6, Suit.Diamonds), new Card(6, Suit.Hearts)
            });
            Hand expectedKickerHand2 = new Hand(new List <Card> {
                new Card(11, Suit.Diamonds), new Card(11, Suit.Spades)
            });

            SortedHand actual2 = testCards2.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand1, actual1.MainHand), "Main hand 1 is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand1, actual1.KickerHand), "Kicker hand 1 is not as expected");

            Assert.IsTrue(Hand.IsEqual(expectedMainHand2, actual2.MainHand), "Main hand 2 is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand2, actual2.KickerHand), "Kicker hand 2 is not as expected");
        }
        public void TestFindBestHandStraight()
        {
            string[] testCardsString1 = { "10h", "14d", "8s", "11d", "7s", "9s", "12c" };
            Hand     testCards1       = ParseCards.parseCards(testCardsString1);

            Hand expectedMainHand1 = new Hand(new List <Card> {
                new Card(12, Suit.Clubs), new Card(11, Suit.Diamonds), new Card(10, Suit.Hearts), new Card(9, Suit.Spades), new Card(8, Suit.Spades)
            });
            Hand expectedKickerHand1 = null;

            SortedHand actual1 = testCards1.FindBestHand().Item1;

            string[] testCardsString2 = { "2h", "14d", "8s", "5d", "7s", "3s", "4c" };
            Hand     testCards2       = ParseCards.parseCards(testCardsString2);

            Hand expectedMainHand2 = new Hand(new List <Card> {
                new Card(5, Suit.Diamonds), new Card(4, Suit.Clubs), new Card(3, Suit.Spades), new Card(2, Suit.Hearts), new Card(1, Suit.Diamonds)
            });
            Hand expectedKickerHand2 = null;

            SortedHand actual2 = testCards2.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand1, actual1.MainHand), "Main hand is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand1, actual1.KickerHand), "Kicker hand is not as expected");

            Assert.IsTrue(Hand.IsEqual(expectedMainHand2, actual2.MainHand), "Main hand is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand2, actual2.KickerHand), "Kicker hand is not as expected");
        }
Example #3
0
        public void SortHand()
        {
            if (PlayerHand == null || PlayerHand.Count < 5)
            {
                throw new ApplicationException("Improper Handsize. Player must have 5 cards to play Poker.");
            }

            SortedHand = PlayerHand;
            SortedHand.Sort();
            SortedHand.Reverse();
        }
        public void TestFindBestHandFlush()
        {
            string[] testCardsString = { "6s", "13d", "7s", "11d", "3s", "9s", "2s" };
            Hand     testCards       = ParseCards.parseCards(testCardsString);

            Hand expectedMainHand = new Hand(new List <Card> {
                new Card(9, Suit.Spades), new Card(7, Suit.Spades), new Card(6, Suit.Spades), new Card(3, Suit.Spades), new Card(2, Suit.Spades)
            });
            Hand expectedKickerHand = null;

            SortedHand actual = testCards.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand, actual.MainHand), "Main hand is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand, actual.KickerHand), "Kicker hand is not as expected");
        }
        public void TestFindBestHandRoyalFlush()
        {
            string[] testCardsString = { "6h", "13d", "10d", "11d", "3s", "14d", "12d" };
            Hand     testCards       = ParseCards.parseCards(testCardsString);

            Hand expectedMainHand = new Hand(new List <Card> {
                new Card(14, Suit.Diamonds), new Card(13, Suit.Diamonds), new Card(12, Suit.Diamonds), new Card(11, Suit.Diamonds), new Card(10, Suit.Diamonds)
            });
            Hand expectedKickerHand = null;

            SortedHand actual = testCards.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand, actual.MainHand), "Main hand is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand, actual.KickerHand), "Kicker hand is not as expected");
        }
        public void TestFindBestHandFour()
        {
            string[] testCardsString = { "4c", "13d", "4d", "11h", "11d", "4s", "4h" };
            Hand     testCards       = ParseCards.parseCards(testCardsString);

            Hand expectedMainHand = new Hand(new List <Card> {
                new Card(4, Suit.Clubs), new Card(4, Suit.Diamonds), new Card(4, Suit.Spades), new Card(4, Suit.Hearts)
            });
            Hand expectedKickerHand = new Hand(new List <Card> {
                new Card(13, Suit.Diamonds)
            });

            SortedHand actual = testCards.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand, actual.MainHand), "Main hand is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand, actual.KickerHand), "Kicker hand is not as expected");
        }
        public void TestFindBestHandHighCard()
        {
            string[] testCardsString = { "4s", "5d", "13c", "2d", "6h", "12s", "8c" };
            Hand     testCards       = ParseCards.parseCards(testCardsString);

            Hand expectedMainHand = new Hand(new List <Card> {
                new Card(13, Suit.Clubs)
            });
            Hand expectedKickerHand = new Hand(new List <Card> {
                new Card(12, Suit.Spades), new Card(8, Suit.Clubs), new Card(6, Suit.Hearts), new Card(5, Suit.Diamonds)
            });

            SortedHand actual = testCards.FindBestHand().Item1;

            Assert.IsTrue(Hand.IsEqual(expectedMainHand, actual.MainHand), "Main hand 1 is not as expected");
            Assert.IsTrue(Hand.IsEqual(expectedKickerHand, actual.KickerHand), "Kicker hand 1 is not as expected");
        }