Exemplo n.º 1
0
        public void DestroyMast_When_DestroyAllFiveTimes_Then_BattleshipResponseIsSunk()
        {
            IBattleField battlefield = new Battlefield(10);
            Battleship   battleship  = new Battleship(5);

            battleship.TryLoadBattleshipToTheBattlefield(battlefield, 2, 2, Direction.Rigth);

            ShipResponse shipResponse = battleship.DestroyMast(3, 2);

            Assert.AreEqual(shipResponse, ShipResponse.Hit);

            battleship = new Battleship(5);
            battleship.TryLoadBattleshipToTheBattlefield(battlefield, 2, 2, Direction.Rigth);
            shipResponse = battleship.DestroyMast(2, 5);
            Assert.AreEqual(shipResponse, ShipResponse.Miss);

            shipResponse = battleship.DestroyMast(20, 20);
            Assert.AreEqual(shipResponse, ShipResponse.Miss);

            shipResponse = battleship.DestroyMast(2, 2);
            Assert.AreEqual(shipResponse, ShipResponse.Hit);
            shipResponse = battleship.DestroyMast(3, 2);
            Assert.AreEqual(shipResponse, ShipResponse.Hit);
            shipResponse = battleship.DestroyMast(4, 2);
            Assert.AreEqual(shipResponse, ShipResponse.Hit);
            shipResponse = battleship.DestroyMast(5, 2);
            Assert.AreEqual(shipResponse, ShipResponse.Hit);
            shipResponse = battleship.DestroyMast(6, 2);

            Assert.AreEqual(shipResponse, ShipResponse.Sunk);
        }
Exemplo n.º 2
0
        public void DestroyMast_When_TryDestroyMastOutOfTheShip_Then_BattleshipResponseIsMiss()
        {
            IBattleField battlefield = new Battlefield(10);
            Battleship   battleship  = new Battleship(5);

            battleship.TryLoadBattleshipToTheBattlefield(battlefield, 2, 2, Direction.Rigth);

            ShipResponse shipResponse = battleship.DestroyMast(3, 2);

            Assert.AreEqual(shipResponse, ShipResponse.Hit);

            battleship = new Battleship(5);
            battleship.TryLoadBattleshipToTheBattlefield(battlefield, 2, 2, Direction.Rigth);
            shipResponse = battleship.DestroyMast(2, 5);
            Assert.AreEqual(shipResponse, ShipResponse.Miss);

            shipResponse = battleship.DestroyMast(20, 20);
            Assert.AreEqual(shipResponse, ShipResponse.Miss);
        }