mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-28 12:14:42 +02:00
Legger til en WallType enum og tester
This commit is contained in:
61
src/test/java/inf112/fiasko/roborally/WallTypeTest.java
Normal file
61
src/test/java/inf112/fiasko/roborally/WallTypeTest.java
Normal file
@ -0,0 +1,61 @@
|
||||
package inf112.fiasko.roborally;
|
||||
|
||||
import inf112.fiasko.roborally.abstractions.TileType;
|
||||
import inf112.fiasko.roborally.abstractions.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