Ejemplo n.º 1
0
 def testBlow(self):
     body = StubBox2dCarBody()
     car = Car(body)
     vector = (0, 1)
     position = (1, 0)
     car.blow(vector, position)
     self.assertTrue(car.isBlowed())
     self.assertEquals((0, 1), body.vector)
     self.assertEquals(position, body.position)
Ejemplo n.º 2
0
 def testMoveCar(self):
     body = StubBox2dCarBody()
     cms = StubCarMovingStrategy()
     car = Car(body)
     car.setMovingStrategy(cms)
     self.assertFalse(cms.moveCarCall)
     car.move(5)
     self.assertTrue(cms.moveCarCall)
     self.assertEquals(car, cms.car)
     self.assertEquals(5, cms.dx)
Ejemplo n.º 3
0
 def testConstructor(self):
     body = StubBox2dCarBody()
     car = Car(body)
     self.assertEquals(4, car.getX())
     self.assertEquals(0, car.getY())
     self.assertEquals(2, car.getWidth())
     self.assertEquals(1, car.getHeight())
     self.assertFalse(car.isBlowed())
Ejemplo n.º 4
0
 def testSetX(self):
     car = Car(StubBox2dCarBody())
     car.setX(4)
     self.assertEquals(4, car.getX())
Ejemplo n.º 5
0
 def testMoveCarAfterBlow(self):
     car = Car(StubBox2dCarBody())
     car.setMovingStrategy(StubCarMovingStrategy())
     car.blow((0, 1), (1, 0))
     self.assertRaises(CarError, lambda: car.move(1))
Ejemplo n.º 6
0
 def testTwiceBlow(self):
     body = StubBox2dCarBody()
     car = Car(body)
     car.blow((0, 1), (1, 0))
     self.assertRaises(CarError, lambda: car.blow((1, 0), (1, 2)))