package ruby.ninja.experiments.zahlenpuzzle.board;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import rubys.ninja.experiments.zahlenpuzzle.board.Board;
import rubys.ninja.experiments.zahlenpuzzle.board.BoardSize;
import rubys.ninja.experiments.zahlenpuzzle.token.Token;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;

public class BoardTest {
    private Board board;

    @Before
    public void setup() throws Exception {
        board = new Board(new BoardSize(4, 5));
    }

    @Test
    public void TestGetSize() throws Exception {
        assertEquals(new BoardSize(4, 5), board.getSize());
    }

    @Test
    public void TestGetToken() throws Exception {
        Token token = board.getTokenAt(new BoardSize(3, 3));
        assertNotNull(token);
    }

    @Test(expected = Exception.class)
    public void TestBounds() throws Exception {
        Token token = board.getTokenAt(new BoardSize(5, 6));
    }

    @Test
    public void TestSwapWithPos() throws Exception {
        BoardSize pos1 = new BoardSize(0, 0);
        BoardSize pos2 = new BoardSize(0, 1);

        Token oldToken1 = board.getTokenAt(pos1);
        Token oldToken2 = board.getTokenAt(pos2);

        board.swapTokens(pos1, pos2);

        Token newToken1 = board.getTokenAt(pos1);
        Token newToken2 = board.getTokenAt(pos2);

        assertSame(oldToken1, newToken2);
        assertSame(oldToken2, newToken1);
    }
}

@@ -49,33 +49,8 @@
 d;%0A%0A
-import org.junit.Assert;%0A
 impo
@@ -150,16 +150,84 @@
 .Board;%0A
+import rubys.ninja.experiments.zahlenpuzzle.board.BoardInitializer;%0A
 import r
@@ -348,185 +348,746 @@
 ort 
-static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertSame;%0A%0Apublic class BoardTest %7B%0A    private Board board;
+java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class BoardTest %7B%0A    private Board board;%0A%0A    private class MockToken implements Token %7B%0A    %7D%0A%0A    private class MockInitializer implements BoardInitializer %7B%0A        public List%3CToken%3E getTokens() %7B%0A            return new ArrayList%3CToken%3E() %7B%7B%0A               add(new MockToken());%0A               add(new MockToken());%0A               add(new MockToken());%0A               add(new MockToken());%0A            %7D%7D;%0A        %7D%0A%0A        public BoardSize getBoardSize() %7B%0A            try %7B%0A                return new BoardSize(2, 2);%0A            %7D catch (Exception ignored) %7B%0A                fail();%0A                return null;%0A            %7D%0A        %7D%0A    %7D
 %0A%0A  
@@ -1169,30 +1169,32 @@
 ard(new 
-BoardSize(4, 5
+MockInitializer(
 ));%0A    
@@ -1294,12 +1294,12 @@
 ize(
-4, 5
+2, 2
 ), b
@@ -1385,38 +1385,24 @@
 on %7B%0A       
- Token token =
  board.getTo
@@ -1425,43 +1425,13 @@
 ize(
-3, 3));%0A        assertNotNull(token
+1, 0)
 );%0A 

Update BoardTest with initializer