mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-07 18:49:34 +01:00
Legger til manglende sjekking av retning for en vegg som instansieres
Legger til en test som sjekker at en exception blir kastet når en ugyldig vegg blir forsøkt instansiert Legger til en test som sjekker at en exception blir kastet når en ugyldig tile blir forsøkt instansiert
This commit is contained in:
parent
d7186d38c3
commit
c6083c2a70
@ -17,6 +17,9 @@ public class Wall {
|
||||
* @param direction The direction of the wall
|
||||
*/
|
||||
public Wall (WallType wallType, Direction direction) {
|
||||
if (direction.getDirectionID() % 2 == 0 && wallType != WallType.WALL_CORNER) {
|
||||
throw new IllegalArgumentException("Invalid direction for wall type submitted");
|
||||
}
|
||||
this.wallType = wallType;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.objects.Tile;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -44,6 +45,11 @@ public class TileTypeTest {
|
||||
assertNull(TileType.getTileTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
public void invalidTileDirectionThrowsError() {
|
||||
new Tile(TileType.TILE, Direction.NORTH_EAST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTilesHaveUniqueId() {
|
||||
/* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
|
||||
|
@ -1,5 +1,6 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.objects.Wall;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -44,6 +45,11 @@ public class WallTypeTest {
|
||||
assertNull(TileType.getTileTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
public void invalidWallDirectionThrowsError() {
|
||||
new Wall(WallType.WALL_NORMAL, Direction.NORTH_EAST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allWallsHaveUniqueId() {
|
||||
/* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
|
||||
|
Loading…
x
Reference in New Issue
Block a user