Пример #1
0
    def test_get_selected_default(self):
        unitmgr = UnitMgr(None, Menu(None))
        a = Unit('type1', UnitInfo(1, 1, 1, Coord()))
        b = Unit('type2', UnitInfo(2, 1, 1, Coord()))
        unitmgr.add(a)
        unitmgr.add(b)

        empty = unitmgr.get_selected()
        self.assertIsNotNone(empty)
        self.assertEqual(len(empty), 0)

        a.selected = True

        sel = unitmgr.get_selected()
        self.assertIsNotNone(sel)
        self.assertEqual(len(sel), 1)
        self.assertEqual(sel[0].unit_info.unit_id, a.unit_info.unit_id)
Пример #2
0
    def test_get_selected_false(self):
        unitmgr = UnitMgr(None, Menu(None))
        a = Unit('type1', UnitInfo(1, 1, 1, Coord()))
        b = Unit('type2', UnitInfo(2, 1, 1, Coord()))
        unitmgr.add(a)
        unitmgr.add(b)

        both = unitmgr.get_selected(False)
        self.assertIsNotNone(both)
        self.assertEqual(len(both), 2)
        self.assertEqual(both[0].unit_info.unit_id, a.unit_info.unit_id)
        self.assertEqual(both[1].unit_info.unit_id, b.unit_info.unit_id)

        a.selected = True

        unsel = unitmgr.get_selected(False)
        self.assertIsNotNone(unsel)
        self.assertEqual(len(unsel), 1)
        self.assertEqual(unsel[0].unit_info.unit_id, b.unit_info.unit_id)