30 lines
1.0 KiB
Java
30 lines
1.0 KiB
Java
package ch.fritteli.maze.generator.model;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|
|
|
class MazeTest {
|
|
@Test
|
|
void testConstruct() {
|
|
// act / assert on simple cases
|
|
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new Maze(0, 0))
|
|
.withMessage("width and height must be >1");
|
|
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new Maze(0, 0, 0))
|
|
.withMessage("width and height must be >1");
|
|
|
|
// now for the real work:
|
|
// arrange
|
|
final Maze sut = new Maze(2, 3, 5);
|
|
|
|
// assert
|
|
assertThat(sut)
|
|
.returns(2, Maze::getWidth)
|
|
.returns(3, Maze::getHeight)
|
|
.returns(5L, Maze::getRandomSeed)
|
|
.returns(new Position(0, 0), Maze::getStart)
|
|
.returns(new Position(1, 2), Maze::getEnd);
|
|
}
|
|
}
|