You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.5 KiB
75 lines
2.5 KiB
import static org.assertj.core.api.Assertions.*;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
import org.junit.jupiter.params.provider.Arguments;
|
|
import org.junit.jupiter.params.provider.MethodSource;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
public class GameboardTest {
|
|
|
|
private Gameboard gb;
|
|
|
|
@BeforeEach
|
|
void setup() {
|
|
gb = new Gameboard();
|
|
}
|
|
|
|
@Test
|
|
void checkGameboardSize() {
|
|
String expectedResult = "56";
|
|
String currentResult = "" + gb.board.length;
|
|
|
|
assertThat(currentResult).describedAs("Dimensions").isEqualTo(expectedResult);
|
|
}
|
|
|
|
@Test
|
|
void checkGameboardFilled() {
|
|
int[] expectedGameboard = new int[56];
|
|
for(int i = 0; i < expectedGameboard.length; i++) {
|
|
expectedGameboard[i] = 0;
|
|
}
|
|
int [] givenGameboard = gb.board;
|
|
|
|
assertThat(givenGameboard).describedAs("Initial Gameboard").isEqualTo(expectedGameboard);
|
|
}
|
|
|
|
@ParameterizedTest
|
|
@MethodSource("FieldStream")
|
|
void checkGameboardFieldType(String testname, int Pos, int expectedResult) {
|
|
gb.initGameboard();
|
|
int currentType = gb.board[Pos];
|
|
assertThat(currentType).describedAs("Field Type").isEqualTo(expectedResult);
|
|
}
|
|
|
|
static Stream<Arguments> FieldStream () {
|
|
return Stream.of(
|
|
Arguments.of("Normal Path", 1, 0),
|
|
Arguments.of("Starting Field", 0, 1),
|
|
Arguments.of("Starting Field", 10, 1),
|
|
Arguments.of("Starting Field", 20, 1),
|
|
Arguments.of("Starting Field", 30, 1),
|
|
Arguments.of("Doorway Field", 9, 2),
|
|
Arguments.of("Doorway Field", 19, 2),
|
|
Arguments.of("Doorway Field", 29, 2),
|
|
Arguments.of("Doorway Field", 39, 2),
|
|
Arguments.of("House Field", 40, 3),
|
|
Arguments.of("House Field", 55, 3)
|
|
);
|
|
}
|
|
|
|
@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);
|
|
}
|
|
|
|
}
|