mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-30 19:55:27 +02:00
Flytter ting til korrekte pakker og forbedrer Tile og Wall
Fikser kommentarer, mellomrom og variabelnavn i Tile og Wall Flytter IGrid, Robot og Wall til objects Flytter tester til korresponderende pakker
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.objects.DrawableObject;
|
||||
import inf112.fiasko.roborally.element_properties.GameTexture;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class DrawableObjectTest {
|
||||
|
||||
public static final GameTexture TEXTURE_MIN_ARG = GameTexture.TILE;
|
||||
public static final GameTexture TEXTURE_MAX_ARG = GameTexture.ROBOT;
|
||||
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;
|
||||
private final boolean FLIP_X_MAX_ARG = true;
|
||||
private final boolean FLIP_Y_MAX_ARG = true;
|
||||
private DrawableObject drawableObjectMinimumArguments;
|
||||
private DrawableObject drawableObjectMaximumArguments;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
drawableObjectMinimumArguments = new DrawableObject(TEXTURE_MIN_ARG, X_POSITION_MIN_ARG, Y_POSITION_MIN_ARG);
|
||||
drawableObjectMaximumArguments = new DrawableObject(TEXTURE_MAX_ARG, X_POSITION_MAX_ARG, Y_POSITION_MAX_ARG,
|
||||
WIDTH_MAX_ARG, HEIGHT_MAX_ARG, ROTATION_MAX_ARG, FLIP_X_MAX_ARG, FLIP_Y_MAX_ARG);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTextureMinArg() {
|
||||
assertSame(TEXTURE_MIN_ARG, drawableObjectMinimumArguments.getTexture());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTextureMaxArg() {
|
||||
assertSame(TEXTURE_MAX_ARG, drawableObjectMaximumArguments.getTexture());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getXPositionMinArg() {
|
||||
assertEquals(X_POSITION_MIN_ARG, drawableObjectMinimumArguments.getXPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getXPositionMaxArg() {
|
||||
assertEquals(X_POSITION_MAX_ARG, drawableObjectMaximumArguments.getXPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getYPositionMinArg() {
|
||||
assertEquals(Y_POSITION_MIN_ARG, drawableObjectMinimumArguments.getYPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getYPositionMaxArg() {
|
||||
assertEquals(Y_POSITION_MAX_ARG, drawableObjectMaximumArguments.getYPosition());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getWidthMinArg() {
|
||||
assertEquals(64, drawableObjectMinimumArguments.getWidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWidthMaxArg() {
|
||||
assertEquals(WIDTH_MAX_ARG, drawableObjectMaximumArguments.getWidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeightMinArg() {
|
||||
assertEquals(64, drawableObjectMinimumArguments.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeightMaxArg() {
|
||||
assertEquals(HEIGHT_MAX_ARG, drawableObjectMaximumArguments.getHeight());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getRotationMinArg() {
|
||||
assertEquals(0, drawableObjectMinimumArguments.getRotation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRotationMaxArg() {
|
||||
assertEquals(ROTATION_MAX_ARG, drawableObjectMaximumArguments.getRotation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flipXMinArg() {
|
||||
assertFalse(drawableObjectMinimumArguments.flipX());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flipXMaxArg() {
|
||||
assertEquals(FLIP_X_MAX_ARG, drawableObjectMaximumArguments.flipX());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flipYMinArg() {
|
||||
assertFalse(drawableObjectMinimumArguments.flipY());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flipYMaxArg() {
|
||||
assertEquals(FLIP_Y_MAX_ARG, drawableObjectMaximumArguments.flipY());
|
||||
}
|
||||
}
|
22
src/test/java/inf112/fiasko/roborally/objects/RobotTest.java
Normal file
22
src/test/java/inf112/fiasko/roborally/objects/RobotTest.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Position;
|
||||
import inf112.fiasko.roborally.objects.Robot;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RobotTest {
|
||||
@Test
|
||||
public void testRobotGetDamageOnInitializedRobot(){
|
||||
Position robotPosition = new Position(3,6);
|
||||
Robot testRobotGetDamage = new Robot(6, robotPosition);
|
||||
assertEquals(0, testRobotGetDamage.getDamage());
|
||||
}
|
||||
@Test
|
||||
public void testRobotSetDamage(){
|
||||
Position robotPosition = new Position(3,6);
|
||||
Robot testRobotSetDamage = new Robot(6, robotPosition);
|
||||
testRobotSetDamage.setDamage(2);
|
||||
assertEquals(2, testRobotSetDamage.getDamage());
|
||||
}
|
||||
}
|
45
src/test/java/inf112/fiasko/roborally/objects/TileTest.java
Normal file
45
src/test/java/inf112/fiasko/roborally/objects/TileTest.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.element_properties.TileType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TileTest {
|
||||
private Tile tile;
|
||||
private Tile tile2;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
tile = new Tile(TileType.HOLE, Direction.NORTH);
|
||||
tile2 = new Tile(TileType.COGWHEEL_RIGHT, Direction.SOUTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTypeFromTile() {
|
||||
assertEquals(TileType.HOLE, tile.getTileType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTypeFromTile2() {
|
||||
assertEquals(TileType.COGWHEEL_RIGHT, tile2.getTileType());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getDirectionFromTile() {
|
||||
assertEquals(Direction.NORTH, tile.getDirection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDirectionFromTile2() {
|
||||
assertEquals(Direction.SOUTH, tile2.getDirection());
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
public void invalidTileThrowsException() {
|
||||
new Tile(TileType.TRANSPORT_BAND_FAST, Direction.NORTH_EAST);
|
||||
}
|
||||
}
|
36
src/test/java/inf112/fiasko/roborally/objects/WallTest.java
Normal file
36
src/test/java/inf112/fiasko/roborally/objects/WallTest.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.objects.Wall;
|
||||
import inf112.fiasko.roborally.element_properties.WallType;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WallTest {
|
||||
@Test
|
||||
public void testWallGetWallTypeNormal(){
|
||||
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);
|
||||
assertEquals(Direction.EAST, testGetWall.getDirection());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user