mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-27 11:44:42 +02:00
Endrer navn på java grensesnitt og kjører automatisk reformatering av objekter og objekttester
Endrer IInteractabaleGame til InteractableGame Endrer IDrawableGame til DrawableGame Endrer IDeck til Deck Endrer IGrid til Grid Endrer Grid til ListGrid Endrer Deck til AbstractDeck Endrer PowerdownContainer til PowerDownContainer Endrer GridTest til ListGridTest Kjører IntelliJ sin automatiske reformatering for å fikse formateringsfeil
This commit is contained in:
@ -29,6 +29,7 @@ import org.junit.runners.model.InitializationError;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
|
@ -11,7 +11,7 @@ public class BoardElementContainerTest {
|
||||
|
||||
@Test
|
||||
public void getObjectTest() {
|
||||
Position pos = new Position(1,2);
|
||||
Position pos = new Position(1, 2);
|
||||
Tile tile = new Tile(TileType.TILE, Direction.NORTH);
|
||||
BoardElementContainer<Tile> element = new BoardElementContainer<>(tile, pos);
|
||||
assertEquals(tile, element.getElement());
|
||||
@ -19,7 +19,7 @@ public class BoardElementContainerTest {
|
||||
|
||||
@Test
|
||||
public void getPositionTest() {
|
||||
Position pos = new Position(1,2);
|
||||
Position pos = new Position(1, 2);
|
||||
Tile tile = new Tile(TileType.TILE, Direction.NORTH);
|
||||
BoardElementContainer<Tile> element = new BoardElementContainer<>(tile, pos);
|
||||
assertEquals(pos, element.getPosition());
|
||||
|
@ -21,8 +21,6 @@ import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BoardTest {
|
||||
private Grid<Tile> tileGrid;
|
||||
private Grid<Wall> wallGrid;
|
||||
private static Position zeroPosition;
|
||||
private static Position someValidPosition1;
|
||||
private static Position someValidPosition2;
|
||||
@ -32,11 +30,13 @@ public class BoardTest {
|
||||
private static Position someValidPosition6;
|
||||
private static Position someValidPosition7;
|
||||
private static Position someValidPosition8;
|
||||
private final Map<WallType, Integer> wallTypeNumberMap = new HashMap<>();
|
||||
private final Map<TileType, Integer> tileTypeNumberMap = new HashMap<>();
|
||||
private Grid<Tile> tileGrid;
|
||||
private Grid<Wall> wallGrid;
|
||||
private List<Robot> robotList;
|
||||
private Board board;
|
||||
private Board boardWithDifferentAmountOfAllTypes;
|
||||
private final Map<WallType,Integer> wallTypeNumberMap = new HashMap<>();
|
||||
private final Map<TileType,Integer> tileTypeNumberMap = new HashMap<>();
|
||||
private List<Robot> robotListforlaser;
|
||||
private Board boardforlaser;
|
||||
private List<Robot> robotListforpowerdown;
|
||||
@ -58,30 +58,30 @@ public class BoardTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
Grid<Tile> tileGridforpowerdown = new Grid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||
Grid<Wall> wallGridforpowerdown = new Grid<>(8, 8);
|
||||
Grid<Tile> tileGridforpowerdown = new ListGrid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||
Grid<Wall> wallGridforpowerdown = new ListGrid<>(8, 8);
|
||||
robotListforpowerdown = new ArrayList<>();
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_1, new Position(2,1)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_2, new Position(4,0)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_3, new Position(4,1)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_4, new Position(1,7)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_5, new Position(0,4)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_6, new Position(0,5)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_7, new Position(7,0)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_8, new Position(1,1)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_1, new Position(2, 1)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_2, new Position(4, 0)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_3, new Position(4, 1)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_4, new Position(1, 7)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_5, new Position(0, 4)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_6, new Position(0, 5)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_7, new Position(7, 0)));
|
||||
robotListforpowerdown.add(new Robot(RobotID.ROBOT_8, new Position(1, 1)));
|
||||
boardforpowerdown = new Board(tileGridforpowerdown, wallGridforpowerdown, robotListforpowerdown);
|
||||
|
||||
Grid<Tile> tileGridforlaser = new Grid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||
Grid<Wall> wallGridforlaser = new Grid<>(8, 8);
|
||||
Grid<Tile> tileGridforlaser = new ListGrid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||
Grid<Wall> wallGridforlaser = new ListGrid<>(8, 8);
|
||||
robotListforlaser = new ArrayList<>();
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_1, new Position(2,1)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_2, new Position(4,0)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_3, new Position(4,1)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_4, new Position(1,7)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_5, new Position(0,4)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_6, new Position(0,5)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_7, new Position(7,0)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_8, new Position(1,1)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_1, new Position(2, 1)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_2, new Position(4, 0)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_3, new Position(4, 1)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_4, new Position(1, 7)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_5, new Position(0, 4)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_6, new Position(0, 5)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_7, new Position(7, 0)));
|
||||
robotListforlaser.add(new Robot(RobotID.ROBOT_8, new Position(1, 1)));
|
||||
wallGridforlaser.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||
wallGridforlaser.setElement(1, 3, new Wall(WallType.WALL_LASER_SINGLE, Direction.SOUTH));
|
||||
wallGridforlaser.setElement(7, 4, new Wall(WallType.WALL_LASER_DOUBLE, Direction.SOUTH));
|
||||
@ -92,8 +92,8 @@ public class BoardTest {
|
||||
wallGridforlaser.setElement(0, 5, new Wall(WallType.WALL_LASER_SINGLE, Direction.SOUTH));
|
||||
boardforlaser = new Board(tileGridforlaser, wallGridforlaser, robotListforlaser);
|
||||
|
||||
tileGrid = new Grid<>(5, 5, new Tile(TileType.TILE, Direction.NORTH));
|
||||
wallGrid = new Grid<>(5, 5);
|
||||
tileGrid = new ListGrid<>(5, 5, new Tile(TileType.TILE, Direction.NORTH));
|
||||
wallGrid = new ListGrid<>(5, 5);
|
||||
robotList = new ArrayList<>();
|
||||
robotList.add(new Robot(RobotID.ROBOT_1, someValidPosition1));
|
||||
robotList.add(new Robot(RobotID.ROBOT_2, someValidPosition2));
|
||||
@ -108,12 +108,12 @@ public class BoardTest {
|
||||
wallGrid.setElement(2, 1, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||
wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST));
|
||||
wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST));
|
||||
tileGrid.setElement(3,3, new Tile(TileType.FLAG_1, Direction.NORTH));
|
||||
tileGrid.setElement(2,2, new Tile(TileType.FLAG_2, Direction.NORTH));
|
||||
tileGrid.setElement(3, 3, new Tile(TileType.FLAG_1, Direction.NORTH));
|
||||
tileGrid.setElement(2, 2, new Tile(TileType.FLAG_2, Direction.NORTH));
|
||||
board = new Board(tileGrid, wallGrid, robotList);
|
||||
|
||||
Grid<Tile> tileGridAllTypes = new Grid<>(6,6);
|
||||
Grid<Wall> wallGridAllTypes = new Grid<>(6,6);
|
||||
Grid<Tile> tileGridAllTypes = new ListGrid<>(6, 6);
|
||||
Grid<Wall> wallGridAllTypes = new ListGrid<>(6, 6);
|
||||
List<Robot> emptyRobotList = new ArrayList<>();
|
||||
wallGridAllTypes.setElement(1, 1, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||
wallGridAllTypes.setElement(1, 2, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||
@ -135,32 +135,35 @@ public class BoardTest {
|
||||
tileTypeNumberMap.put(TileType.COGWHEEL_RIGHT, 4);
|
||||
tileTypeNumberMap.put(TileType.COGWHEEL_LEFT, 1);
|
||||
tileTypeNumberMap.put(TileType.TILE, 5);
|
||||
boardWithDifferentAmountOfAllTypes = new Board(tileGridAllTypes,wallGridAllTypes,emptyRobotList);
|
||||
boardWithDifferentAmountOfAllTypes = new Board(tileGridAllTypes, wallGridAllTypes, emptyRobotList);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setRobotPowerDownStatus() {
|
||||
Robot testrobot = robotListforpowerdown.get(0);
|
||||
assertEquals(false , testrobot.isInPowerDown());
|
||||
boardforpowerdown.setPowerDown(RobotID.ROBOT_1,true);
|
||||
assertEquals(true , testrobot.isInPowerDown());
|
||||
assertEquals(false, testrobot.isInPowerDown());
|
||||
boardforpowerdown.setPowerDown(RobotID.ROBOT_1, true);
|
||||
assertEquals(true, testrobot.isInPowerDown());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executRobotPowerDown() {
|
||||
Robot testrobot = robotListforpowerdown.get(1);
|
||||
boardforpowerdown.setPowerDown(RobotID.ROBOT_2,true);
|
||||
boardforpowerdown.setPowerDown(RobotID.ROBOT_2, true);
|
||||
testrobot.setDamageTaken(4);
|
||||
assertEquals(4,testrobot.getDamageTaken());
|
||||
assertEquals(4, testrobot.getDamageTaken());
|
||||
boardforpowerdown.executePowerdown();
|
||||
assertEquals(0,testrobot.getDamageTaken());
|
||||
assertEquals(0, testrobot.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repairRobotOnRepairTile() {
|
||||
Robot testrobot = robotListforpowerdown.get(2);
|
||||
testrobot.setDamageTaken(4);
|
||||
assertEquals(4,testrobot.getDamageTaken());
|
||||
assertEquals(4, testrobot.getDamageTaken());
|
||||
boardforpowerdown.repairRobotOnTile(RobotID.ROBOT_3);
|
||||
assertEquals(3,testrobot.getDamageTaken());
|
||||
assertEquals(3, testrobot.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -168,15 +171,17 @@ public class BoardTest {
|
||||
Robot testRobot = robotListforlaser.get(7);
|
||||
assertEquals(0, testRobot.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertNotEquals(0,testRobot.getDamageTaken());
|
||||
assertNotEquals(0, testRobot.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void laserBlockedByWallDoesNotDamageRobot() {
|
||||
Robot testRobot = robotListforlaser.get(0);
|
||||
assertEquals(0, testRobot.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(0,testRobot.getDamageTaken());
|
||||
assertEquals(0, testRobot.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void laserBlockedByRobotDoesNotDamageOtherRobot() {
|
||||
Robot testRobot1 = robotListforlaser.get(1);
|
||||
@ -185,16 +190,18 @@ public class BoardTest {
|
||||
assertEquals(0, testRobot1.getDamageTaken());
|
||||
assertEquals(0, testRobot2.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(0,testRobot1.getDamageTaken());
|
||||
assertNotEquals(0,testRobot2.getDamageTaken());
|
||||
assertEquals(0, testRobot1.getDamageTaken());
|
||||
assertNotEquals(0, testRobot2.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleLaserDamage() {
|
||||
Robot testRobot = robotListforlaser.get(6);
|
||||
assertEquals(0, testRobot.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(2,testRobot.getDamageTaken());
|
||||
assertEquals(2, testRobot.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void robotGetsHitByTwoLasers() {
|
||||
Robot testRobot = robotListforlaser.get(3);
|
||||
@ -202,38 +209,41 @@ public class BoardTest {
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(2, testRobot.getDamageTaken());
|
||||
}
|
||||
@Test
|
||||
public void robotDamageEachOther() {
|
||||
Robot robot5 = robotListforlaser.get(4);
|
||||
Robot robot6 = robotListforlaser.get(5);
|
||||
robot5.setFacingDirection(Direction.SOUTH);
|
||||
assertEquals(0, robot5.getDamageTaken());
|
||||
assertEquals(0, robot6.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(1, robot5.getDamageTaken());
|
||||
assertEquals(2, robot6.getDamageTaken());
|
||||
}
|
||||
@Test
|
||||
public void robotStandingOnLaserTakesDamage() {
|
||||
Robot robot6 = robotListforlaser.get(5);
|
||||
assertEquals(0, robot6.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(1, robot6.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void robotDamageEachOther() {
|
||||
Robot robot5 = robotListforlaser.get(4);
|
||||
Robot robot6 = robotListforlaser.get(5);
|
||||
robot5.setFacingDirection(Direction.SOUTH);
|
||||
assertEquals(0, robot5.getDamageTaken());
|
||||
assertEquals(0, robot6.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(1, robot5.getDamageTaken());
|
||||
assertEquals(2, robot6.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void robotStandingOnLaserTakesDamage() {
|
||||
Robot robot6 = robotListforlaser.get(5);
|
||||
assertEquals(0, robot6.getDamageTaken());
|
||||
boardforlaser.fireAllLasers();
|
||||
assertEquals(1, robot6.getDamageTaken());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flagGetsUpdatedOnRobotWithCorrectLastVisitedFlag() {
|
||||
Robot testRobot = robotList.get(6);
|
||||
assertEquals(0,testRobot.getLastFlagVisited());
|
||||
assertEquals(0, testRobot.getLastFlagVisited());
|
||||
board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_1);
|
||||
assertEquals(1,testRobot.getLastFlagVisited());
|
||||
assertEquals(1, testRobot.getLastFlagVisited());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flagDoesNotUpdatedOnRobotWithWringLastVisitedFlag() {
|
||||
Robot testRobot = robotList.get(6);
|
||||
assertEquals(0,testRobot.getLastFlagVisited());
|
||||
assertEquals(0, testRobot.getLastFlagVisited());
|
||||
board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_2);
|
||||
assertEquals(0,testRobot.getLastFlagVisited());
|
||||
assertEquals(0, testRobot.getLastFlagVisited());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -293,13 +303,13 @@ public class BoardTest {
|
||||
assertEquals(Direction.NORTH, robot.getFacingDirection());
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void gridsOfDifferentSizeThrowsError() {
|
||||
IGrid<Wall> wallGrid = new Grid<>(1, 1);
|
||||
Grid<Wall> wallGrid = new ListGrid<>(1, 1);
|
||||
new Board(tileGrid, wallGrid, robotList);
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void multipleRobotsWithSameIDThrowsError() {
|
||||
Robot robot = new Robot(RobotID.ROBOT_1, someValidPosition1);
|
||||
robotList.add(robot);
|
||||
@ -336,7 +346,7 @@ public class BoardTest {
|
||||
|
||||
@Test
|
||||
public void getPositionsOfTileOnBoardGivesCorrectAmountOfCogwheelLeftTiles() {
|
||||
assertEquals((int)tileTypeNumberMap.get(TileType.COGWHEEL_LEFT),
|
||||
assertEquals((int) tileTypeNumberMap.get(TileType.COGWHEEL_LEFT),
|
||||
boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.COGWHEEL_LEFT).size());
|
||||
}
|
||||
|
||||
@ -348,7 +358,7 @@ public class BoardTest {
|
||||
|
||||
@Test
|
||||
public void getPositionsOfTileOnBoardGivesCorrectAmountOfTileTiles() {
|
||||
assertEquals((int)tileTypeNumberMap.get(TileType.TILE),
|
||||
assertEquals((int) tileTypeNumberMap.get(TileType.TILE),
|
||||
boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.TILE).size());
|
||||
}
|
||||
|
||||
@ -360,7 +370,7 @@ public class BoardTest {
|
||||
|
||||
@Test
|
||||
public void getPositionsOfWallOnBoardGivesCorrectAmountOfWallNormalWalls() {
|
||||
assertEquals((int)wallTypeNumberMap.get(WallType.WALL_NORMAL),
|
||||
assertEquals((int) wallTypeNumberMap.get(WallType.WALL_NORMAL),
|
||||
boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_NORMAL).size());
|
||||
}
|
||||
|
||||
@ -372,7 +382,7 @@ public class BoardTest {
|
||||
|
||||
@Test
|
||||
public void getPositionsOfWallOnBoardGivesCorrectAmountOfWallCornerWalls() {
|
||||
assertEquals((int)wallTypeNumberMap.get(WallType.WALL_CORNER),
|
||||
assertEquals((int) wallTypeNumberMap.get(WallType.WALL_CORNER),
|
||||
boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_CORNER).size());
|
||||
}
|
||||
|
||||
@ -402,6 +412,7 @@ public class BoardTest {
|
||||
elemList.removeIf(pred);
|
||||
return 0 == elemList.size();
|
||||
}
|
||||
|
||||
private <K> boolean checkIfAllElementsAreOfSpecificTileType(List<BoardElementContainer<Tile>> elemList, K TileType) {
|
||||
Predicate<BoardElementContainer<Tile>> pred = (element) -> element.getElement().getTileType() == TileType;
|
||||
elemList.removeIf(pred);
|
||||
|
@ -15,16 +15,16 @@ import static org.junit.Assert.assertFalse;
|
||||
@RunWith(GdxTestRunner.class)
|
||||
public class DrawableObjectTest {
|
||||
|
||||
private static final int X_POSITION_MIN_ARG = 5;
|
||||
private static final int Y_POSITION_MIN_ARG = 8;
|
||||
private static final int X_POSITION_MAX_ARG = 6;
|
||||
private static final int Y_POSITION_MAX_ARG = 7;
|
||||
private static final Texture textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
|
||||
private static final Texture robotsTexture = new Texture(Gdx.files.internal("assets/robots.png"));
|
||||
private static final TextureRegion TEXTURE_MAX_ARG = new TextureRegion(robotsTexture, 0, 0,
|
||||
64, 64);
|
||||
private static final TextureRegion TEXTURE_MIN_ARG = new TextureRegion(textureSheet, 4 * 300, 0,
|
||||
300, 300);
|
||||
public static final TextureRegion TEXTURE_MAX_ARG = new TextureRegion(robotsTexture, 0, 0,
|
||||
64, 64);
|
||||
public static final int X_POSITION_MIN_ARG = 5;
|
||||
public static final int Y_POSITION_MIN_ARG = 8;
|
||||
public static final int X_POSITION_MAX_ARG = 6;
|
||||
public static final int Y_POSITION_MAX_ARG = 7;
|
||||
private final int WIDTH_MAX_ARG = 50;
|
||||
private final int HEIGHT_MAX_ARG = 60;
|
||||
private final int ROTATION_MAX_ARG = 90;
|
||||
|
@ -7,16 +7,16 @@ import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class GridTest {
|
||||
private Grid<Tile> grid;
|
||||
private Grid<Tile> grid2;
|
||||
public class ListGridTest {
|
||||
private ListGrid<Tile> grid;
|
||||
private ListGrid<Tile> grid2;
|
||||
private Tile defaultTile;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
defaultTile = new Tile(TileType.TILE, Direction.NORTH);
|
||||
grid = new Grid<>(7, 4);
|
||||
grid2 = new Grid<>(5,8, defaultTile);
|
||||
grid = new ListGrid<>(7, 4);
|
||||
grid2 = new ListGrid<>(5, 8, defaultTile);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -41,22 +41,22 @@ public class GridTest {
|
||||
|
||||
@Test
|
||||
public void getElementFromGrid2() {
|
||||
assertEquals(defaultTile, grid2.getElement(3,5));
|
||||
assertEquals(defaultTile, grid2.getElement(3, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setElementInGrid2() {
|
||||
Tile hole = new Tile(TileType.HOLE, Direction.NORTH);
|
||||
grid2.setElement(2,1, hole);
|
||||
assertEquals(hole, grid2.getElement(2,1));
|
||||
grid2.setElement(2, 1, hole);
|
||||
assertEquals(hole, grid2.getElement(2, 1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidPositionThrowsErrorOnGet() {
|
||||
grid.getElement(7, 4);
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidPositionThrowsErrorOnSet() {
|
||||
grid2.setElement(5, 8, null);
|
||||
}
|
@ -44,7 +44,7 @@ public class ParticleTest {
|
||||
assertNull(ParticleType.getParticleTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidParticleDirectionThrowsError() {
|
||||
new Particle(ParticleType.LASER_BEAM_DOUBLE, Direction.NORTH_EAST);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class PlayerTest {
|
||||
private Player playerTest;
|
||||
private final List<ProgrammingCard> cards = new ArrayList<>();
|
||||
private Player playerTest;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -24,7 +24,7 @@ public class PlayerTest {
|
||||
cards.add(new ProgrammingCard(30, Action.MOVE_3));
|
||||
cards.add(new ProgrammingCard(40, Action.BACK_UP));
|
||||
cards.add(new ProgrammingCard(50, Action.ROTATE_LEFT));
|
||||
playerTest = new Player(RobotID.ROBOT_1, "TestPlayer" );
|
||||
playerTest = new Player(RobotID.ROBOT_1, "TestPlayer");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -48,18 +48,18 @@ public class PlayerTest {
|
||||
assertEquals(Action.BACK_UP, playerTest.getProgram().get(3).getAction());
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetInProgramWithToManyCards() {
|
||||
cards.add(new ProgrammingCard(10,Action.ROTATE_LEFT));
|
||||
cards.add(new ProgrammingCard(10, Action.ROTATE_LEFT));
|
||||
playerTest.setInProgram(cards);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetInDeck() {
|
||||
cards.add(new ProgrammingCard(10,Action.ROTATE_LEFT));
|
||||
cards.add(new ProgrammingCard(10, Action.ROTATE_LEFT));
|
||||
ProgrammingCardDeck playerDeck = new ProgrammingCardDeck(cards);
|
||||
playerTest.setPlayerDeck(playerDeck);
|
||||
assertEquals(playerDeck , playerTest.getPlayerDeck());
|
||||
assertEquals(playerDeck, playerTest.getPlayerDeck());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -75,7 +75,7 @@ public class PlayerTest {
|
||||
@Test
|
||||
public void getProgramFromPlayer() {
|
||||
playerTest.setInProgram(cards);
|
||||
assertEquals(cards,playerTest.getProgram());
|
||||
assertEquals(cards, playerTest.getProgram());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import inf112.fiasko.roborally.elementproperties.Action;
|
||||
import inf112.fiasko.roborally.utility.DeckLoaderUtil;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -16,9 +17,9 @@ import java.util.List;
|
||||
public class ProgrammingCardDeckTest {
|
||||
private ProgrammingCard programmingCard1;
|
||||
private ProgrammingCard programmingCard3;
|
||||
private IDeck<ProgrammingCard> testDeck;
|
||||
private IDeck<ProgrammingCard> testDeck2;
|
||||
private IDeck<ProgrammingCard> fullDeck;
|
||||
private Deck<ProgrammingCard> testDeck;
|
||||
private Deck<ProgrammingCard> testDeck2;
|
||||
private Deck<ProgrammingCard> fullDeck;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -40,18 +41,18 @@ public class ProgrammingCardDeckTest {
|
||||
|
||||
@Test
|
||||
public void testSize() {
|
||||
assertEquals(3,testDeck.size());
|
||||
assertEquals(3, testDeck.size());
|
||||
testDeck.emptyInto(testDeck2);
|
||||
assertEquals(0,testDeck.size());
|
||||
assertEquals(0, testDeck.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDrawCard() {
|
||||
assertEquals(3,testDeck.size());
|
||||
assertEquals(3,testDeck2.size());
|
||||
assertEquals(3, testDeck.size());
|
||||
assertEquals(3, testDeck2.size());
|
||||
testDeck.draw(testDeck2);
|
||||
assertEquals(4,testDeck.size());
|
||||
assertEquals(2,testDeck2.size());
|
||||
assertEquals(4, testDeck.size());
|
||||
assertEquals(2, testDeck2.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,7 +1,9 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.Action;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -17,11 +19,13 @@ public class ProgrammingCardTest {
|
||||
programmingCard2 = new ProgrammingCard(234, Action.ROTATE_LEFT);
|
||||
programmingCard3 = new ProgrammingCard(2334, Action.ROTATE_LEFT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProgrammingCardAction() {
|
||||
assertEquals(Action.MOVE_1, programmingCard1.getAction());
|
||||
assertEquals(Action.ROTATE_LEFT, programmingCard2.getAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProgrammingCardValue() {
|
||||
assertEquals(5, programmingCard1.getPriority());
|
||||
|
@ -8,12 +8,12 @@ import org.junit.Test;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RoboRallyGameTest {
|
||||
private IDrawableGame game;
|
||||
private DrawableGame game;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
game = new RoboRallyGame(new ArrayList<>(),"Checkmate.txt",false, "Player1",
|
||||
null, null);
|
||||
game = new RoboRallyGame(new ArrayList<>(), "Checkmate.txt", false, "Player1",
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,6 +1,7 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.Position;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.RobotID;
|
||||
@ -8,13 +9,13 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RobotTest {
|
||||
private final int nextFlag = 1;
|
||||
private Position robotPosition;
|
||||
private Robot testRobot;
|
||||
private final int nextFlag = 1;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
robotPosition = new Position(3,6);
|
||||
robotPosition = new Position(3, 6);
|
||||
testRobot = new Robot(RobotID.ROBOT_6, robotPosition);
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ public class RobotTest {
|
||||
|
||||
@Test
|
||||
public void testRobotGetPositionOnRobotWithNewPosition() {
|
||||
Position newRobotPosition = new Position(8,12);
|
||||
Position newRobotPosition = new Position(8, 12);
|
||||
testRobot.setPosition(newRobotPosition);
|
||||
assertEquals(newRobotPosition, testRobot.getPosition());
|
||||
}
|
||||
@ -70,7 +71,7 @@ public class RobotTest {
|
||||
|
||||
@Test
|
||||
public void testRobotGetNewBackup() {
|
||||
Position nextFlagPosition = new Position(3,4);
|
||||
Position nextFlagPosition = new Position(3, 4);
|
||||
testRobot.setPosition(nextFlagPosition);
|
||||
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag);
|
||||
assertEquals(nextFlagPosition, testRobot.getBackupPosition());
|
||||
|
@ -44,7 +44,7 @@ public class TileTest {
|
||||
assertNull(TileType.getTileTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidTileDirectionThrowsError() {
|
||||
new Tile(TileType.TILE, Direction.NORTH_EAST);
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.Direction;
|
||||
import inf112.fiasko.roborally.elementproperties.WallType;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class WallTest {
|
||||
@ -11,21 +13,25 @@ public class WallTest {
|
||||
Wall testGetWall = new Wall(WallType.WALL_NORMAL, Direction.NORTH);
|
||||
assertEquals(WallType.WALL_NORMAL, testGetWall.getWallType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWallGetWallTypeCorner() {
|
||||
Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.NORTH);
|
||||
assertEquals(WallType.WALL_CORNER, testGetWall.getWallType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWallGetWallTypeLaserSingle() {
|
||||
Wall testGetWall = new Wall(WallType.WALL_LASER_SINGLE, Direction.NORTH);
|
||||
assertEquals(WallType.WALL_LASER_SINGLE, testGetWall.getWallType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWallGetDirectionNorth() {
|
||||
Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.NORTH);
|
||||
assertEquals(Direction.NORTH, testGetWall.getDirection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWallGetDirectionEast() {
|
||||
Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.EAST);
|
||||
|
Reference in New Issue
Block a user