public void ShouldRejectANonFlush() { IEnumerable<Card> result = new Flush().Match(new[] { Picture.King.Of(Suit.Diamonds), 2.Of(Suit.Spades), 3.Of(Suit.Spades), 4.Of(Suit.Hearts), 5.Of(Suit.Spades), 6.Of(Suit.Spades), 10.Of(Suit.Clubs) }); Assert.That(result, Is.Null, "Should not have matching cards since the flush was not detected."); }
public void ShouldDetectAFlush() { IEnumerable<Card> result = new Flush().Match(new[] { Picture.King.Of(Suit.Diamonds), 2.Of(Suit.Spades), 3.Of(Suit.Spades), 5.Of(Suit.Spades), 7.Of(Suit.Spades), 9.Of(Suit.Spades), 10.Of(Suit.Clubs) }); Assert.That(result.Count(), Is.EqualTo(5)); Assert.That(result.All( x => x.Suit == Suit.Spades), Is.True, "Should contain the flush only."); }
public void ShouldDetectTheHighestFlush() { var cards = new[] { Picture.Ace.Of(Suit.Spades), 2.Of(Suit.Spades), 3.Of(Suit.Spades), 5.Of(Suit.Spades), 7.Of(Suit.Spades), 9.Of(Suit.Spades), 10.Of(Suit.Spades) }; IEnumerable<Card> result = new Flush().Match(cards); Assert.That(result.Count(), Is.EqualTo(5)); Assert.That(result.All(x => x.Suit == Suit.Spades), Is.True, "Should contain the flush only."); Assert.That(result, Is.EquivalentTo(cards.OrderByDescending(x => x.Rank).Take(5)), "Should have picked the highest spade cards."); }
public IEnumerable<Card> TestFlushFirst(IEnumerable<Card> cards) { IEnumerable<Card> match = new Flush().Match(cards); return match != null ? new Straight().Match(cards) : null; }