package org.sudoku.slave.blocks;

import java.util.Arrays;
import java.util.Collection;

import org.sudoku.elements.Square;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class SubstitutableBlockTest {

	@Parameters
	public static Collection conf() {
		int[] sizes = new int[] {3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
		int resultSize = 0;
		for(int size : sizes) {
			resultSize += size*size;
		}
		int[][] result = new int[resultSize][2];
		for(int i = 0; i < sizes.length; i++) {
			final int size = sizes[i];
			for(int j = 0; j < size; j++) {
				for(int k = 0; k < size; k++) {
					result[i][0] = j;
					result[i][1] = k;
				}
			}
		}
		return Arrays.asList(result);
	}

	private final int rowIndex;
	private final int columnIndex;

	public SubstitutableBlockTest(final int columnIndex, final int rowIndex) {
		this.columnIndex = columnIndex;
		this.rowIndex = rowIndex;
	}

	@Test
	@Ignore
	public void testBuildSubstitutableBlock() {
		fail();
		SubstitutableBlock block = new SubstitutableBlock();
		//build squares and merge into block
		assertThat(block, is(notNullValue()));
	}
}

@@ -104,25 +104,89 @@
 oku.
-elements.Square;%0A
+conf.SquareLocation;%0Aimport org.sudoku.elements.Square;%0A%0Aimport org.junit.Assert;
 %0Aimp
@@ -549,16 +549,121 @@
 ameters;
+%0Aimport static org.sudoku.TestsConstants.ELEMENTS;%0Aimport static org.sudoku.TestsConstants.CONFIGURATION;
 %0A%0A@RunWi
@@ -1413,15 +1413,334 @@
 st%0A%09
-@Ignore
+public void testNonFilledSubstitutableBlockFilled() %7B%0A%09%09SubstitutableBlock block = new SubstitutableBlock();%0A%09%09Square nonFilledCenterSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 0, 0).build();%0A%09%09block.mergeInto(nonFilledCenterSquare, SquareLocation.CENTER);%0A%09%09Assert.assertThat(block.isFilled(), is(false));%0A%09%7D%0A%0A%09@Test
 %0A%09pu
@@ -1785,18 +1785,8 @@
 ) %7B%0A
-%09%09fail();%0A
 %09%09Su
@@ -1842,44 +1842,673 @@
 ;%0A%09%09
-//build squares and merge into block
+Square centerSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 0, 0).build();%0A%09%09block.mergeInto(centerSquare, SquareLocation.CENTER);%0A%09%09Square upSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 0, 2).build();%0A%09%09block.mergeInto(upSquare, SquareLocation.UP);%0A%09%09Square downSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 0, 1).build();%0A%09%09block.mergeInto(downSquare, SquareLocation.DOWN);%0A%09%09Square leftSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 2, 0).build();%0A%09%09block.mergeInto(leftSquare, SquareLocation.LEFT);%0A%09%09Square rightSquare = new Square.Builder(CONFIGURATION, ELEMENTS, 1, 0).build();%0A%09%09block.mergeInto(rightSquare, SquareLocation.RIGHT);
 %0A%09%09a

add tests