Esempio n. 1
0
        public void ThreeOfAKindRuleBigTest()
        {
            var rule = new ThreeOfAKindRule();

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

            Assert.AreEqual(100000, winners.Count);
        }
Esempio n. 2
0
        public void ThreeOfAKindRuleTest()
        {
            var rule = new ThreeOfAKindRule();

            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 8H 7C 9D AH 7C\r\nplayer2 7D 6C 5H QS 6H";

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

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

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

            const string testcase4 = "Player1 8H 6C 9D 6H 6C\r\nplayer2 7D 6C 5H QS 6H";

            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 8H 6C 8D 6H 6C\r\nplayer2 7D 6C 8H 8S 6H";

            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 8H 6C 8D 6H 6C\r\nPlayer2 6D 6C 8H 8S 6H";

            builder = new RoundBuilder(new StringReader(testcase6));
            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 testcase7 = "Player1 8H 6C 8D 6H 6C\r\nPlayer2 6D 6C 9H 8S 6H";

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

            const string testcase8 = "Player1 8H 6C 8D 6H 6C\r\nPlayer2 7D 7C 8H 8S 7H";

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

            const string testcase9 = "Player1 8H 6C 8D 6H 6C\r\nPlayer2 7D 7C 8H 8S 7H\r\nPlayer3 7D 7C 8H 8S 7H";

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