Exemplo n.º 1
0
        public void HighCardRuleTest()
        {
            var rule = new HighCardRule();

            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(1, winners.Count);
            Assert.AreEqual("Player1", winners[0].Name);

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

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

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

            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 8H 7C 9D AH KC\r\nplayer2 7D 8C 9H AS KH";

            builder = new RoundBuilder(new StringReader(testcase4));
            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 testcase5 = "Player1 8H 7C 9D JH 10C\r\nPlayer2 7D 6C 5H QS 10H\r\nPlayer3 7D KC 5H QS 10H\r\nPlayer4 7D KC AH QS 10H";

            builder = new RoundBuilder(new StringReader(testcase5));
            winners = rule.Apply(builder.Build());
            Assert.IsNotNull(winners);
            Assert.AreEqual(1, winners.Count);
            Assert.AreEqual("Player4", winners[0].Name);
        }
Exemplo n.º 2
0
        public void HighCardBigTest()
        {
            var rule = new HighCardRule();

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

            Assert.AreEqual(100000, winners.Count);
        }