def testConstructor(self): enemy = Enemy(1, 2, 10, 20) self.assertEquals(1, enemy.getX()) self.assertEquals(2, enemy.getY()) self.assertEquals(10, enemy.getWidth()) self.assertEquals(20, enemy.getHeight()) self.assertFalse(enemy.isDestroyed())
def testAllEnemiesDestroyed(self): box2dWorld = StubBox2dWorld() car = Car(StubBox2dCarBody()) enemy1 = Enemy(0, 5, 1, 1) enemy2 = Enemy(5, 8, 1, 1) enemies = [enemy1, enemy2] explosion = Explosion(1) world = World(10, 20, box2dWorld, car, enemies, explosion) self.assertFalse(world.allEnemiesDestroyed()) enemy1.destroy() self.assertFalse(world.allEnemiesDestroyed()) enemy2.destroy() self.assertTrue(world.allEnemiesDestroyed())
def testDestroy(self): enemy = Enemy(1, 2, 10, 20) self.assertFalse(enemy.isDestroyed()) enemy.destroy() self.assertTrue(enemy.isDestroyed())