public void CardList_Is_Not_Straight_Flush()
        {
            var cardList = new List <Card>()
            {
                new Card()
                {
                    FaceValue = CardFaceValue.Ace, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Two, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Three, Suit = CardSuit.Clubs
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Four, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Five, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.HighAce, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Ten, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Jack, Suit = CardSuit.Diamonds
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Queen, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.King, Suit = CardSuit.Hearts
                }
            };

            var rule = new StraightFlushRule();
            var hand = rule.BuildStrongestHand(cardList);

            Assert.IsNull(hand);
        }
        public void StraightFlus_DifferentSuit_IsNoMatch()
        {
            var cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ten),
                new Card(CardSuit.Clubs, CardRank.Nine),
                new Card(CardSuit.Clubs, CardRank.Eight),
                new Card(CardSuit.Clubs, CardRank.Seven),
                new Card(CardSuit.Spades, CardRank.Six)
            };

            Rule   rule   = new StraightFlushRule().SetNext(new EmptyTestRule());
            Result result = rule.IsMatch(cards);

            Assert.IsNull(result);
        }
        public void CardList_Is_Straight_Flush()
        {
            var cardList = new List <Card>()
            {
                new Card()
                {
                    FaceValue = CardFaceValue.Ace, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Two, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Three, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Four, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Five, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.HighAce, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Ten, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Jack, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Queen, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.King, Suit = CardSuit.Hearts
                }
            };

            var rule = new StraightFlushRule();
            var hand = rule.BuildStrongestHand(cardList);

            Assert.IsNotNull(hand);
            Assert.AreEqual("Straight flush", hand.Name);
            Assert.AreEqual(900, hand.RankPrimary);
            Assert.AreEqual(60, hand.RankSecondry);

            Assert.IsTrue(hand.Cards.All(x => x.Suit == CardSuit.Hearts));
            Assert.IsTrue(hand.Cards.Any(x => x.FaceValue == CardFaceValue.Ten));
            Assert.IsTrue(hand.Cards.Any(x => x.FaceValue == CardFaceValue.Jack));
            Assert.IsTrue(hand.Cards.Any(x => x.FaceValue == CardFaceValue.Queen));
            Assert.IsTrue(hand.Cards.Any(x => x.FaceValue == CardFaceValue.King));
            Assert.IsTrue(hand.Cards.Any(x => x.FaceValue == CardFaceValue.HighAce));
        }
예제 #4
0
 public StraightFlushRuleTests()
 {
     _rule = new StraightFlushRule();
 }