Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 def testSetX(self):
     explosion = Explosion(2)
     explosion.setX(4)
     self.assertEquals(4, explosion.getX())
Пример #4
0
 def testMoveBowingExplosion(self):
     explosion = Explosion(2)
     explosion.setMovingStrategy(StubExplosionMovingStrategy())
     explosion.setBlowingObject(StubBlowingObject())
     explosion.blow()
     self.assertRaises(ExplosionError, lambda: explosion.move(1))
Пример #5
0
 def testSetVolumeOnBlowingExplosion(self):
     explosion = Explosion(2)
     explosion.setBlowingObject(StubBlowingObject())
     explosion.blow()
     self.assertRaises(ExplosionError, lambda: explosion.setVolume(ExplosionVolume_Normal))
Пример #6
0
 def testTwiceBlow(self):
     explosion = Explosion(2)
     explosion.setBlowingObject(StubBlowingObject())
     explosion.blow()
     self.assertRaises(ExplosionError, lambda: explosion.blow())
Пример #7
0
 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())
Пример #8
0
 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())
Пример #9
0
 def testGetSetVolume(self):
     explosion = Explosion(2)
     self.assertEquals(ExplosionVolume_Normal, explosion.getVolume())
     explosion.setVolume(ExplosionVolume_Low)
     self.assertEquals(ExplosionVolume_Low, explosion.getVolume())