-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for advanced atmospheric control rolls
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package megamek.server; | ||
|
||
import megamek.common.*; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Vector; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class GameManagerTest { | ||
private Player player; | ||
private GameManager gameManager; | ||
private Game game; | ||
|
||
@BeforeAll | ||
static void before() { | ||
EquipmentType.initializeTypes(); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
player = new Player(0, "Test"); | ||
gameManager = new GameManager(); | ||
game = gameManager.getGame(); | ||
game.addPlayer(0, player); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericMergesIntoOneRoll() { | ||
AeroSpaceFighter aero = new AeroSpaceFighter(); | ||
game.addEntity(aero); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "critical hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(aero, rolls, reasons); | ||
assertEquals(1, rolls.size()); | ||
assertTrue(reasons.toString().contains("critical hit")); | ||
assertTrue(reasons.toString().contains("avionics hit")); | ||
assertTrue(reasons.toString().contains("threshold")); | ||
assertTrue(reasons.toString().contains("highest damage threshold exceeded")); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericIncludesAllReasons() { | ||
AeroSpaceFighter aero = new AeroSpaceFighter(); | ||
game.addEntity(aero); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "critical hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(aero, rolls, reasons); | ||
assertTrue(reasons.toString().contains("critical hit")); | ||
assertTrue(reasons.toString().contains("avionics hit")); | ||
assertTrue(reasons.toString().contains("threshold")); | ||
assertTrue(reasons.toString().contains("highest damage threshold exceeded")); | ||
} | ||
} |