Deck { public PokerHand blackHand(String card1, String card2, String card3, String card4, String card5) { black = new PokerHand(card1, card2, card3, card4, card5); return black; } Deck(); Set<Card> getCards(); PokerHand whiteHand(String card1, String card2, String card3, String card4, String card5); PokerHand blackHand(String card1, String card2, String card3, String card4, String card5); PokerHand white(); PokerHand black();  }
@Test public void should_create_a_sorted_hand() { Deck deck = new Deck(); Deck.PokerHand hand = deck.blackHand("A♥", "2♠", "2♦", "2♣", "2♥"); List<Card> cards = hand.sortHandByValueAsc(); Assertions.assertThat(cards).hasSize(5); Iterator<Card> cardIterator = cards.iterator(); assertThat(cardIterator.next().toString()).isEqualTo("A♥"); assertThat(cardIterator.next().toString()).isEqualTo("2♠"); assertThat(cardIterator.next().toString()).isEqualTo("2♦"); assertThat(cardIterator.next().toString()).isEqualTo("2♣"); assertThat(cardIterator.next().toString()).isEqualTo("2♥"); }
@Test public void with_a_straight_flush() { Deck deck = new Deck(); Deck.PokerHand hand = deck.blackHand("7♦", "8♦", "9♦", "10♦", "J♦"); assertThat(hand.hasStraightFlush()).isTrue(); }
@Test public void with_an_unsorted_hand_should_recognize_straight_flush() { Deck deck = new Deck(); Deck.PokerHand hand = deck.blackHand("7♦", "J♦", "9♦", "10♦", "8♦"); assertThat(hand.hasStraightFlush()).isTrue(); }
@Test(expected = IllegalArgumentException.class) public void should_not_create_a_hand_with_less_than_5_cards() { Deck deck = new Deck(); deck.blackHand("10♣", null, null, null, null); }
@Test(expected = IllegalArgumentException.class) public void with_one_hand_should_not_distribute_the_same_card_twice() throws Exception { Deck deck = new Deck(); deck.blackHand("1♣", "2♣", "3♣", "A♣", "A♣"); }