public void AreCellsAvailable_NullShip_ShouldReturnFalse() { //Arrange var board = new Board(10); var ship = default(Battleship); var helperService = new GameHelperService(); //Act var result = helperService.AreCellsAvailable(board, ship); //Asset Assert.IsFalse(result); }
public void AreCellsAvailable_NullBoard_ShouldReturnFalse() { //Arrange var board = default(Board); var ship = new Battleship() { ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true }; var helperService = new GameHelperService(); //Act var result = helperService.AreCellsAvailable(board, ship); //Asset Assert.IsFalse(result); }
public void AreCellsAvailable_ValidShipSize_EmptyBoard_ShouldReturnTrue() { //Arrange var board = new Board(10); var ship = new Battleship() { ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true }; var helperService = new GameHelperService(); //Act var result = helperService.AreCellsAvailable(board, ship); //Asset Assert.IsTrue(result); }
public void AddBattleShip_ValidShip_EmptyBoard_ShouldReturnTrue() { //Arrange var board = new Board(10); var ship = new Battleship() { ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true }; var helperService = new GameHelperService(); //Act var result = helperService.AddBattleShip(board, ship); var occupiedCells = board.Cells.Where(x => x.IsOccupied == true).ToList(); //Asset Assert.IsTrue(result); Assert.AreEqual(ship.Size, occupiedCells.Count); }
public void AreCellsAvailable_ValidShipSize_BoardOccupied_ShouldReturnFalse() { //Arrange var board = new Board(10); board.Cells.ForEach(x => x.IsOccupied = true); var ship = new Battleship() { ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true }; var helperService = new GameHelperService(); //Act var result = helperService.AreCellsAvailable(board, ship); //Asset Assert.IsFalse(result); }
public void IsAttacSuccessful_ValidBoard_InValidColumn_OutsideBoard_ShouldReturnFalse() { //Arrange var board = new Board(10); board.Cells.Where(x => x.Row == 0 && x.Column == 0).First().IsOccupied = true; int row = 0; int column = 99; var helperService = new GameHelperService(); //Act var result = helperService.IsAttacSuccessful(board, row, column); var hitCells = board.Cells.Where(x => x.IsHit == true).ToList(); //Asset Assert.IsFalse(result); Assert.AreEqual(0, hitCells.Count); }