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)
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)
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)
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)