コード例 #1
0
        public void RoyalFlush_OneCardMissingInHand_NoMatch()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ace),
                new Card(CardSuit.Clubs, CardRank.King),
                new Card(CardSuit.Clubs, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Jack)
            };

            RoyalFlushRule rule = new RoyalFlushRule();

            bool result = rule.IsMatch(cards);

            Assert.AreEqual(false, result);
        }
コード例 #2
0
        public void RoyalFlush_AllSameSuitNotCorrectRank_NoMatch()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.King),
                new Card(CardSuit.Clubs, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Jack),
                new Card(CardSuit.Clubs, CardRank.Ten),
                new Card(CardSuit.Clubs, CardRank.Nine),
                new Card(CardSuit.Clubs, CardRank.Eight),
                new Card(CardSuit.Clubs, CardRank.Seven),
            };

            RoyalFlushRule rule = new RoyalFlushRule();

            bool result = rule.IsMatch(cards);

            Assert.AreEqual(false, result);
        }
コード例 #3
0
        public void RoyalFlush_CorrectRanksOtherSuit_NoMatch()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ace),
                new Card(CardSuit.Hearts, CardRank.King),
                new Card(CardSuit.Clubs, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Jack),
                new Card(CardSuit.Clubs, CardRank.Ten),
                new Card(CardSuit.Clubs, CardRank.Nine),
                new Card(CardSuit.Clubs, CardRank.Eight)
            };

            RoyalFlushRule rule = new RoyalFlushRule();

            bool result = rule.IsMatch(cards);

            Assert.AreEqual(false, result);
        }
コード例 #4
0
        public void RoyalFlush_IsMatch_IsAMatchWithSevenCards()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ace),
                new Card(CardSuit.Clubs, CardRank.King),
                new Card(CardSuit.Clubs, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Jack),
                new Card(CardSuit.Clubs, CardRank.Ten),
                new Card(CardSuit.Clubs, CardRank.Nine),
                new Card(CardSuit.Clubs, CardRank.Eight)
            };

            RoyalFlushRule rule = new RoyalFlushRule();

            bool result = rule.IsMatch(cards);

            Assert.AreEqual(true, result);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ace),
                new Card(CardSuit.Diamonds, CardRank.Ace),
                new Card(CardSuit.Diamonds, CardRank.Queen),
                new Card(CardSuit.Hearts, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Queen),
            };

            var royalFlushRule = new RoyalFlushRule()
                                 .SetNext(new ThreeOfAKindRule())
                                 .SetNext(new TwoPairRule())
                                 .SetNext(new HighEndRule());

            var isMatch = royalFlushRule.IsMatch(cards);

            Console.WriteLine($"This is a match with: {isMatch.Rule}");
        }
コード例 #6
0
        public void RoyalFlush_DoubleRoyalFlushWithDifferentSuit_IsAMatch()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardSuit.Clubs, CardRank.Ace),
                new Card(CardSuit.Clubs, CardRank.King),
                new Card(CardSuit.Clubs, CardRank.Queen),
                new Card(CardSuit.Clubs, CardRank.Jack),
                new Card(CardSuit.Clubs, CardRank.Ten),
                new Card(CardSuit.Diamonds, CardRank.Ace),
                new Card(CardSuit.Diamonds, CardRank.King),
                new Card(CardSuit.Diamonds, CardRank.Queen),
                new Card(CardSuit.Diamonds, CardRank.Jack),
                new Card(CardSuit.Diamonds, CardRank.Ten),
            };

            RoyalFlushRule rule = new RoyalFlushRule();

            bool result = rule.IsMatch(cards);

            Assert.AreEqual(true, result);
        }