Пример #1
0
        public void CardList_Is_Not_Flush()
        {
            var cardList = new List <Card>()
            {
                new Card()
                {
                    FaceValue = CardFaceValue.Jack, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Jack, Suit = CardSuit.Clubs
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Jack, Suit = CardSuit.Diamonds
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Eight, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Four, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.HighAce, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.HighAce, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Four, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Queen, Suit = CardSuit.Spades
                },
                new Card()
                {
                    FaceValue = CardFaceValue.King, Suit = CardSuit.Hearts
                },
                new Card()
                {
                    FaceValue = CardFaceValue.Five, Suit = CardSuit.Hearts
                }
            };

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

            Assert.IsNotNull(hand);

            Assert.AreEqual("Flush", hand.Name);
            Assert.AreEqual(700, hand.RankPrimary);
            Assert.AreEqual(14, hand.RankSecondry);
        }
Пример #2
0
        public void ParseBigRoundTest()
        {
            var rule = new FlushRule();

            var builder = new RoundBuilder(new StringReader(testcase_bigflush));
            var round   = builder.Build();

            Assert.AreEqual(100000, round.Players.Count);
        }
Пример #3
0
        public void FlushRuleBigTest()
        {
            var rule = new FlushRule();

            var builder = new RoundBuilder(new StringReader(testcase_bigflush));
            var round   = builder.Build();
            var winners = rule.Apply(round);

            Assert.AreEqual(100000, winners.Count);
        }
Пример #4
0
        public void FlushRuleTest()
        {
            var rule = new FlushRule();

            const string testcase0 = "Player1 8H ";
            var          builder   = new RoundBuilder(new StringReader(testcase0));
            var          ex        = Assert.ThrowsException <Exception>(() => builder.Build());

            Assert.AreEqual(ex.Message, "Invalid player format");

            const string testcase1 = "Player1 8H 7C 9D AH KC\r\nplayer2 7D 6C 5H QS 10H";

            builder = new RoundBuilder(new StringReader(testcase1));
            var winners = rule.Apply(builder.Build());

            Assert.IsNotNull(winners);
            Assert.AreEqual(0, winners.Count);

            const string testcase2 = "Player1 8C 7C 9C AC KH\r\nplayer2 7C 6C 5C QC 10H";

            builder = new RoundBuilder(new StringReader(testcase2));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(0, winners.Count);

            const string testcase3 = "Player1 8C 7C 9C AC KC\r\nPlayer2 7C 6C 5C QC 10H";

            builder = new RoundBuilder(new StringReader(testcase3));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player1", winners[0].Name);

            const string testcase4 = "Player1 8C 7C 9C AC KC\r\nPlayer2 7C 6C 5C QC AC";

            builder = new RoundBuilder(new StringReader(testcase4));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player1", winners[0].Name);

            const string testcase5 = "Player1 8C 7C 9C AC KC\r\nPlayer2 7C 6C 5C KC AC";

            builder = new RoundBuilder(new StringReader(testcase5));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player1", winners[0].Name);

            const string testcase6 = "Player1 8C 7C 9C QC JC\r\nPlayer2 7C 6C 5C QC KC";

            builder = new RoundBuilder(new StringReader(testcase6));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player2", winners[0].Name);

            const string testcase7 = "Player1 8C 7C 9C QC JC\r\nPlayer2 9C 8C 7C QC JC";

            builder = new RoundBuilder(new StringReader(testcase7));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(2, winners.Count);
            Assert.AreEqual("Player1", winners[0].Name);
            Assert.AreEqual("Player2", winners[1].Name);

            const string testcase8 = "Player1 8C 7C 9C QC JC\r\nPlayer2 9C 8C 7C QC JC\r\nPlayer3 9C 8C 7C QC KC";

            builder = new RoundBuilder(new StringReader(testcase8));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player3", winners[0].Name);
        }