Browse Source

Test: JunitTest verified correct cell

remotes/origin/ghostsbehaviour
fdai2751 11 months ago
parent
commit
c5f46f59d6
  1. 8
      src/main/java/pacmanGame/GameManager.java
  2. 27
      src/test/java/pacmanTests/MapTest.java

8
src/main/java/pacmanGame/GameManager.java

@ -46,14 +46,6 @@ public class GameManager {
break; break;
} }
time++; time++;
/*
if(time == 300) {
spawnCherry();
}
if (time == 600) {
destroyCherry();
}*/
} }
public void spawnCherry() { public void spawnCherry() {

27
src/test/java/pacmanTests/MapTest.java

@ -3,6 +3,8 @@ package pacmanTests;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import java.util.function.IntPredicate;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import pacmanGame.*; import pacmanGame.*;
@ -34,6 +36,31 @@ class MapTest {
assertThat(expectedBottomRight).isEqualTo(bottomRight); assertThat(expectedBottomRight).isEqualTo(bottomRight);
} }
@Test
void Map_getCell_returnsExceptionCells() {
// arrange
String[] mapTest = {
"eew",
"e..",
"ww."
};
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
Map testMap = gameManager.map;
Cell expectedTopLeft = testMap.cells[2][0];
Cell expectedMiddle = testMap.cells[1][1];
Cell expectedBottomRight = testMap.cells[0][2];
// act
Cell topLeft = testMap.GetCell(new Vector2(2, 0));
Cell middle = testMap.GetCell(new Vector2(1, 1));
Cell bottomRight = testMap.GetCell(new Vector2(0, 2));
IntPredicate expectedTopRight;
// assert
assertThat(expectedTopLeft).isEqualTo(topLeft);
assertThat(expectedMiddle).isEqualTo(middle);
assertThat(expectedBottomRight).isEqualTo(bottomRight);
}
@Test @Test
void Map_getCell_returnsCorrectCells() { void Map_getCell_returnsCorrectCells() {
// arrange // arrange

Loading…
Cancel
Save