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)
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)
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())
def testSetX(self): car = Car(StubBox2dCarBody()) car.setX(4) self.assertEquals(4, car.getX())
def testMoveCarAfterBlow(self): car = Car(StubBox2dCarBody()) car.setMovingStrategy(StubCarMovingStrategy()) car.blow((0, 1), (1, 0)) self.assertRaises(CarError, lambda: car.move(1))
def testTwiceBlow(self): body = StubBox2dCarBody() car = Car(body) car.blow((0, 1), (1, 0)) self.assertRaises(CarError, lambda: car.blow((1, 0), (1, 2)))