public void IsDamagedAt_WhenCalledWithInvalidCoordinate_ThrowsException() { var battleship = new Battleship(2, 2); Assert.ThrowsException <IndexOutOfRangeException>( // Before () => battleship.IsDamagedAt(new Coord { X = -1, Y = -1 })); Assert.ThrowsException <IndexOutOfRangeException>( // Off row () => battleship.IsDamagedAt(new Coord { X = 2, Y = 1 })); Assert.ThrowsException <IndexOutOfRangeException>( // After () => battleship.IsDamagedAt(new Coord { X = 2, Y = 2 })); }
public void Should_BeUndamaged_WhenConstructed() { var battleship = new Battleship(4, 1); for (var i = 0; i < 4; i++) { Assert.IsFalse(battleship.IsDamagedAt(new Coord { X = i, Y = 0 })); } }