Пример #1
0
    def testPropertyNonExist(self):
        unit = Unit(1)

        with self.assertRaises(RuntimeError):
            str = unit.getProperty('strength')
            
        pass
Пример #2
0
    def testGetId(self):
        unit = Unit(1)

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

        pass
Пример #3
0
    def testProperty(self):
        unit = Unit(1)
        unit.setProperty('hitPoints', 25)

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

        pass
Пример #4
0
    def testType(self):
        unit = Unit(1)
        unit.setType('infantry')

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

        pass
Пример #5
0
    def testName(self):
        unit = Unit(1)
        unit.setName('Damon')

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

        pass
Пример #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
Пример #7
0
    def test_removeUnitNotUnit(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

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

        pass
Пример #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
Пример #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
Пример #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
Пример #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
Пример #12
0
    def test_getUnitById(self):
        anyUnit = Unit(1)
        self.unitgroup.addUnit(anyUnit)

        res = self.unitgroup.getUnit(1)

        self.assertIsInstance(res, Unit)

        pass
Пример #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
Пример #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