Beispiel #1
0
        public void AddShouldAdd()
        {
            var hand = new Hand();

            hand.Add(Picture.King.Of(Suit.Spades));
            hand.Add(Picture.Queen.Of(Suit.Hearts));
            hand.Add( 1.Of(Suit.Diamonds));

            Assert.That(hand.Cards.Contains(Picture.King.Of(Suit.Spades)), Is.True);
            Assert.That(hand.Cards.Contains(Picture.Queen.Of(Suit.Hearts)), Is.True);
        }
Beispiel #2
0
 public PokerHandScore Evaluate(Hand hand)
 {
     foreach (Rank rank in PatternLookup.Keys.OrderByDescending( x => x))
     {
         var match = PatternLookup[rank].Match(hand.Cards);
         if (match != null)
         {
             return new PokerHandScore(match, rank);
         }
     }
     throw new InvalidOperationException("No hand was matched!");
 }
Beispiel #3
0
        public void HandCannotContainMoreThan7Cards()
        {
            var hand = new Hand();

            hand.Add(1.Of(Suit.Clubs));
            hand.Add(2.Of(Suit.Clubs));
            hand.Add(3.Of(Suit.Clubs));
            hand.Add(4.Of(Suit.Clubs));
            hand.Add(5.Of(Suit.Clubs));
            hand.Add(6.Of(Suit.Clubs));
            hand.Add(7.Of(Suit.Clubs));

            Assert.Throws<InvalidOperationException>(() => hand.Add(10.Of(Suit.Hearts)),
                                                     "Should not be possible to have more than 7 cards in a holdem hand.");
        }