fdai7910
11 months ago
10 changed files with 299 additions and 47 deletions
-
50src/main/java/pacmanGame/Cell.java
-
43src/main/java/pacmanGame/GameManager.java
-
32src/main/java/pacmanGame/Map.java
-
35src/main/java/pacmanGame/Player.java
-
11src/main/java/pacmanGame/VisualizerPlainText.java
-
28src/main/java/pacmanGame/VisualizerPlainTextUltra.java
-
110src/test/java/pacmanTests/CellTest.java
-
4src/test/java/pacmanTests/GameManagerTest.java
-
18src/test/java/pacmanTests/MapTest.java
-
1src/test/java/pacmanTests/VisualizerPlainTextTest.java
@ -0,0 +1,110 @@ |
|||
package pacmanTests; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
import pacmanGame.*; |
|||
|
|||
|
|||
class CellTest { |
|||
|
|||
@Test |
|||
void cell_triggerItem_505cherryScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "cherry"; |
|||
int expectedScore = 505; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_10dotScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "dot"; |
|||
int expectedScore = 10; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_100pillScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "pill"; |
|||
int expectedScore = 100; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_405strawberryScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "strawberry"; |
|||
int expectedScore = 405; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_305orangeScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "orange"; |
|||
int expectedScore = 305; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_205appleScore() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "apple"; |
|||
int expectedScore = 205; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingScore = gameManager.score; |
|||
// assert |
|||
assertThat(expectedScore).isEqualTo(resultingScore); |
|||
} |
|||
|
|||
@Test |
|||
void cell_triggerItem_3crystalMoveSpeed() { |
|||
// arrange |
|||
GameManager gameManager = new GameManager(); |
|||
Cell cell = gameManager.map.GetCell(new Vector2(0,0)); |
|||
cell.type = "crystal"; |
|||
int expectedMoveSpeed = 3; |
|||
// act |
|||
cell.triggerItem(); |
|||
int resultingMoveSpeed = gameManager.moveSpeed; |
|||
// assert |
|||
assertThat(expectedMoveSpeed).isEqualTo(resultingMoveSpeed); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue