|
|
@ -56,24 +56,24 @@ class SpaceInvadersLevelTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void testActionIfEnemyIsHitPointsUp() { |
|
|
|
Integer numPointsBefore = (Integer)myLevel.getGlobalFlag("points"); |
|
|
|
Integer numPointsBefore = (Integer)Playground.getGlobalFlag("points"); |
|
|
|
GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.WHITE); |
|
|
|
GameObject dummyEnemy = new RectObject("ego1", myLevel, 0,0,0,0, 12, 12, Color.BLACK); |
|
|
|
myLevel.addObject(dummyShot); |
|
|
|
myLevel.addObject(dummyEnemy); |
|
|
|
myLevel.actionIfEnemyIsHit(dummyEnemy, dummyShot);; // this is the call under test |
|
|
|
Integer numPointsAfter = (Integer)myLevel.getGlobalFlag("points"); // changed? |
|
|
|
Integer numPointsAfter = (Integer)Playground.getGlobalFlag("points"); // changed? |
|
|
|
assertTrue("numPoints is up +200 after EnemyIsHit", numPointsAfter == numPointsBefore + 200); // points are set +200 , check. |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testActionIfEgoObjectIsHitLivesDown() { |
|
|
|
Integer numLivesBefore = (Integer)myLevel.getGlobalFlag("egoLives"); |
|
|
|
Integer numLivesBefore = (Integer)Playground.getGlobalFlag("egoLives"); |
|
|
|
GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.RED); |
|
|
|
GameObject dummyEgo = new EgoObject("ego1", myLevel, 0,0,0,0, 5); |
|
|
|
myLevel.addObject(dummyShot); |
|
|
|
myLevel.actionIfEgoObjectIsHit(dummyShot, dummyEgo); // this is the call under test |
|
|
|
Integer numLivesAfter = (Integer)myLevel.getGlobalFlag("egoLives"); // changed? |
|
|
|
Integer numLivesAfter = (Integer)Playground.getGlobalFlag("egoLives"); // changed? |
|
|
|
assertTrue("numLives is reduced by one ifEgoIsHit", numLivesAfter == numLivesBefore - 1); // lives is reduced by one |
|
|
|
|
|
|
|
} |
|
|
|