Пример #1
0
        public void BattleGrid_AddShip_WhenFreePosition_Success()
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            // Act and assert
            bg.AddShip(new Ship(Orientation.Horizontal, 4, 1, 1));
            bg.AddShip(new Ship(Orientation.Vertical, 3, 1, 3));
        }
Пример #2
0
        public void BattleGrid_AddShip_WhenOccupiedPosition_ThrowsException()
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            bg.AddShip(new Ship(Orientation.Horizontal, 4, 1, 1));

            // Assert
            Assert.Throws <OccupiedPositionException>(() => bg.AddShip(new Ship(Orientation.Horizontal, 3, 1, 1)));
        }
Пример #3
0
        public void BattleGrid_AddShip_WhenLenghtAndVerticalPositionSumOutOfRange_ThrowsException()
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            // Assert
            Assert.Throws <OutOfRangePositionException>(() =>
                                                        bg.AddShip(new Ship(Orientation.Vertical, 2, 9, 9)));
        }
Пример #4
0
        public void BattleGrid_AttackShip_WhenOccupiedPosition_ReturnsTrue()
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            bg.AddShip(new Ship(Orientation.Horizontal, 2, 2, 2));

            // Act and assert
            Assert.IsTrue(bg.AttackShip(2, 2));
        }
Пример #5
0
        public void BattleGrid_CheckPositionOreolIsFree_WhenBorder_Success([Values(0, 9)] int xPos, [Values(0, 9)] int yPos)
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            // Act
            bg.AddShip(new Ship(Orientation.Horizontal, 1, 0, 0));

            // Assert
            bg.CheckPositionIsFree(xPos, yPos);
        }
Пример #6
0
        public void BattleGrid_CheckPositionIsFree_WhenOccupiedByOneDecker_ReturnsFalse()
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            // Act
            bg.AddShip(new Ship(Orientation.Horizontal, 1, 2, 2));

            // Assert
            Assert.IsFalse(bg.CheckPositionIsFree(2, 2));
        }
Пример #7
0
        public void BattleGrid_CheckPositionOreolIsFree_WhenOccupiedByVerticalTwoDecker_ReturnsFalse([Values(1, 2, 3)] int xPos, [Values(1, 2, 3, 4)] int yPos)
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            // Act
            bg.AddShip(new Ship(Orientation.Vertical, 2, 2, 2));

            // Assert
            Assert.IsFalse(bg.CheckPositionIsFree(xPos, yPos));
        }
Пример #8
0
        public void BattleGrid_CheckPositionOreolIsFree_WhenOccupiedByOneDecker_ReturnsFalse([Values(1, 2, 3)] int xPos, [Values(1, 2, 3)] int yPos)
        {
            // Arrange
            BattleGridBase bg = new BattleGridBase();

            Orientation orientation = Orientation.Horizontal;
            int         length      = 1;
            int         x           = 2;
            int         y           = 2;

            // Act
            bg.AddShip(new Ship(Orientation.Horizontal, length, x, y));

            // Assert
            Assert.IsFalse(bg.CheckPositionIsFree(xPos, yPos));
        }