public void BSCanPlaceAllShips() { BattleShips battleShipsTest = new BattleShips(); battleShipsTest.PlaceShip(0, 0, 2, 1, 'A'); battleShipsTest.PlaceShip(0, 1, 2, 1, 'B'); battleShipsTest.PlaceShip(0, 2, 2, 1, 'C'); battleShipsTest.PlaceShip(0, 3, 3, 1, 'D'); battleShipsTest.PlaceShip(0, 4, 3, 1, 'E'); battleShipsTest.PlaceShip(0, 5, 3, 1, 'F'); battleShipsTest.PlaceShip(0, 6, 4, 1, 'G'); //battleShipsTest.PlaceShip(0, 7, 4, 1, 'H'); //battleShipsTest.PlaceShip(0, 8, 5, 1, 'I'); /*char[,] expected = new char[10,10] * { * {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', ' '}, * {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', ' '}, * {' ', ' ', ' ', 'D', 'E', 'F', 'G', 'H', 'I', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', 'G', 'H', 'I', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'I', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, * {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '} * };*/ Assert.AreEqual(true, battleShipsTest.ValidateShipDirection(0, 7, 4, 'e')); Assert.AreEqual(false, battleShipsTest.ValidateShipDirection(0, 7, 4, 'n')); Assert.AreEqual(false, battleShipsTest.ValidateShipDirection(0, 7, 4, 's')); Assert.AreEqual(false, battleShipsTest.ValidateShipDirection(0, 7, 4, 'w')); }
public void BSSuccesfullyPlacedShip() { BattleShips battleShipsTest = new BattleShips(); char[,] expected = new char[10, 10] { { 'A', ' ', ' ', ' ', ' ', ' ', ' ', 'C', 'C', 'C' }, { 'A', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, { 'A', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, { 'A', ' ', ' ', '#', '#', '#', '#', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' }, { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' }, }; //PlaceShip(xKoordinat, yKoordinat, længde, shipdirection) battleShipsTest.PlaceShip(3, 3, 4, 3, '#'); battleShipsTest.PlaceShip(0, 0, 4, 1, 'A'); battleShipsTest.PlaceShip(9, 9, 3, 2, 'B'); battleShipsTest.PlaceShip(0, 9, 3, 4, 'C'); CollectionAssert.AreEqual(expected, battleShipsTest.player[battleShipsTest.battleShipCurrentPlayer].GameBoardMyShips); }