Exemple #1
0
        public void TestSortingTwoPair()
        {
            var hand = new PokerSharp.Hand
            {
                new Card {
                    suit = Card.Suit.Hearts, rank = 2
                },
                new Card {
                    suit = Card.Suit.Clubs, rank = 5
                },
                new Card {
                    suit = Card.Suit.Spades, rank = 2
                },
                new Card {
                    suit = Card.Suit.Clubs, rank = 3
                },
                new Card {
                    suit = Card.Suit.Diamonds, rank = 5
                }
            };

            hand.handRanking = hand.DetermineHandRankings();

            Assert.AreEqual(new List <int>
            {
                5,
                5,
                2,
                2,
                3
            }, hand.SortCardsByRanking(hand.handRanking).Select(card => card.rank));
        }
        public void TestSimpleHandsForWinner()
        {
            var player1Hand = new PokerSharp.Hand
            {
                new Card {
                    suit = Card.Suit.Clubs, rank = 5
                },
                new Card {
                    suit = Card.Suit.Diamonds, rank = 5
                },
                new Card {
                    suit = Card.Suit.Hearts, rank = 5
                },
                new Card {
                    suit = Card.Suit.Spades, rank = 5
                },
                new Card {
                    suit = Card.Suit.Clubs, rank = 4
                }
            };

            var player2Hand = new PokerSharp.Hand
            {
                new Card {
                    suit = Card.Suit.Clubs, rank = 5
                },
                new Card {
                    suit = Card.Suit.Diamonds, rank = 5
                },
                new Card {
                    suit = Card.Suit.Hearts, rank = 3
                },
                new Card {
                    suit = Card.Suit.Spades, rank = 4
                },
                new Card {
                    suit = Card.Suit.Clubs, rank = 4
                }
            };

            var winner =
                DetermineWinner.CalculateHighestHandRanking(player1Hand, player2Hand);

            Assert.AreEqual(player1Hand, winner);
        }