@Before public void setUp() throws Exception { startingBoard = new HashMap<Integer, Integer>(); startingBoard.put(35, 2); boardManager = new BoardManager(); boardManager.setUpBoard(startingBoard); strategy = new CountingSquaresStrategy(boardManager, PopperStub.getSingleton()); }
@Test public final void test() throws Exception { Integer[] square = {34, 42, 43, 44, 51, 52, 53}; for (int i : square) boardManager.eliminateChoice(i, VALUE, PopperStub.getSingleton()); strategy.resolve(VALUE); for (int i = 0; i < Numbers.BOARD_SIZE; i++) { final Cell cell = boardManager.getCell(i); if (i == 33) { // check cell itself assertTrue(cell.isFilled()); assertEquals(VALUE, cell.getValue()); } else if (startingBoard.keySet().contains(i)) { assertTrue(cell.isFilled()); assertEquals(startingBoard.get(i), Integer.valueOf(cell.getValue())); } else if (Arrays.asList(square).contains(i)) { assertFalse("Cell " + i + " has value ", cell.isFilled()); assertEquals("Cell " + i, 8, cell.getPossibilities().size()); } else { assertFalse("Cell " + i + " has value ", cell.isFilled()); assertEquals("Cell " + i, 9, cell.getPossibilities().size()); } } }