private DieRollResult GetResult(DieRoll die) { var diceSet = new DiceRoll(FakeDiceRollFactory.GetSetOfRolls(die, 3)); var threeOfAKind = new ThreeOfAKindRule(); return(threeOfAKind.CountPoints(diceSet)); }
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); }
public void CardList_Is_Three_Of_A_Kind() { var cardList = new List <Card>() { new Card() { FaceValue = CardFaceValue.Ace, Suit = CardSuit.Clubs }, new Card() { FaceValue = CardFaceValue.Two, Suit = CardSuit.Diamonds }, new Card() { FaceValue = CardFaceValue.Jack, Suit = CardSuit.Spades }, new Card() { FaceValue = CardFaceValue.Jack, Suit = CardSuit.Diamonds }, new Card() { FaceValue = CardFaceValue.Five, Suit = CardSuit.Hearts }, new Card() { FaceValue = CardFaceValue.HighAce, Suit = CardSuit.Hearts }, new Card() { FaceValue = CardFaceValue.Ten, Suit = CardSuit.Hearts }, new Card() { FaceValue = CardFaceValue.Jack, Suit = CardSuit.Hearts }, new Card() { FaceValue = CardFaceValue.Queen, Suit = CardSuit.Hearts }, new Card() { FaceValue = CardFaceValue.King, Suit = CardSuit.Hearts } }; var rule = new ThreeOfAKindRule(); var hand = rule.BuildStrongestHand(cardList); Assert.IsNotNull(hand); Assert.AreEqual("Three of a kind", hand.Name); Assert.AreEqual(400, hand.RankPrimary); }
public void IsMatch_ThreeCardsOfSameSuitNotSameRank_IsNoMatch() { List <Card> cards = new List <Card> { new Card(CardSuit.Diamonds, CardRank.Nine), new Card(CardSuit.Diamonds, CardRank.Eight), new Card(CardSuit.Diamonds, CardRank.Seven) }; ThreeOfAKindRule rule = new ThreeOfAKindRule(); bool isMatch = rule.IsMatch(cards); Assert.AreEqual(false, isMatch); }
public void IsMatch_ThreeCardsOfSameRank_IsAMatch() { List <Card> cards = new List <Card> { new Card(CardSuit.Diamonds, CardRank.Nine), new Card(CardSuit.Clubs, CardRank.Nine), new Card(CardSuit.Spades, CardRank.Nine) }; ThreeOfAKindRule rule = new ThreeOfAKindRule(); bool isMatch = rule.IsMatch(cards); Assert.AreEqual(true, isMatch); }
public void IsMatch_HandContainsTwoSetsOfThreeSameCards_IsMatch() { List <Card> cards = new List <Card> { new Card(CardSuit.Diamonds, CardRank.Nine), new Card(CardSuit.Clubs, CardRank.Nine), new Card(CardSuit.Spades, CardRank.Nine), new Card(CardSuit.Diamonds, CardRank.Four), new Card(CardSuit.Clubs, CardRank.Four), new Card(CardSuit.Spades, CardRank.Four), }; ThreeOfAKindRule rule = new ThreeOfAKindRule(); bool isMatch = rule.IsMatch(cards); Assert.AreEqual(true, isMatch); }
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 ThreeOfAKindRuleTests() { _rule = new ThreeOfAKindRule(); }