66 lines
1.6 KiB
Java
66 lines
1.6 KiB
Java
package uebung06.test.sudoku;
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
import sudoku.*;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertNull;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
public class FieldTest {
|
|
private static final int X = 8;
|
|
private static final int Y = 5;
|
|
private static final int NUL = -1;
|
|
private static final Value VAL = Value.EIGHT;
|
|
private static Sudoku sudoku;
|
|
private static Field field;
|
|
|
|
@Before
|
|
public void init() {
|
|
sudoku = new Sudoku();
|
|
field = new Field(sudoku, X, Y);
|
|
}
|
|
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void illegalXLowerBoundFieldTest() {
|
|
field = new Field(sudoku, NUL, Y);
|
|
}
|
|
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void illegalXUpperBoundFieldTest() {
|
|
field = new Field(sudoku, Sudoku.SIZE, Y);
|
|
}
|
|
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void illegalYLowerBoundFieldTest() {
|
|
field = new Field(sudoku, X, NUL);
|
|
}
|
|
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void illegalYUpperBoundFieldTest() {
|
|
field = new Field(sudoku, X, Sudoku.SIZE);
|
|
}
|
|
|
|
@Test
|
|
public void valueFieldTest() {
|
|
field.setValue(VAL);
|
|
assertEquals(field.getValue(), VAL);
|
|
}
|
|
|
|
@Test
|
|
public void clearValueFieldTest() {
|
|
field.setValue(VAL);
|
|
field.clearValue();
|
|
assertNull(field.getValue());
|
|
}
|
|
|
|
@Test
|
|
public void isValueEmptyFieldTest() {
|
|
field.setValue(VAL);
|
|
field.clearValue();
|
|
assertTrue(field.isEmpty());
|
|
}
|
|
}
|