/**
 * 
 */
package mathsquared.resultswizard2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

/**
 * @author MathSquared
 * 
 */
public class SweepstakesTest {

    /**
     * Test method for {@link mathsquared.resultswizard2.Sweepstakes#assignPoints(int[], int[], mathsquared.resultswizard2.TiePlaceAssignment, mathsquared.resultswizard2.SweepstakesAssignment)}.
     */
    @Test
    public void testAssignPoints () {
        fail("Not yet implemented");
    }

    /**
     * Test method for {@link mathsquared.resultswizard2.Sweepstakes#linkSweepstakes(java.lang.String[][], mathsquared.resultswizard2.Fraction[])}.
     */
    @Test
    public void testLinkSweepstakes () {
        String[][] simple = new String[][]{{"a", "b"}, {"c"}, {"d", "e", "f"}};
        String[][] repeat = new String[][]{{"a", "b", "c"}, {"b", "d"}};
        String[][] selfRepeat = new String[][]{{"a", "a"}, {"b"}};

        Fraction[] toLink = new Fraction[]{new Fraction(4), new Fraction(2), new Fraction(1)};

        Map<String, Fraction> simpleRes = new HashMap<String, Fraction>();
        simpleRes.put("a", new Fraction(4));
        simpleRes.put("b", new Fraction(4));
        simpleRes.put("c", new Fraction(2));
        simpleRes.put("d", new Fraction(1));
        simpleRes.put("e", new Fraction(1));
        simpleRes.put("f", new Fraction(1));

        Map<String, Fraction> repeatRes = new HashMap<String, Fraction>();
        repeatRes.put("a", new Fraction(4));
        repeatRes.put("b", new Fraction(6));
        repeatRes.put("c", new Fraction(4));
        repeatRes.put("d", new Fraction(2));

        Map<String, Fraction> selfRepeatRes = new HashMap<String, Fraction>();
        selfRepeatRes.put("a", new Fraction(8));
        selfRepeatRes.put("b", new Fraction(2));

        assertEquals("Simple, no dupes", Sweepstakes.linkSweepstakes(simple, toLink), simpleRes);
        assertEquals("Repeated keys", Sweepstakes.linkSweepstakes(repeat, toLink), repeatRes);
        assertEquals("Repeated keys in the same sub-array", Sweepstakes.linkSweepstakes(selfRepeat, toLink), selfRepeatRes);
    }

}

@@ -75,24 +75,29 @@
 ssert.assert
+Array
 Equals;%0Aimpo
@@ -123,20 +123,71 @@
 .Assert.
-fail
+assertEquals;%0Aimport static org.junit.Assert.assertTrue
 ;%0A%0Aimpor
@@ -592,34 +592,1404 @@
     
-fail(%22Not yet implemented%22
+int%5B%5D spec = new int%5B%5D%7B243, 81, 27, 9, 3, 1%7D; // powers of 3 (averages of 2 or 3 will be whole, and sums of two elements are distinguished from lone elements)%0A%0A        // CONDENSED LENGTH ARRAYS //%0A%0A        int%5B%5D simple = new int%5B%5D%7B1, 1, 1, 1, 1, 1%7D; // six competitors, no ties%0A        int%5B%5D overrun = new int%5B%5D%7B1, 1, 1, 1, 1, 1, 1%7D; // seven competitors, no ties%0A%0A        // RESULTS ARRAYS //%0A%0A        Fraction%5B%5D simpleRes = new Fraction%5B%5D%7Bnew Fraction(243), new Fraction(81), new Fraction(27), new Fraction(9), new Fraction(3), new Fraction(1)%7D;%0A        Fraction%5B%5D overrunRes = new Fraction%5B%5D%7Bnew Fraction(243), new Fraction(81), new Fraction(27), new Fraction(9), new Fraction(3), new Fraction(1), new Fraction(0)%7D;%0A%0A        // TEST CODE //%0A%0A        TiePlaceAssignment tpaDefault = TiePlaceAssignment.TOP; // this is tested with SweepstakesAssignment.TIE_PLACE%0A%0A        // Sanity check: SweepstakesAssignment.CUSTOM%0A        assertTrue(%22Returns null for SweepstakesAssignment.CUSTOM%22, null == Sweepstakes.assignPoints(simple, spec, tpaDefault, SweepstakesAssignment.CUSTOM));%0A%0A        // Simple cases: simple, overrun%0A        assertArrayEquals(%22Simplest case%22, Sweepstakes.assignPoints(simple, spec, tpaDefault, SweepstakesAssignment.TOP), simpleRes);%0A        assertArrayEquals(%22Overrun by 1, no ties%22, Sweepstakes.assignPoints(overrun, spec, tpaDefault, SweepstakesAssignment.TOP), overrunRes
 );%0A 

Add simple (no tie) cases for Sweepstakes test: assignPoints