def testPropertyNonExist(self): unit = Unit(1) with self.assertRaises(RuntimeError): str = unit.getProperty('strength') pass
def testGetId(self): unit = Unit(1) id = unit.getId() self.assertEqual(id, 1) pass
def testProperty(self): unit = Unit(1) unit.setProperty('hitPoints', 25) hp = unit.getProperty('hitPoints') self.assertEqual(hp, 25) pass
def testType(self): unit = Unit(1) unit.setType('infantry') type = unit.getType() self.assertEqual(type, 'infantry') pass
def testName(self): unit = Unit(1) unit.setName('Damon') name = unit.getName() self.assertEqual(name, 'Damon') pass
def test_removeUnitNotExit(self): anyUnit = Unit(1) notExistInGroup = Unit(100) self.unitgroup.addUnit(anyUnit) with self.assertRaises(TypeError): res = self.unitgroup.removeUnit(notExistInGroup) pass
def test_removeUnitNotUnit(self): anyUnit = Unit(1) self.unitgroup.addUnit(anyUnit) with self.assertRaises(TypeError): res = self.unitgroup.removeUnit(None) pass
def test_addUnit(self): anyUnit = Unit(1) res = self.unitgroup.addUnit(anyUnit) self.assertEqual(True, res) self.assertEqual(1, self.unitgroup.getUnitCounts()) pass
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
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
def test_removeUnit(self): anyUnit = Unit(1) self.board.addUnit(anyUnit, 1, 1) res = self.board.removeUnit(anyUnit, 1, 1) self.assertIsNone(res) pass
def test_getUnitById(self): anyUnit = Unit(1) self.unitgroup.addUnit(anyUnit) res = self.unitgroup.getUnit(1) self.assertIsInstance(res, Unit) pass
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
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