|
|
@ -6,15 +6,21 @@ import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
public class GameboardTest { |
|
|
|
|
|
|
|
private Gameboard gb; |
|
|
|
private Game g; |
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
void setup() { |
|
|
|
gb = new Gameboard(); |
|
|
|
g = new Game(); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
@ -60,16 +66,68 @@ public class GameboardTest { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void checkPrintGameboard() { |
|
|
|
String expectedResult = "[1, 0, 0, 0, 0, 0, 0, 0, 0, 2, " + |
|
|
|
"1, 0, 0, 0, 0, 0, 0, 0, 0, 2, " + |
|
|
|
"1, 0, 0, 0, 0, 0, 0, 0, 0, 2, " + |
|
|
|
"1, 0, 0, 0, 0, 0, 0, 0, 0, 2, " + |
|
|
|
"3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]"; |
|
|
|
gb.initGameboard(); |
|
|
|
String calculatedResult = gb.toString(); |
|
|
|
assertThat(calculatedResult).describedAs("Print Gameboard").isEqualTo(expectedResult); |
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("FiguresOnBoardData") |
|
|
|
void checkGetFiguresOnBoard (String testname, ArrayList<Integer> positions, String[] expectedResult) { |
|
|
|
Iterator<Player> pIt = g.players.iterator(); |
|
|
|
Iterator<Integer> posIt = positions.iterator(); |
|
|
|
while(pIt.hasNext()) { |
|
|
|
Player p = pIt.next(); |
|
|
|
Iterator<Figure> figureIt = p.figures.iterator(); |
|
|
|
while (figureIt.hasNext()) { |
|
|
|
Figure f = figureIt.next(); |
|
|
|
f.setPosition(posIt.next()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String[] calculatedResult = g.gb.getFiguresOnBoard(g); |
|
|
|
assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> FiguresOnBoardData () { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of( |
|
|
|
"All Figures in Base", |
|
|
|
new ArrayList<>(Arrays.asList( |
|
|
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 |
|
|
|
)), |
|
|
|
new String[] { |
|
|
|
" "," "," "," "," "," "," "," "," "," ", |
|
|
|
" "," "," "," "," "," "," "," "," "," ", |
|
|
|
" "," "," "," "," "," "," "," "," "," ", |
|
|
|
" "," "," "," "," "," "," "," "," "," ", |
|
|
|
" "," "," "," "," "," "," "," "," "," ", |
|
|
|
" "," "," "," "," "," ","\u001b[31;1m1\u001b[0m", "\u001b[31;1m2\u001b[0m","\u001b[31;1m3\u001b[0m","\u001b[31;1m4\u001b[0m", |
|
|
|
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m","\u001b[34;1m4\u001b[0m","\u001b[33;1m1\u001b[0m","\u001b[33;1m2\u001b[0m","\u001b[33;1m3\u001b[0m","\u001b[33;1m4\u001b[0m","\u001b[32;1m1\u001b[0m","\u001b[32;1m2\u001b[0m", |
|
|
|
"\u001b[32;1m3\u001b[0m","\u001b[32;1m4\u001b[0m"} |
|
|
|
), |
|
|
|
Arguments.of( |
|
|
|
"Figures on Board", |
|
|
|
new ArrayList<>(Arrays.asList( |
|
|
|
0,1,3,5,-1,-1,-1,-1,10,12,16,-1,-1,-1,-1,-1 |
|
|
|
)), |
|
|
|
new String[] { |
|
|
|
"\u001b[31;1m1\u001b[0m","\u001b[31;1m2\u001b[0m"," ","\u001b[31;1m3\u001b[0m", |
|
|
|
" ","\u001b[31;1m4\u001b[0m"," "," ", |
|
|
|
" "," ","\u001b[33;1m1\u001b[0m"," ", |
|
|
|
"\u001b[33;1m2\u001b[0m"," "," "," ", |
|
|
|
"\u001b[33;1m3\u001b[0m"," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
" "," "," "," ", |
|
|
|
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m","\u001b[34;1m4\u001b[0m", |
|
|
|
" "," "," ","\u001b[33;1m4\u001b[0m", |
|
|
|
"\u001b[32;1m1\u001b[0m","\u001b[32;1m2\u001b[0m","\u001b[32;1m3\u001b[0m","\u001b[32;1m4\u001b[0m"} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |