Exemple #1
0
        public void ShouldNotAddShipWhichHaveInvalidLocations()
        {
            // Arrange
            int         width  = 5;
            int         height = 5;
            BattleBoard board  = new BattleBoard(width, height);

            // Act
            board.OnBoardShips(new Ship(), "Q2");
            board.OnBoardShips(new Ship(), "P2");
            // Assert
            Assert.IsTrue(board.HaveAllShipDestroyed());
        }
Exemple #2
0
        public void ShouldAddShipWhichHaveValidLocations()
        {
            // Arrange
            int         width  = 5;
            int         height = 5;
            BattleBoard board  = new BattleBoard(width, height);

            // Act
            board.OnBoardShips(new Ship(), "A1");
            board.OnBoardShips(new Ship(), "E3");
            // Assert
            Assert.IsFalse(board.HaveAllShipDestroyed());
        }
Exemple #3
0
        public void ShouldCleanValidShipFields()
        {
            // Arrange
            int         width  = 5;
            int         height = 5;
            BattleBoard board  = new BattleBoard(width, height);

            // Act
            board.OnBoardShips(new Ship(), "A1");
            board.OnBoardShips(new Ship(), "E3");
            board.ClearShipField("A1");
            board.ClearShipField("E3");
            // Assert
            Assert.IsTrue(board.HaveAllShipDestroyed());
        }
Exemple #4
0
        public void ShouldNotAddShipWhenShipIsNull()
        {
            // Arrange
            int         width  = 45;
            int         height = 34;
            BattleBoard board  = new BattleBoard(width, height);

            // Act
            board.OnBoardShips(null, "A1");
            // Assert
            Assert.IsTrue(board.HaveAllShipDestroyed());
        }
Exemple #5
0
        public void ShouldReturnValidShipFieldsWhenCordinatesAreValid()
        {
            // Arrange
            int         width  = 5;
            int         height = 5;
            BattleBoard board  = new BattleBoard(width, height);

            // Act
            board.OnBoardShips(new Ship(), "A1");
            var a = board.GetCordinates("A1");

            // Assert
            Assert.IsTrue(a.Shot() == ShotResult.DESTROYED);
        }