Browse Source

Test: JunitTest verified correct cell

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

10
src/main/java/pacmanGame/GameManager.java

@ -45,15 +45,7 @@ public class GameManager {
default:
break;
}
time++;
/*
if(time == 300) {
spawnCherry();
}
if (time == 600) {
destroyCherry();
}*/
time++;
}
public void spawnCherry() {

29
src/test/java/pacmanTests/MapTest.java

@ -3,6 +3,8 @@ package pacmanTests;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import java.util.function.IntPredicate;
import org.junit.jupiter.api.Test;
import pacmanGame.*;
@ -34,6 +36,31 @@ class MapTest {
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
void Map_getCell_returnsCorrectCells() {
// arrange
@ -57,7 +84,7 @@ class MapTest {
assertThat(expectedMiddle).isEqualTo(middle);
assertThat(expectedBottomRight).isEqualTo(bottomRight);
}
@Test
void Map_getPath_returnCorrectPathSimple() {
// arrange

Loading…
Cancel
Save