Exemplo n.º 1
0
        public void Test_PlaceShips()
        {
            BattleShip.BattleShip shp = null;

            m_newBoard.AddBattleShip(shp = new BattleShip.BattleShip(1, 2));

            m_newBoard.PlaceShip(1, 1, shp, Orientation.RHORIZONTAL);

            shp = m_newBoard.IsOccupied(1, 1);

            Assert.IsNotNull(shp);
        }
Exemplo n.º 2
0
        public void Test_OverlapAcrossColumns()
        {
            m_newBoard.AddBattleShip(new BattleShip.BattleShip(1, 3));
            m_newBoard.AddBattleShip(new BattleShip.BattleShip(1, 1));

            Boolean placed = m_newBoard.PlaceShip(2, 2, m_newBoard.GetBattleShip(0), Orientation.RHORIZONTAL);

            Assert.IsTrue(placed);

            placed = m_newBoard.PlaceShip(0, 2, m_newBoard.GetBattleShip(1), Orientation.DVERTICAL);

            Assert.IsTrue(placed);
        }
Exemplo n.º 3
0
        public void Attack_WithOneDestroyed()
        {
            m_newBoard.AddBattleShip(new BattleShip.BattleShip(1, 3));
            m_newBoard.AddBattleShip(new BattleShip.BattleShip(1, 1));

            Boolean placed = m_newBoard.PlaceShip(2, 2, m_newBoard.GetBattleShip(0), Orientation.RHORIZONTAL);

            Assert.IsTrue(m_newBoard.Attack(2, 4));
            Assert.IsTrue(m_newBoard.Attack(2, 2));
            Assert.IsTrue(m_newBoard.Attack(2, 3));

            BattleShip.BattleShip ship = m_newBoard.GetBattleShip(0);
            Assert.IsTrue(ship.IsDestroyed());
        }
Exemplo n.º 4
0
        public void Test_Multiple_1()
        {
            BattleShip.BattleShip shp = null;

            m_newBoard.AddBattleShip(shp = new BattleShip.BattleShip(2, 4));

            Boolean placed = m_newBoard.PlaceShip(2, 5, shp, Orientation.DVERTICAL);

            Assert.IsTrue(placed);

            shp = m_newBoard.IsOccupied(5, 6);

            Assert.IsNotNull(shp);

            m_newBoard.AddBattleShip(shp = new BattleShip.BattleShip(2, 4));

            placed = m_newBoard.PlaceShip(5, 4, shp, Orientation.RHORIZONTAL);

            Assert.IsFalse(placed);

            placed = m_newBoard.PlaceShip(5, 1, shp, Orientation.RHORIZONTAL);

            Assert.IsTrue(placed);

            m_newBoard.AddBattleShip(shp = new BattleShip.BattleShip(1, 7));

            placed = m_newBoard.PlaceShip(1, 7, shp, Orientation.LHORIZONTAL);

            Assert.IsTrue(placed);

            m_newBoard.AddBattleShip(shp = new BattleShip.BattleShip(1, 2));

            placed = m_newBoard.PlaceShip(0, 8, shp, Orientation.UVERTICAL);

            Assert.IsFalse(placed);

            placed = m_newBoard.PlaceShip(1, 4, shp, Orientation.UVERTICAL);

            Assert.IsFalse(placed);

            placed = m_newBoard.PlaceShip(1, 8, shp, Orientation.UVERTICAL);

            Assert.IsTrue(placed);
        }