Beispiel #1
0
        public void Compare_WithThreeOfAKind_Success()
        {
            // arrange
            var winningPair = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Ace, Suit.Spades),
                new Card(Rank.Ace, Suit.Diamonds),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Eight, Suit.Hearts),
                new Card(Rank.Three, Suit.Clubs)
            });

            var losingPair = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Eight, Suit.Spades),
                new Card(Rank.Eight, Suit.Diamonds),
                new Card(Rank.Eight, Suit.Hearts),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Three, Suit.Clubs)
            });

            var winningKicker = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Ace, Suit.Spades),
                new Card(Rank.Ace, Suit.Diamonds),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Eight, Suit.Hearts),
                new Card(Rank.Four, Suit.Clubs)
            });

            var losingKicker = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Ace, Suit.Spades),
                new Card(Rank.Ace, Suit.Diamonds),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Eight, Suit.Hearts),
                new Card(Rank.Three, Suit.Clubs)
            });

            var testData = HandCompareTestData.GetTestData(winningPair, losingPair)
                           .Concat(HandCompareTestData.GetTestData(winningKicker, losingKicker));

            // act & assert
            foreach (var test in testData)
            {
                Assert.AreEqual(test.ExpectedResult, _comparer.Compare(test.First, test.Second));
            }
        }
        public void Compare_WithStraights_Success()
        {
            // arrange
            var winningHand = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Nine, Suit.Spades),
                new Card(Rank.Eight, Suit.Hearts),
                new Card(Rank.Seven, Suit.Diamonds),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Five, Suit.Spades)
            });

            var losingHand = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Seven, Suit.Diamonds),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Five, Suit.Spades),
                new Card(Rank.Four, Suit.Spades),
                new Card(Rank.Three, Suit.Spades),
            });

            var testData = HandCompareTestData.GetTestData(winningHand, losingHand);

            // act & assert
            AssertTestData(testData);
        }
        public void Compare_WithFlushes_Success()
        {
            // arrange
            var winningHand = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Two, Suit.Clubs),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Seven, Suit.Clubs),
                new Card(Rank.Jack, Suit.Clubs),
                new Card(Rank.King, Suit.Clubs)
            });

            var losingHand = new FiveCardPokerHand(new List <Card> {
                new Card(Rank.Two, Suit.Clubs),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Seven, Suit.Clubs),
                new Card(Rank.Jack, Suit.Clubs),
                new Card(Rank.Four, Suit.Clubs)
            });

            var testData = HandCompareTestData.GetTestData(winningHand, losingHand);

            // act & assert
            AssertTestData(testData);
        }