Example #1
0
    def testPropertyNonExist(self):
        unit = Unit(1)

        with self.assertRaises(RuntimeError):
            str = unit.getProperty('strength')
            
        pass
Example #2
0
    def testGetId(self):
        unit = Unit(1)

        id = unit.getId()
        self.assertEqual(id, 1)

        pass
Example #3
0
    def testProperty(self):
        unit = Unit(1)
        unit.setProperty('hitPoints', 25)

        hp = unit.getProperty('hitPoints')
        self.assertEqual(hp, 25)

        pass
Example #4
0
    def testType(self):
        unit = Unit(1)
        unit.setType('infantry')

        type = unit.getType()
        self.assertEqual(type, 'infantry')

        pass
Example #5
0
    def testName(self):
        unit = Unit(1)
        unit.setName('Damon')

        name = unit.getName()
        self.assertEqual(name, 'Damon')

        pass
Example #6
0
    def test_removeUnitNotExit(self):
        anyUnit = Unit(1)
        notExistInGroup = Unit(100)
        self.unitgroup.addUnit(anyUnit)

        with self.assertRaises(TypeError):
            res = self.unitgroup.removeUnit(notExistInGroup)

        pass
Example #7
0
    def test_removeUnitNotUnit(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

        with self.assertRaises(TypeError):
            res = self.unitgroup.removeUnit(None)

        pass
Example #8
0
    def test_addUnit(self):
        anyUnit = Unit(1)
        res = self.unitgroup.addUnit(anyUnit)

        self.assertEqual(True, res)
        self.assertEqual(1, self.unitgroup.getUnitCounts())

        pass
Example #9
0
    def test_getUnits(self):
        for i in range(3):
            self.board.addUnit(Unit(i), 2, 1)

        res = self.board.getUnits(2, 1)

        self.assertIsInstance(res, list)
        pass
Example #10
0
    def test_removeUnits(self):
        for i in range(3):
            self.board.addUnit(Unit(i), 1, 1)

        res = self.board.removeUnits(1, 1)

        self.assertIsNone(res)
        pass
Example #11
0
    def test_removeUnit(self):
        anyUnit = Unit(1)
        self.board.addUnit(anyUnit, 1, 1)

        res = self.board.removeUnit(anyUnit, 1, 1)

        self.assertIsNone(res)
        pass
Example #12
0
    def test_getUnitById(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

        res = self.unitgroup.getUnit(1)

        self.assertIsInstance(res, Unit)

        pass
Example #13
0
    def test_getUnits(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

        res = self.unitgroup.getUnits()

        self.assertIsInstance(res, dict)
        self.assertEqual(1, len(res))

        pass
Example #14
0
    def test_removeUnitByUnit(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

        res = self.unitgroup.removeUnit(anyUnit)

        self.assertEqual(True, res)
        self.assertEqual(0, self.unitgroup.getUnitCounts())

        pass