-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Updated playerstatuscontroller and tests
- Loading branch information
Showing
2 changed files
with
46 additions
and
38 deletions.
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
46 changes: 36 additions & 10 deletions
46
src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/model/PlayerStatusTest.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 |
|---|---|---|
| @@ -1,23 +1,49 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.model; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.controller.PlayerStatusController; | ||
| import org.junit.jupiter.api.Test; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class PlayerStatusTest { | ||
|
|
||
| /** | ||
| * Player object used for testing. | ||
| * */ | ||
| private Player testPlayer; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| testPlayer = new Player("Player", new BigDecimal(1000)); | ||
| } | ||
|
|
||
| @Test | ||
| void getStatusReturnsProperStatuses() { | ||
| Player testPlayer = new Player("Player", new BigDecimal(1000)); | ||
| PlayerStatus gottenStatus = PlayerStatusController.getStatus(testPlayer); | ||
| assertEquals(PlayerStatus.NOOB, gottenStatus); | ||
| void getStatusAtStartReturnsWorstStatus() { | ||
| assertEquals(PlayerStatus.NOOB, testPlayer.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| void getStatusAfterDoubleIncreaseReturnsBetterStatus() { | ||
| testPlayer.addMoney(new BigDecimal(1000)); | ||
| PlayerStatus gottenStatus2 = PlayerStatusController.getStatus(testPlayer); | ||
| assertEquals(PlayerStatus.TRYHARD, testPlayer.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| void gettingStatusWhenNegativeDifferenceReturnsWorstStatus() { | ||
| testPlayer.addMoney(new BigDecimal(-1000)); | ||
| assertEquals(PlayerStatus.NOOB, testPlayer.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| void multipleChangesInValueCauseCorrectStatus() { | ||
| testPlayer.addMoney(new BigDecimal(2000)); | ||
| assertEquals(PlayerStatus.PRO, testPlayer.getStatus()); | ||
|
|
||
| testPlayer.addMoney(new BigDecimal(-1000)); | ||
| assertEquals(PlayerStatus.TRYHARD, testPlayer.getStatus()); | ||
|
|
||
| assertEquals(PlayerStatus.TRYHARD, gottenStatus2); | ||
| testPlayer.addMoney(new BigDecimal(-500)); | ||
| assertEquals(PlayerStatus.GOOD, testPlayer.getStatus()); | ||
| } | ||
| } |