-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4796 from Algebro7/fix-untreated-personnel-nag-fo…
…r-prisoners Remove untreated personnel nag for prisoner-defectors and add unit tests
- Loading branch information
Showing
2 changed files
with
80 additions
and
2 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
78 changes: 78 additions & 0 deletions
78
MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UntreatedPersonnelNagDialogTest.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,78 @@ | ||
package mekhq.gui.dialog.nagDialogs; | ||
|
||
import megamek.common.EquipmentType; | ||
import mekhq.campaign.Campaign; | ||
import mekhq.campaign.personnel.Person; | ||
import mekhq.campaign.personnel.SkillType; | ||
import mekhq.campaign.personnel.enums.PersonnelRole; | ||
import mekhq.campaign.personnel.enums.PersonnelStatus; | ||
import mekhq.campaign.personnel.enums.PrisonerStatus; | ||
import mekhq.campaign.personnel.ranks.Ranks; | ||
import mekhq.campaign.universe.Systems; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
import static mekhq.gui.dialog.nagDialogs.UntreatedPersonnelNagDialog.isUntreatedInjury; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class UntreatedPersonnelNagDialogTest { | ||
Campaign campaign; | ||
Person person; | ||
|
||
@BeforeAll | ||
public static void setup() { | ||
EquipmentType.initializeTypes(); | ||
SkillType.initializeTypes(); | ||
Ranks.initializeRankSystems(); | ||
try { | ||
Systems.setInstance(Systems.loadDefault()); | ||
} catch (Exception ex) { | ||
LogManager.getLogger().error("", ex); | ||
} | ||
} | ||
|
||
@BeforeEach | ||
public void init() { | ||
campaign = new Campaign(); | ||
person = campaign.newPerson(PersonnelRole.MECHWARRIOR); | ||
person.setHits(1); | ||
} | ||
|
||
@Test | ||
public void isUntreatedInjuryIncludesNonPrisonersTest() { | ||
person.setPrisonerStatus(campaign, PrisonerStatus.FREE, false); | ||
campaign.importPerson(person); | ||
assertTrue(isUntreatedInjury(campaign)); | ||
} | ||
|
||
@Test | ||
public void isUntreatedInjuryExcludesPrisonersTest() { | ||
person.setPrisonerStatus(campaign, PrisonerStatus.PRISONER, false); | ||
campaign.importPerson(person); | ||
assertFalse(isUntreatedInjury(campaign)); | ||
} | ||
|
||
@Test | ||
public void isUntreatedInjuryExcludesPrisonerDefectorsTest() { | ||
person.setPrisonerStatus(campaign, PrisonerStatus.PRISONER_DEFECTOR, false); | ||
campaign.importPerson(person); | ||
assertFalse(isUntreatedInjury(campaign)); | ||
} | ||
|
||
@Test | ||
public void isUntreatedInjuryExcludesBondsmenTest() { | ||
person.setPrisonerStatus(campaign, PrisonerStatus.BONDSMAN, false); | ||
campaign.importPerson(person); | ||
assertTrue(isUntreatedInjury(campaign)); | ||
} | ||
|
||
@Test | ||
public void isUntreatedInjuryExcludesInactivePersonnelTest() { | ||
person.setStatus(PersonnelStatus.AWOL); | ||
campaign.importPerson(person); | ||
assertFalse(isUntreatedInjury(campaign)); | ||
} | ||
} |