def testMove(self): ms = StubExplosionMovingStrategy() explosion = Explosion(2) explosion.setMovingStrategy(ms) self.assertFalse(ms.moveExplosionCall) explosion.move(5) self.assertTrue(ms.moveExplosionCall) self.assertEquals(explosion, ms.exlosion) self.assertEquals(5, ms.dx)
def testBlow(self): explosion = Explosion(1.5) blowingObject = StubBlowingObject() blowingObject.setPosition(1.0, 0.0) explosion.setBlowingObject(blowingObject) explosion.setVolume(ExplosionVolume_Hight) self.assertFalse(blowingObject.blowCall) explosion.blow() self.assertTrue(explosion.isBlowing()) self.assertTrue(blowingObject.blowCall) self.assertEquals((0.0, ExplosionVolume_Hight), blowingObject.blowVector) self.assertEquals((1.5, 1.0), blowingObject.blowPosition)
def testSetX(self): explosion = Explosion(2) explosion.setX(4) self.assertEquals(4, explosion.getX())
def testMoveBowingExplosion(self): explosion = Explosion(2) explosion.setMovingStrategy(StubExplosionMovingStrategy()) explosion.setBlowingObject(StubBlowingObject()) explosion.blow() self.assertRaises(ExplosionError, lambda: explosion.move(1))
def testSetVolumeOnBlowingExplosion(self): explosion = Explosion(2) explosion.setBlowingObject(StubBlowingObject()) explosion.blow() self.assertRaises(ExplosionError, lambda: explosion.setVolume(ExplosionVolume_Normal))
def testTwiceBlow(self): explosion = Explosion(2) explosion.setBlowingObject(StubBlowingObject()) explosion.blow() self.assertRaises(ExplosionError, lambda: explosion.blow())
def testConstructor(self): explosion = Explosion(2) self.assertEquals(2, explosion.getX()) self.assertEquals(0, explosion.getY()) self.assertEquals(ExplosionVolume_Normal, explosion.getVolume()) self.assertFalse(explosion.isBlowing())
def testSetNextVolume(self): explosion = Explosion(2) self.assertEquals(ExplosionVolume_Normal, explosion.getVolume()) explosion.setNextVolume() self.assertEquals(ExplosionVolume_Hight, explosion.getVolume()) explosion.setNextVolume() self.assertEquals(ExplosionVolume_Low, explosion.getVolume()) explosion.setNextVolume() self.assertEquals(ExplosionVolume_Normal, explosion.getVolume())
def testGetSetVolume(self): explosion = Explosion(2) self.assertEquals(ExplosionVolume_Normal, explosion.getVolume()) explosion.setVolume(ExplosionVolume_Low) self.assertEquals(ExplosionVolume_Low, explosion.getVolume())