public void TestAttackTwice() { var game = new BattleshipGameBoard(); game.Attack(0, 0); Assertions.AssertThat(() => game.Attack(0, 0)) .ThrowsException(typeof(ArgumentException)) .WithMessageContaining("already"); }
public void TestAttackHit() { var game = new BattleshipGameBoard() .PlaceShip(new Destroyer(), 0, 0, Facing.Horizontal) .PlaceShip(new Carrier(), 0, 1, Facing.Vertical); Assertions.AssertThat(game.Attack(0, 0).Hit).IsTrue(); }
public void TestGameOverWithSunkFleet() { var game = new BattleshipGameBoard() .PlaceShip(new Destroyer(), 0, 0, Facing.Horizontal) .PlaceShip(new Carrier(), 1, 1, Facing.Vertical); game.Attack(0, 0); game.Attack(1, 0); game.Attack(1, 1); game.Attack(1, 2); game.Attack(1, 3); game.Attack(1, 4); game.Attack(1, 5); Assertions.AssertThat(game.GameOver).IsTrue(); }