Added some more region priority unit tests.

This commit is contained in:
sk89q 2011-06-11 01:20:21 -07:00
parent b2cd3d31fd
commit 2277183330

View File

@ -92,6 +92,7 @@ void setUpCourtyardRegion() {
manager.addRegion(region); manager.addRegion(region);
courtyard = region; courtyard = region;
courtyard.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
} }
void setUpFountainRegion() throws Exception { void setUpFountainRegion() throws Exception {
@ -106,16 +107,22 @@ void setUpFountainRegion() throws Exception {
fountain = region; fountain = region;
fountain.setParent(courtyard); fountain.setParent(courtyard);
fountain.setFlag(DefaultFlag.FIRE_SPREAD, StateFlag.State.DENY); fountain.setFlag(DefaultFlag.FIRE_SPREAD, StateFlag.State.DENY);
fountain.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.ALLOW);
} }
@Test @Test
public void testNoPriorities() throws Exception { public void testNoPriorities() throws Exception {
ApplicableRegionSet appl; ApplicableRegionSet appl;
courtyard.setPriority(0);
fountain.setPriority(0);
appl = manager.getApplicableRegions(inCourtyard); appl = manager.getApplicableRegions(inCourtyard);
assertTrue(appl.allows(DefaultFlag.FIRE_SPREAD)); assertTrue(appl.allows(DefaultFlag.FIRE_SPREAD));
assertFalse(appl.allows(DefaultFlag.MOB_SPAWNING));
appl = manager.getApplicableRegions(inFountain); appl = manager.getApplicableRegions(inFountain);
assertFalse(appl.allows(DefaultFlag.FIRE_SPREAD)); assertFalse(appl.allows(DefaultFlag.FIRE_SPREAD));
assertFalse(appl.allows(DefaultFlag.MOB_SPAWNING));
} }
@Test @Test
@ -123,6 +130,8 @@ public void testPriorities() throws Exception {
ApplicableRegionSet appl; ApplicableRegionSet appl;
courtyard.setPriority(5); courtyard.setPriority(5);
fountain.setPriority(0);
appl = manager.getApplicableRegions(inCourtyard); appl = manager.getApplicableRegions(inCourtyard);
assertTrue(appl.allows(DefaultFlag.FIRE_SPREAD)); assertTrue(appl.allows(DefaultFlag.FIRE_SPREAD));
appl = manager.getApplicableRegions(inFountain); appl = manager.getApplicableRegions(inFountain);
@ -133,10 +142,12 @@ public void testPriorities() throws Exception {
public void testPriorities2() throws Exception { public void testPriorities2() throws Exception {
ApplicableRegionSet appl; ApplicableRegionSet appl;
fountain.setPriority(0);
fountain.setPriority(5); fountain.setPriority(5);
appl = manager.getApplicableRegions(inCourtyard); appl = manager.getApplicableRegions(inCourtyard);
assertTrue(appl.allows(DefaultFlag.FIRE_SPREAD)); assertFalse(appl.allows(DefaultFlag.MOB_SPAWNING));
appl = manager.getApplicableRegions(inFountain); appl = manager.getApplicableRegions(inFountain);
assertFalse(appl.allows(DefaultFlag.FIRE_SPREAD)); assertTrue(appl.allows(DefaultFlag.MOB_SPAWNING));
} }
} }