1 | package com.ociweb.emma.ex1; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import junit.framework.TestCase; |
7 | |
8 | public class PokerHandTestCase extends TestCase { |
9 | |
10 | PokerHand pokerHand = null; |
11 | List cards = null; |
12 | PokerHand.Hand result = null; |
13 | |
14 | public void setUp() { |
15 | cards = new ArrayList(); |
16 | } |
17 | |
18 | private PokerHand buildHand( int card1, int suit1, int card2, int suit2, int card3, int suit3) { |
19 | PokerHand pokerHand = null; |
20 | |
21 | cards.add( new Card(card1, suit1) ); |
22 | cards.add( new Card(card2, suit2) ); |
23 | cards.add( new Card(card3, suit3) ); |
24 | |
25 | pokerHand = new PokerHand(cards); |
26 | |
27 | return pokerHand; |
28 | } |
29 | |
30 | |
31 | // test pair |
32 | |
33 | public void testIsPair_Pair() { |
34 | pokerHand = buildHand( Card.TWO, Card.CLUBS, Card.TWO, Card.HEARTS, Card.NINE, Card.SPADES ); |
35 | PokerHand.Hand result = pokerHand.evaluate(); |
36 | assertEquals( PokerHand.Hand.PAIR, result ); |
37 | } |
38 | |
39 | // public void testIsPair_UnsortedPair() { |
40 | // pokerHand = buildHand( Card.TWO, Card.CLUBS, Card.THREE, Card.HEARTS, Card.TWO, Card.SPADES ); |
41 | // PokerHand.Hand result = pokerHand.evaluate(); |
42 | // assertEquals( PokerHand.Hand.PAIR, result ); |
43 | // } |
44 | // |
45 | // public void testIsPair_ThreeOfKind() { |
46 | // pokerHand = buildHand( Card.TWO, Card.CLUBS, Card.TWO, Card.HEARTS, Card.TWO, Card.SPADES ); |
47 | // PokerHand.Hand result = pokerHand.evaluate(); |
48 | // assertFalse( PokerHand.Hand.PAIR == result ); |
49 | // } |
50 | |
51 | } |