mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Legger til tester for rotasjon av robot
This commit is contained in:
parent
963d9a515f
commit
232e28aed0
@ -11,6 +11,7 @@ import org.junit.Test;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ public class BoardTest {
|
|||||||
someValidPosition = new Position(2, 2);
|
someValidPosition = new Position(2, 2);
|
||||||
robotList = new ArrayList<>();
|
robotList = new ArrayList<>();
|
||||||
robotList.add(new Robot(RobotID.ROBOT_1, someValidPosition));
|
robotList.add(new Robot(RobotID.ROBOT_1, someValidPosition));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_2, someValidPosition));
|
||||||
wallGrid.setElement(2, 3, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
wallGrid.setElement(2, 3, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||||
wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST));
|
wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST));
|
||||||
wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST));
|
wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST));
|
||||||
@ -54,6 +56,32 @@ public class BoardTest {
|
|||||||
assertFalse(board.moveRobot(RobotID.ROBOT_1, Direction.WEST));
|
assertFalse(board.moveRobot(RobotID.ROBOT_1, Direction.WEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotCanBeRotatedLeft() {
|
||||||
|
assertEquals(Direction.NORTH, robotList.get(0).getFacingDirection());
|
||||||
|
board.rotateRobotLeft(RobotID.ROBOT_1);
|
||||||
|
assertEquals(Direction.WEST, robotList.get(0).getFacingDirection());
|
||||||
|
board.rotateRobotLeft(RobotID.ROBOT_1);
|
||||||
|
assertEquals(Direction.SOUTH, robotList.get(0).getFacingDirection());
|
||||||
|
board.rotateRobotLeft(RobotID.ROBOT_1);
|
||||||
|
assertEquals(Direction.EAST, robotList.get(0).getFacingDirection());
|
||||||
|
board.rotateRobotLeft(RobotID.ROBOT_1);
|
||||||
|
assertEquals(Direction.NORTH, robotList.get(0).getFacingDirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotCanBeRotatedRight() {
|
||||||
|
assertEquals(Direction.NORTH, robotList.get(1).getFacingDirection());
|
||||||
|
board.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
assertEquals(Direction.EAST, robotList.get(1).getFacingDirection());
|
||||||
|
board.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
assertEquals(Direction.SOUTH, robotList.get(1).getFacingDirection());
|
||||||
|
board.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
assertEquals(Direction.WEST, robotList.get(1).getFacingDirection());
|
||||||
|
board.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
assertEquals(Direction.NORTH, robotList.get(1).getFacingDirection());
|
||||||
|
}
|
||||||
|
|
||||||
@Test (expected = IllegalArgumentException.class)
|
@Test (expected = IllegalArgumentException.class)
|
||||||
public void gridsOfDifferentSizeThrowsError() {
|
public void gridsOfDifferentSizeThrowsError() {
|
||||||
IGrid<Wall> wallGrid = new Grid<>(1, 1);
|
IGrid<Wall> wallGrid = new Grid<>(1, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user