mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-28 20:24:43 +02:00
Gjør nødvendige forandringer i klasser og interfaces relatert til Grid
Bytter rekkefølge mellom height og width Forbedrer kommentarer Gjør slik at testene bruker Tile i stedet for TileType Legger til manglende exception i setElement til IGrid og Grid
This commit is contained in:
@ -1,50 +1,63 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.element_properties.TileType;
|
||||
import inf112.fiasko.roborally.objects.Grid;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class GridTest {
|
||||
private Grid<TileType> grid;
|
||||
private Grid<TileType> grid2;
|
||||
private Grid<Tile> grid;
|
||||
private Grid<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, TileType.TILE);
|
||||
grid2 = new Grid<>(5,8, defaultTile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWidthFromGrid() {
|
||||
assertEquals(4, grid.getWidth());
|
||||
assertEquals(7, grid.getWidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWidthFromGrid2() {
|
||||
assertEquals(8, grid2.getWidth());
|
||||
assertEquals(5, grid2.getWidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeightFromGrid() {
|
||||
assertEquals(7,grid.getHeight());
|
||||
assertEquals(4, grid.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeightFromGrid2() {
|
||||
assertEquals(5,grid2.getHeight());
|
||||
assertEquals(8, grid2.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getElementFromGrid2() {
|
||||
assertEquals(TileType.TILE, grid2.getElement(5,3));
|
||||
assertEquals(defaultTile, grid2.getElement(3,5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setElementInGrid2() {
|
||||
grid2.setElement(2,1, TileType.HOLE);
|
||||
assertEquals(TileType.HOLE, grid2.getElement(2,1));
|
||||
Tile hole = new Tile(TileType.HOLE, Direction.NORTH);
|
||||
grid2.setElement(2,1, hole);
|
||||
assertEquals(hole, grid2.getElement(2,1));
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
public void invalidPositionThrowsErrorOnGet() {
|
||||
grid.getElement(7, 4);
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class)
|
||||
public void invalidPositionThrowsErrorOnSet() {
|
||||
grid2.setElement(5, 8, null);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user