public void CanSinkShip() { var board = SetupBoard(); var coordinate = new Coordinate(10, 6); var response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Hit, response.ShotStatus); Assert.AreEqual("Battleship", response.ShipImpacted); coordinate = new Coordinate(10, 7); response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Hit, response.ShotStatus); Assert.AreEqual("Battleship", response.ShipImpacted); coordinate = new Coordinate(10, 8); response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Hit, response.ShotStatus); Assert.AreEqual("Battleship", response.ShipImpacted); coordinate = new Coordinate(10, 9); response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.HitAndSunk, response.ShotStatus); Assert.AreEqual("Battleship", response.ShipImpacted); }
public void CanMissShip() { var board = SetupBoard(); var coordinate = new Coordinate(5, 5); var response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Miss, response.ShotStatus); }
public void CanNotFireOffBoard() { var board = SetupBoard(); var coordinate = new Coordinate(15, 20); var response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Invalid, response.ShotStatus); }
public void CanHitShip() { var board = SetupBoard(); var coordinate = new Coordinate(3, 1); var response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Hit, response.ShotStatus); Assert.AreEqual("Cruiser", response.ShipImpacted); }
public void CanNotFireDuplicateShot() { var board = SetupBoard(); var coordinate = new Coordinate(5, 5); var response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Miss, response.ShotStatus); // fire same shot response = board.FireShot(coordinate); Assert.AreEqual(ShotStatus.Duplicate, response.ShotStatus); }
public ShotStatus FireAtShip(Coordinate position) { if (BoardPositions.Contains(position)) { _lifeRemaining--; if(_lifeRemaining == 0) return ShotStatus.HitAndSunk; return ShotStatus.Hit; } return ShotStatus.Miss; }
private FireShotResponse SinkSubmarine(Board board) { var coordinate = new Coordinate(1, 5); board.FireShot(coordinate); coordinate = new Coordinate(2, 5); board.FireShot(coordinate); coordinate = new Coordinate(3, 5); return board.FireShot(coordinate); }
private FireShotResponse SinkDestroyer(Board board) { var coordinate = new Coordinate(1, 8); board.FireShot(coordinate); coordinate = new Coordinate(2, 8); return board.FireShot(coordinate); }
private FireShotResponse SinkCruiser(Board board) { var coordinate = new Coordinate(3, 1); board.FireShot(coordinate); coordinate = new Coordinate(3, 2); board.FireShot(coordinate); coordinate = new Coordinate(3, 3); return board.FireShot(coordinate); }
private FireShotResponse SinkCarrier(Board board) { var coordinate = new Coordinate(4, 4); board.FireShot(coordinate); coordinate = new Coordinate(5, 4); board.FireShot(coordinate); coordinate = new Coordinate(6, 4); board.FireShot(coordinate); coordinate = new Coordinate(7, 4); board.FireShot(coordinate); coordinate = new Coordinate(8, 4); return board.FireShot(coordinate); }
private FireShotResponse SinkBattleship(Board board) { var coordinate = new Coordinate(10, 6); board.FireShot(coordinate); coordinate = new Coordinate(10, 7); board.FireShot(coordinate); coordinate = new Coordinate(10, 8); board.FireShot(coordinate); coordinate = new Coordinate(10, 9); return board.FireShot(coordinate); }
public void CoordinateEquality() { var c1 = new Coordinate(5, 10); var c2 = new Coordinate(5, 10); Assert.AreEqual(c1, c2); }
public Ship(ShipType shipType, int numberOfSlots) { ShipType = shipType; _lifeRemaining = numberOfSlots; BoardPositions = new Coordinate[numberOfSlots]; }
public Ship(ShipType shipType, int numberOfSlots) { ShipType = shipType; // ShipType object, set to one of the values of the enum ship type _lifeRemaining = numberOfSlots; BoardPositions = new Coordinate[numberOfSlots]; }