package apostov;

import static apostov.Suit.CLUBS;
import static apostov.Suit.DIAMONDS;
import static apostov.Suit.HEARTS;
import static apostov.Suit.SPADES;
import static apostov.Value.FIVE;
import static apostov.Value.FOUR;
import static apostov.Value.KING;
import static apostov.Value.QUEEN;
import static apostov.Value.SEVEN;
import static apostov.Value.SIX;
import static com.google.common.collect.ImmutableSet.copyOf;
import static com.google.common.collect.Iterables.concat;
import static org.junit.Assert.*;
import static strength.PokerHandKind.PAIR;

import org.junit.Test;

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;

import strength.PairRanking;
import strength.PokerHandRanking;

public class ShowdownEvaluatorTest {

	@Test
	public void selectBestCombinationWithTwoKings() {
		final Card seven = new Card(SEVEN, SPADES);
		final ImmutableCollection<Card> holeCards = ImmutableSet.of(
				seven,
				new Card(KING, CLUBS));
		

		final Card queen = new Card(QUEEN, CLUBS);
		final Card six = new Card(SIX, DIAMONDS);
		final ImmutableCollection<Card> board = ImmutableSet.of(
				new Card(FIVE, CLUBS),
				new Card(KING, DIAMONDS),
				new Card(FOUR, HEARTS),
				queen,
				six);
		
		final ShowdownEvaluator evaluator = new ShowdownEvaluator();
		final PokerHandRanking handStrength = evaluator.selectBestCombination(copyOf(concat(holeCards, board)));
		assertSame(PAIR, handStrength.handKind);
		final PairRanking pairRanking = (PairRanking) handStrength;
		assertSame(KING, pairRanking.pairValue);
		assertEquals(
				ImmutableSet.of(CLUBS, DIAMONDS),
				ImmutableSet.of(pairRanking.firstSuit, pairRanking.secondSuit));
		assertEquals(queen, pairRanking.firstKicker);
		assertEquals(seven, pairRanking.secondKicker);
		assertEquals(six, pairRanking.thirdKicker);
	}
}

@@ -331,47 +331,219 @@
 lue.
-SEVEN;%0D%0Aimport static apostov.Value.SIX
+JACK;%0D%0Aimport static apostov.Value.TWO;%0D%0Aimport static apostov.Value.NINE;%0D%0Aimport static apostov.Value.SEVEN;%0D%0Aimport static apostov.Value.SIX;%0D%0Aimport static apostov.Value.TEN;%0D%0Aimport static apostov.Value.ACE
 ;%0D%0Ai
@@ -740,16 +740,65 @@
 d.PAIR;%0D
+%0Aimport static strength.PokerHandKind.HIGH_CARD;%0D
 %0A%0D%0Aimpor
@@ -919,24 +919,58 @@
 ableSet;%0D%0A%0D%0A
+import strength.HighCardRanking;%0D%0A
 import stren
@@ -1716,24 +1716,28 @@
  board)));%0D%0A
+%09%09%0D%0A
 %09%09assertSame
@@ -2151,11 +2151,1112 @@
 );%0D%0A%09%7D%0D%0A
+%09%0D%0A%09@Test%0D%0A%09public void selectBestCombinationWithNothing() %7B%0D%0A%09%09final Card jack = new Card(JACK, HEARTS);%0D%0A%09%09final Card nine = new Card(NINE, DIAMONDS);%0D%0A%09%09final ImmutableCollection%3CCard%3E holeCards = ImmutableSet.of(%0D%0A%09%09%09%09jack,%0D%0A%09%09%09%09nine);%0D%0A%09%09%0D%0A%0D%0A%09%09final Card ace = new Card(ACE, HEARTS);%0D%0A%09%09final Card queen = new Card(QUEEN, SPADES);%0D%0A%09%09final Card ten = new Card(TEN, HEARTS);%0D%0A%09%09final ImmutableCollection%3CCard%3E board = ImmutableSet.of(%0D%0A%09%09%09%09new Card(TWO, DIAMONDS),%0D%0A%09%09%09%09new Card(SIX, SPADES),%0D%0A%09%09%09%09queen,%0D%0A%09%09%09%09ten,%0D%0A%09%09%09%09ace);%0D%0A%09%09%0D%0A%09%09final ShowdownEvaluator evaluator = new ShowdownEvaluator();%0D%0A%09%09final PokerHandRanking handStrength = evaluator.selectBestCombination(copyOf(concat(holeCards, board)));%0D%0A%09%09%0D%0A%09%09assertSame(HIGH_CARD, handStrength.handKind);%0D%0A%09%09final HighCardRanking highCardRanking = (HighCardRanking) handStrength;%0D%0A%09%09assertEquals(ace, highCardRanking.highestCard);%0D%0A%09%09assertEquals(queen, highCardRanking.secondHighestCard);%0D%0A%09%09assertEquals(jack, highCardRanking.middleCard);%0D%0A%09%09assertEquals(ten, highCardRanking.fourthCard);%0D%0A%09%09assertEquals(nine, highCardRanking.bottomCard);%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Add a JUnit test for selectBestCombination, with just a high-card