public void TakeAttack_Miss() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.TakeAttack(1, 1); Assert.AreEqual("Miss", message); }
public void TakeAttack_Invalid_Range() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.TakeAttack(11, 11); Assert.AreEqual("Row and Column numbers are invalid", message); }
public void TakeAttack_Hit() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.TakeAttack(1, 2); Assert.AreEqual("Hit", message); }
public void TakeAttack_All_Ships_Repeated() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(1, 5, new Battleship(), Direction.Horizontal); message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.AddShip(6, 6, new Submarine(), Direction.Horizontal); message = stateTracker.AddShip(4, 7, new Destroyer(), Direction.Vertical); for (int i = 1; i <= 20; i++) { message = stateTracker.TakeAttack(3, 3); } Assert.AreEqual("Hit", message); }
public void TakeAttack_All_Ships_Sunk_Bruteforce() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(1, 5, new Battleship(), Direction.Horizontal); message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.AddShip(6, 6, new Submarine(), Direction.Horizontal); message = stateTracker.AddShip(4, 7, new Destroyer(), Direction.Vertical); for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { message = stateTracker.TakeAttack(i, j); if (message.Contains("All ships sunk")) { Assert.AreEqual("Hit. All ships sunk", message); break; } } } }
public void TakeAttack_All_Ships_Sunk() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(1, 5, new Battleship(), Direction.Horizontal); message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.AddShip(6, 6, new Submarine(), Direction.Horizontal); message = stateTracker.AddShip(4, 7, new Destroyer(), Direction.Vertical); message = stateTracker.TakeAttack(1, 2); message = stateTracker.TakeAttack(2, 2); message = stateTracker.TakeAttack(3, 2); message = stateTracker.TakeAttack(1, 5); message = stateTracker.TakeAttack(1, 6); message = stateTracker.TakeAttack(1, 7); message = stateTracker.TakeAttack(1, 8); message = stateTracker.TakeAttack(3, 3); message = stateTracker.TakeAttack(4, 3); message = stateTracker.TakeAttack(5, 3); message = stateTracker.TakeAttack(6, 3); message = stateTracker.TakeAttack(7, 3); message = stateTracker.TakeAttack(6, 6); message = stateTracker.TakeAttack(6, 7); message = stateTracker.TakeAttack(6, 8); message = stateTracker.TakeAttack(4, 7); message = stateTracker.TakeAttack(5, 7); Assert.AreEqual("Hit. All ships sunk", message); }