示例#1
0
    def test_income_shoot_outrange(self):
        f = Field(4, 4)
        with self.assertRaises(CoordOutOfRange):
            ShipService.shoot_to(f, 22, 2)

        with self.assertRaises(CoordOutOfRange):
            ShipService.shoot_to(f, 2, -2)
示例#2
0
 def test_income_shoot_border(self):
     f = Field(4, 4)
     cell = f.get(2, 2)
     cell.mark_border()
     self.assertFalse(ShipService.shoot_to(f, 2, 2))
     self.assertTrue(cell.is_shooted)
     self.assertTrue(cell.is_border)
示例#3
0
 def test_income_shoot_hit(self):
     f = Field(4, 4)
     cell = f.get(2, 2)
     cell.mark_ship()
     self.assertTrue(ShipService.shoot_to(f, 2, 2))
     self.assertTrue(cell.is_shooted)
     self.assertTrue(cell.is_ship)
示例#4
0
 def test_income_shoot_missed(self):
     f = Field(4, 4)
     cell = f.get(2, 2)
     self.assertFalse(ShipService.shoot_to(f, 2, 2))
     self.assertTrue(cell.is_shooted)
     self.assertTrue(cell.is_empty)