/
CoordinateParametrizedTest.java
73 lines (60 loc) · 1.99 KB
/
CoordinateParametrizedTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package ticTacToe.utils;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class CoordinateParametrizedTest {
private int OUTRow;
private int OUTColumn;
private Coordinate coordinate;
private boolean expectedInRow;
private boolean expectedInColumn;
private boolean expectedInMainDiagonal;
private Direction expectedDirection;
@Parameters(name = "({0}, {1}) con {2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ 2, 8, new Coordinate(2, 5), true, false, false, Direction.HORIZONTAL },
{ 1, 6, new Coordinate(6, 6), false, true, false, Direction.VERTICAL },
{ 3, 3, new Coordinate(6, 6), false, false, true, Direction.MAIN_DIAGONAL },
});
}
public CoordinateParametrizedTest(int OUTRow, int OUTColumn, // OUT
Coordinate coordinate, // arguments
boolean expectedInRow, boolean expectedInColumn, boolean expectedInMainDiagonal,
Direction expectedDirection) {
this.OUTRow = OUTRow;
this.OUTColumn = OUTColumn;
this.coordinate = coordinate;
this.expectedInRow = expectedInRow;
this.expectedInColumn = expectedInColumn;
this.expectedInMainDiagonal = expectedInMainDiagonal;
this.expectedDirection = expectedDirection;
}
private Coordinate OUTCoordinate;
@Before
public void before() {
OUTCoordinate = new Coordinate(OUTRow, OUTColumn);
}
@Test
public void testInRow() {
assertEquals(expectedInRow, OUTCoordinate.inRow(coordinate));
}
@Test
public void testInColumn() {
assertEquals(expectedInColumn, OUTCoordinate.inColumn(coordinate));
}
@Test
public void testInMainDiagonal() {
assertEquals(expectedInMainDiagonal, OUTCoordinate.inMainDiagonal());
}
@Test
public void testDirection() {
assertEquals(expectedDirection, OUTCoordinate.direction(coordinate));
}
}