-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdc57f9
commit d06551b
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
source/core/src/test/com/csse3200/game/services/GameEndServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.csse3200.game.services; | ||
|
||
import com.csse3200.game.extensions.GameExtension; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@ExtendWith(GameExtension.class) | ||
class GameEndServiceTest { | ||
|
||
GameEndService endService; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
endService = new GameEndService(); | ||
ServiceLocator.registerGameEndService(endService); | ||
} | ||
|
||
@Test | ||
void shouldReturnCount() { | ||
assertEquals(5, ServiceLocator.getGameEndService().getEngineerCount()); | ||
} | ||
|
||
@Test | ||
void shouldDecrementCount() { | ||
ServiceLocator.getGameEndService().updateEngineerCount(); | ||
assertEquals(4, ServiceLocator.getGameEndService().getEngineerCount()); | ||
} | ||
|
||
@Test | ||
void shouldEndGame() { | ||
for (int i = 0; i < 5; i++) { | ||
ServiceLocator.getGameEndService().updateEngineerCount(); | ||
} | ||
assertTrue(ServiceLocator.getGameEndService().hasGameEnded()); | ||
} | ||
} |