public void OnePairRuleTest() { var rule = new OnePairRule(); 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 KH KC\r\nplayer2 7D 6C 5H KS KH"; 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 9H KC\r\nplayer2 7D 6C 9H 9S 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 9H KC\r\nPlayer2 8D 8C 9H 9S KH"; builder = new RoundBuilder(new StringReader(testcase4)); winners = rule.Apply(builder.Build()); Assert.IsNotNull(winners); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase5 = "Player1 8H 8C 9D 9H AC\r\nPlayer2 8D 8C 9H 9S KH"; 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 8C 9D 9H AC\r\nPlayer2 8D 8C 9H 9S KH\r\nPlayer3 8D 8C 9H 9S AH"; 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("Player3", winners[1].Name); }
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); }
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); }
public void OnePairBigTest() { var rule = new OnePairRule(); var builder = new RoundBuilder(new StringReader(testcase_bigonepair)); var round = builder.Build(); var winners = rule.Apply(round); Assert.AreEqual(100000, winners.Count); }
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); }
public void TestRoundBuilder() { const string testcase0 = ""; var builder = new RoundBuilder(new StringReader(testcase0)); var round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(0, round.Players.Count); const string testcase1 = "Player1 8Q"; builder = new RoundBuilder(new StringReader(testcase1)); var ex = Assert.ThrowsException <Exception>(() => builder.Build()); Assert.AreEqual(ex.Message, "Invalid card format"); const string testcase2 = "Player1 8H 7C 9D AH KC"; builder = new RoundBuilder(new StringReader(testcase2)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(1, round.Players.Count); const string testcase3 = "Player1 8H 7C 9D AH KC \r\n "; builder = new RoundBuilder(new StringReader(testcase3)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(1, round.Players.Count); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(0, round.Players.Count); const string testcase4 = "Player1 8H 7C 9D AH KC \r\n player2 7D 6C 5H QS 10H \r\n\r\n Player1 9C 10H 8C 7C 5C "; builder = new RoundBuilder(new StringReader(testcase4)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(2, round.Players.Count); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(1, round.Players.Count); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(0, round.Players.Count); const string testcase5 = "Player1 8H 7C 9D AH KC \r\n player2 7D 6C 5H QS 10H \r\n Player3 9C 10H 8C 7C"; builder = new RoundBuilder(new StringReader(testcase5)); ex = Assert.ThrowsException <Exception>(() => builder.Build()); Assert.AreEqual(ex.Message, "Invalid player format"); }
public void TestBigRound() { var builder = new RoundBuilder(new StringReader(biground)); var round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(100000, round.Players.Count); var winners = round.Play(); Assert.AreEqual(100000, winners.Count); }
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); }
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); }
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); }
public void TestRound() { const string testcase0 = ""; var builder = new RoundBuilder(new StringReader(testcase0)); var round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(0, round.Players.Count); var winners = round.Play(); Assert.AreEqual(0, winners.Count); const string testcase1 = "Player1 8C 7C 9C QC JC\r\n"; builder = new RoundBuilder(new StringReader(testcase1)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(1, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase2 = "Player1 8C 7H 9C QC JC\r\n"; builder = new RoundBuilder(new StringReader(testcase2)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(1, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase3 = "Player1 8C 7H 9C QC JC\r\nPlayer2 8C 7H 9S QC JD\r\n"; builder = new RoundBuilder(new StringReader(testcase3)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(2, round.Players.Count); winners = round.Play(); Assert.AreEqual(2, winners.Count); Assert.AreEqual("Player1", winners[0].Name); Assert.AreEqual("Player2", winners[1].Name); const string testcase4 = "Player1 8C 9H 9C 9C 9C\r\nPlayer2 8C 7H 9S 9C 9D\r\n"; builder = new RoundBuilder(new StringReader(testcase4)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(2, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase5 = "Player1 8C 9H 9C 9C 9C\r\nPlayer2 8C 10H 9S 9C 9D\r\n"; builder = new RoundBuilder(new StringReader(testcase5)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(2, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase6 = "Player1 8C 7H 9C 10C JC\r\nPlayer2 8C 7H 9S QC JD\r\n"; builder = new RoundBuilder(new StringReader(testcase6)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(2, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase7 = "Player1 8C 7H 9C 10C JC\r\nPlayer2 8C 7H 9S QC JD\r\nPlayer3 8C 7H 9S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase7)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(2, winners.Count); Assert.AreEqual("Player2", winners[0].Name); Assert.AreEqual("Player3", winners[1].Name); const string testcase8 = "Player1 7C 7H 9C 10C JC\r\nPlayer2 8C 7H 9S QC JD\r\nPlayer3 8C 7H 9S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase8)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase9 = "Player1 7C 7H 9C 10C JC\r\nPlayer2 8C 9H 9S QC JD\r\nPlayer3 8C 7H 9S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase9)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase10 = "Player1 7C 7H 9C 10C JC\r\nPlayer2 8C 9H 9S QC JD\r\nPlayer3 6C 6H 6S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase10)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player3", winners[0].Name); const string testcase11 = "Player1 7C 7H 7C 10C JC\r\nPlayer2 8C 9H 9S QC JD\r\nPlayer3 6C 6H 6S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase11)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase12 = "Player1 7C 7H 7C 10C JC\r\nPlayer2 8C 9H 9S QC JD\r\nPlayer3 7C 7H 7S QH JD\r\n"; builder = new RoundBuilder(new StringReader(testcase12)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player3", winners[0].Name); const string testcase13 = "Player1 7C 7H 7C 10C JC\r\nPlayer2 8C 9H 9S QC JD\r\nPlayer3 7C 7H 7S 7H 8D\r\n"; builder = new RoundBuilder(new StringReader(testcase13)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player1", winners[0].Name); const string testcase14 = "Player1 7C 7H 7C 10C JC\r\nPlayer2 8C 9C 9C QC JC\r\nPlayer3 7C 7H 7S 7H 8D\r\n"; builder = new RoundBuilder(new StringReader(testcase14)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase15 = "Player1 6C 7C 7C 10C JC\r\nPlayer2 8C 9C 9C QC JC\r\nPlayer3 7C 7H 7S 7H 8D\r\n"; builder = new RoundBuilder(new StringReader(testcase15)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase16 = "Player1 6C 7C 7C 10C JC\r\nPlayer2 8C 9C 9C QC JC\r\nPlayer3 7H 7H 7H 7H 8H\r\n"; builder = new RoundBuilder(new StringReader(testcase16)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(3, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player2", winners[0].Name); const string testcase17 = "Player1 6C 7C 7C 10C JC Player2 8C 9C 9C QC JC Player3 7H 7H 7H 7H 8H Player4 7H 7H 7H 7H KH Player5 7H 7H 7H 7H AC"; builder = new RoundBuilder(new StringReader(testcase17)); round = builder.Build(); Assert.IsNotNull(round); Assert.AreEqual(5, round.Players.Count); winners = round.Play(); Assert.AreEqual(1, winners.Count); Assert.AreEqual("Player4", winners[0].Name); }