public void PokerHandDetectorShouldDetectCombination(DetectHandTestCase testCase) { var detector = new PokerHandDetector(); var hand = detector.DetectTopPokerHand(CardParser.ParseCards(testCase.Cards).ToHashSet()); Assert.AreEqual( expected: testCase.ExpectedCombinationKind, actual: hand.CardCombination.Kind); var cardCombnation = hand.CardCombination as CardCombination; CollectionAssert.AreEquivalent( expected: CardParser.ParseCards(testCase.ExpectedCombinationCards), actual: cardCombnation.Cards); var expectedKickers = CardParser.ParseCards(testCase.ExpectedKickers).ToList(); var actualKickers = hand.Kickers .OrderByDescending(k => k.Value) .ThenByDescending(k => k.Suit) // added to define ordering in test as it matters .ToList(); CollectionAssert.AreEqual( expected: expectedKickers, actual: actualKickers ); }
public void PokerHandsComparisons(CompareHandsTestCase testCase) { var detector = new PokerHandDetector(); var commonCards = CardParser.ParseCards(testCase.CommonCards); var aliceCards = CardParser.ParseCards(testCase.AliceCards); var bobCards = CardParser.ParseCards(testCase.BobCards); var aliceTopHand = detector.DetectTopPokerHand(aliceCards.Concat(commonCards).ToHashSet()); var bobTopHand = detector.DetectTopPokerHand(bobCards.Concat(commonCards).ToHashSet()); var winner = DetectWinner(aliceTopHand, bobTopHand); Assert.AreEqual(expected: testCase.ExpectedTopHandPlayer, actual: winner); }