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.ACE;
import static apostov.Value.QUEEN;
import static apostov.Value.SEVEN;
import static apostov.Value.TEN;
import static apostov.Value.TWO;
import static org.junit.Assert.assertEquals;

import java.util.Map;

import org.apache.commons.math3.fraction.Fraction;
import org.junit.Test;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;

public class HandResultEnumeratorTest {

	@Test
	public void test01() {
		final HolecardHand aces = new HolecardHand(new Card(ACE, CLUBS), new Card(ACE, SPADES));
		final HolecardHand trash = new HolecardHand(new Card(TWO, CLUBS), new Card(SEVEN, SPADES));
		
		displayPercentages(aces, trash);
	}

	@Test
	public void test02() {
		final HolecardHand aceTen = new HolecardHand(new Card(ACE, CLUBS), new Card(TEN, SPADES));
		final HolecardHand queenTen = new HolecardHand(new Card(QUEEN, DIAMONDS), new Card(TEN, HEARTS));
		
		displayPercentages(aceTen, queenTen);
	}

	private void displayPercentages(final HolecardHand h1, final HolecardHand h2) {
		final Map<HolecardHand, Fraction> result = new HandResultEnumerator().enumerateBoardsAndMeasureWins(ImmutableList.of(h1, h2));
		final Fraction sum = result.values().stream().reduce((x,y) -> x.add(y)).get();
		assertEquals(1, sum.intValue());
		
		System.out.println(Maps.transformValues(result, f -> String.format("%.02f%%", 100*f.doubleValue())));
	}
	
}

@@ -377,16 +377,60 @@
 Equals;%0D
+%0Aimport static org.junit.Assert.assertTrue;%0D
 %0A%0D%0Aimpor
@@ -891,38 +891,203 @@
 %0D%0A%09%09
-displayPercentages(aces, trash
+final Map%3CHolecardHand, Fraction%3E percentages = computePercentages(aces, trash);%0D%0A%09%09assertTrue(percentages.get(aces).doubleValue() %3E 0.8);%0D%0A%09%09assertTrue(percentages.get(trash).doubleValue() %3C 0.2
 );%0D%0A
@@ -1330,74 +1330,267 @@
 %0D%0A%09%09
-displayPercentages(aceTen, queenTen);%0D%0A%09%7D%0D%0A%0D%0A%09private void display
+final Map%3CHolecardHand, Fraction%3E percentages = computePercentages(aceTen, queenTen);%0D%0A%09%09assertTrue(percentages.get(aceTen).doubleValue() %3E 0.7);%0D%0A%09%09assertTrue(percentages.get(queenTen).doubleValue() %3C 0.3);%0D%0A%09%7D%0D%0A%0D%0A%09private Map%3CHolecardHand, Fraction%3E compute
 Perc
@@ -1985,9 +1985,11 @@
  100
-*
+ * 
 f.do
@@ -2001,22 +2001,40 @@
 alue())));%0D%0A
+%09%09return result;%0D%0A
 %09%7D%0D%0A%09%0D%0A%7D%0D%0A

Make a test a little more atomated, remove the need for human-eye verification