mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-28 20:24:43 +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,60 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class DirectionTest {
|
||||
|
||||
@Test
|
||||
public void getDirectionIdForNorth() {
|
||||
assertEquals(1, Direction.NORTH.getDirectionID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDirectionFromNorthID() {
|
||||
assertEquals(Direction.NORTH, Direction.getDirectionFromID(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDirectionIdForSouthWest() {
|
||||
assertEquals(6, Direction.SOUTH_WEST.getDirectionID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDirectionFromSouthWestID() {
|
||||
assertEquals(Direction.SOUTH_WEST, Direction.getDirectionFromID(6));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allDirectionsIDConversionToIDAndBack() {
|
||||
for (Direction direction : Direction.values()) {
|
||||
assertEquals(direction, Direction.getDirectionFromID(direction.getDirectionID()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidDirectionIDReturnsNull() {
|
||||
assertNull(Direction.getDirectionFromID(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allDirectionsHaveUniqueId() {
|
||||
/* This test is also done implicitly by the allDirectionsIDConversionToIDAndBack test, but that test may fail
|
||||
even if this test passes, so this test is needed for clarity. */
|
||||
Set<Integer> set = new HashSet<>();
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (Direction direction : Direction.values()) {
|
||||
set.add(direction.getDirectionID());
|
||||
list.add(direction.getDirectionID());
|
||||
}
|
||||
assertEquals(list.size(), set.size());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Position;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PositionTest {
|
||||
private Position testPosition;
|
||||
@Before
|
||||
public void setUp() {
|
||||
testPosition = new Position(3, 4);
|
||||
}
|
||||
@Test
|
||||
public void testGetXPosition(){
|
||||
assertEquals(3,testPosition.getXCoordinate());
|
||||
}
|
||||
@Test
|
||||
public void testGetYPosition(){
|
||||
assertEquals(4,testPosition.getYCoordinate());
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.TileType;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TileTypeTest {
|
||||
|
||||
@Test
|
||||
public void getTileTypeIDForHole() {
|
||||
assertEquals(2, TileType.HOLE.getTileTypeID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTypeFromHoleID() {
|
||||
assertEquals(TileType.HOLE, TileType.getTileTypeFromID(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTypeIDForWrench() {
|
||||
assertEquals(21, TileType.WRENCH.getTileTypeID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTypeFromWrenchID() {
|
||||
assertEquals(TileType.WRENCH, TileType.getTileTypeFromID(21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTileTypesIDConversionToIDAndBack() {
|
||||
for (TileType type : TileType.values()) {
|
||||
assertEquals(type, TileType.getTileTypeFromID(type.getTileTypeID()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidTileTypeIDReturnsNull() {
|
||||
assertNull(TileType.getTileTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTilesHaveUniqueId() {
|
||||
/* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
|
||||
even if this test passes, so this test is needed for clarity. */
|
||||
Set<Integer> set = new HashSet<>();
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (TileType type : TileType.values()) {
|
||||
set.add(type.getTileTypeID());
|
||||
list.add(type.getTileTypeID());
|
||||
}
|
||||
assertEquals(list.size(), set.size());
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.TileType;
|
||||
import inf112.fiasko.roborally.element_properties.WallType;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class WallTypeTest {
|
||||
|
||||
@Test
|
||||
public void getWallTypeIDForWallNormal() {
|
||||
assertEquals(1, WallType.WALL_NORMAL.getWallTypeID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWallTypeFromWallNormalID() {
|
||||
assertEquals(WallType.WALL_NORMAL, WallType.getWallTypeFromID(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWallTypeIDForWallLaserSingle() {
|
||||
assertEquals(3, WallType.WALL_LASER_SINGLE.getWallTypeID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWallTypeFromWallLaserSingleID() {
|
||||
assertEquals(WallType.WALL_LASER_SINGLE, WallType.getWallTypeFromID(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allWallTypesIDConversionToIDAndBack() {
|
||||
for (WallType type : WallType.values()) {
|
||||
assertEquals(type, WallType.getWallTypeFromID(type.getWallTypeID()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidWallTypeIDReturnsNull() {
|
||||
assertNull(TileType.getTileTypeFromID(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allWallsHaveUniqueId() {
|
||||
/* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
|
||||
even if this test passes, so this test is needed for clarity. */
|
||||
Set<Integer> set = new HashSet<>();
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (WallType type : WallType.values()) {
|
||||
set.add(type.getWallTypeID());
|
||||
list.add(type.getWallTypeID());
|
||||
}
|
||||
assertEquals(list.size(), set.size());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user