public void TestDefaults() { var game = new BattleshipGameBoard(); Assertions.AssertThat(game.SizeX).IsEqualTo(10); Assertions.AssertThat(game.SizeY).IsEqualTo(10); }
public void TestCustomGameSize() { var game = new BattleshipGameBoard(2, 3); Assertions.AssertThat(game.SizeX).IsEqualTo(2); Assertions.AssertThat(game.SizeY).IsEqualTo(3); }
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 TestGameOverWithUndamagedFleet() { var game = new BattleshipGameBoard() .PlaceShip(new Destroyer(), 0, 0, Facing.Horizontal) .PlaceShip(new Carrier(), 0, 1, Facing.Vertical); Assertions.AssertThat(game.GameOver).IsFalse(); }
public void TestPlaceShipsNoCollision() { var game = new BattleshipGameBoard(); game.PlaceShip(new Carrier(), 0, 0, Facing.Horizontal); game.PlaceShip(new Cruiser(), 1, 1, Facing.Horizontal); }
public void TestAttackTwice() { var game = new BattleshipGameBoard(); game.Attack(0, 0); Assertions.AssertThat(() => game.Attack(0, 0)) .ThrowsException(typeof(ArgumentException)) .WithMessageContaining("already"); }
public void TestPlaceShipPerpendicularCollision() { var game = new BattleshipGameBoard(); game.PlaceShip(new Carrier(), 0, 1, Facing.Horizontal); Assertions.AssertThat(() => { game.PlaceShip(new Cruiser(), 1, 0, Facing.Vertical); }) .ThrowsException(typeof(ArgumentException)) .WithMessageContaining("collide"); }
public void TestGameGridIsInitialized() { var game = new BattleshipGameBoard(); for (int x = 0; x < game.SizeX; x++) { for (int y = 0; y < game.SizeY; y++) { var cell = game.Grid[x, y]; Assertions.AssertThat(cell).IsFalse(); } } }
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(); }
public void TestGameOverWithNoFleet() { var game = new BattleshipGameBoard(); Assertions.AssertThat(game.GameOver).IsFalse(); }