public void TestOnHandWithNoCards()
        {
            var handWithNoCards = new Hand(new List<ICard>());
            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithNoCards);

            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithFourDifferentCardsOnEqualSuit()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Diamonds),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Eight, CardSuit.Diamonds)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithValidFullHouse()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Six, CardSuit.Diamonds),
                new Card(CardFace.Six, CardSuit.Hearts),
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.Ace, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithThreeEqualOnSuitOfFiveCards()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        private static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds)
            });
            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));
        }
        public void TestOnHandWithOnePair()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.King, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Diamonds),
                new Card(CardFace.Seven, CardSuit.Hearts),
                new Card(CardFace.Nine, CardSuit.Diamonds),
                new Card(CardFace.Jack, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithValidStraightFlush_3()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Jack, CardSuit.Clubs),
                new Card(CardFace.Queen, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Clubs)
            });

            var expected = true;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithValidStraightFlush_2()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Three, CardSuit.Clubs),
                new Card(CardFace.Four, CardSuit.Clubs),
                new Card(CardFace.Five, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithValidStraightFlush_1()
        {
            var handWithFiveDifferentCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Five, CardSuit.Clubs),
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Eight, CardSuit.Clubs),
                new Card(CardFace.Nine, CardSuit.Clubs)
            });

            var expected = true;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveDifferentCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithHighCard_3()
        {
            var handWithTwoEqualOfSixCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Queen, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Spades)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithTwoEqualOfSixCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithTwoEqualOfSixCardsOnEqualSuit()
        {
            var handWithTwoEqualOfSixCardsOnEqualSuit = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Eight, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithTwoEqualOfSixCardsOnEqualSuit);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithTwoEqualOfSixCardsWithDifferentFaces()
        {
            var handWithTwoEqualOfSixCards = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Eight, CardSuit.Diamonds)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithTwoEqualOfSixCards);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithFiveEqualCards()
        {
            var handWithFiveEqualCards = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithFiveEqualCards);
            Assert.AreEqual(expected, actual);
        }
        public void TestOnHandWithTwoEqualOnSuitCards()
        {
            var handWithTwoEqualCard = new Hand(new List<ICard>
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Diamonds),
                new Card(CardFace.Ten, CardSuit.Hearts),
                new Card(CardFace.Ten, CardSuit.Spades)
            });

            var expected = false;
            var actual = _pokerHandsChecker.IsFlush(handWithTwoEqualCard);
            Assert.AreEqual(expected, actual);
        }