Ejemplo n.º 1
0
    def testTroopGetRectForManuallyAssignedRectReturnsCorrectRect(self):
        unit = Troop()
        surface = pygame.Surface((10,10))
        rect = surface.get_rect()
        unit.rect = rect

        self.assertEqual(unit.getRect(), unit.rect)
Ejemplo n.º 2
0
    def testTroopRectAttributeHasCorrectDimensionsAfterCreateImageCall(self):
        unit = Troop()
        unit.createImage()
        unit_rect = unit.getRect()
        correct_width = 10
        correct_height = 10

        self.assertEqual(unit_rect.width, correct_width)
        self.assertEqual(unit_rect.height, correct_height)
Ejemplo n.º 3
0
    def testTroopColorSpriteMethodCallsSurfaceFillMethod(self):
        unit = Troop()
        unit.createImage()
        unit.image = Mock()
        unit.colorSprite((0,0,0))

        unit.image.fill.assert_called_once_with((0,0,0))
Ejemplo n.º 4
0
    def testTroopCreateImageAssignsARectToTroopRectAttribute(self):
        unit = Troop()
        unit.createImage()

        self.assertIs(type(unit.getRect()), pygame.Rect)
Ejemplo n.º 5
0
    def testTroopCreateImageAssignsASurfaceToTroopImageAttribute(self):
        unit = Troop()
        unit.createImage()

        self.assertIs(type(unit.getImage()), pygame.Surface)
Ejemplo n.º 6
0
    def testTroopGetImageForManuallyAssignedImageReturnsCorrectImage(self):
        unit = Troop()
        image = pygame.Surface((10,10))
        unit.image = image

        self.assertEqual(unit.getImage(), unit.image)
Ejemplo n.º 7
0
    def testTroopGetRectForTroopWithANoneRectReturnsCorrectRect(self):
        unit = Troop()

        self.assertEqual(unit.getRect(), None)
Ejemplo n.º 8
0
    def testTroopGetImageForTroopWithANoneImageReturnsCorrectImage(self):
        unit = Troop()

        self.assertEqual(unit.getImage(), None)
Ejemplo n.º 9
0
    def testTroopGetIdWithManuallyAssignedIdReturnsCorrectId(self):
        unit = Troop()
        unit._id = 83

        self.assertEqual(unit.getId(), 83)
Ejemplo n.º 10
0
    def testTroopGetIdWithUnassignedIdReturnsCorrectId(self):
        unit = Troop()

        self.assertEqual(unit.getId(), -1)
Ejemplo n.º 11
0
    def testTroopInitializedWithCertainParametersHasCorrectValues(self):
        unit = Troop(5)

        self.assertEqual(unit.getId(), 5)
        self.assertEqual(unit.getImage(), None)
        self.assertEqual(unit.getRect(), None)
Ejemplo n.º 12
0
    def testTroopInitializedWithNoParametersHasCorrectValues(self):
        unit = Troop()

        self.assertEqual(unit.getId(), -1)
        self.assertEqual(unit.image, None)
        self.assertEqual(unit.rect, None)