Пример #1
0
        public void Shoot_ThrowsShootCellOutOfRangeException(int shootPointX, int shootPointY)
        {
            var shootStrategyAtPoint = new ShootStrategyAtPoint
            {
                ShootPoint = new Point(shootPointX, shootPointY)
            };
            var field = new Field(5, 5);

            void Action() => shootStrategyAtPoint.Shoot(field);

            Assert.Throws <ShootCellOutOfRangeException>(Action);
        }
Пример #2
0
        public void Shoot_OnEmptyCell_ThrowsShootCellCheckedException(int shootPointX, int shootPointY)
        {
            var shootStrategyAtPoint = new ShootStrategyAtPoint
            {
                ShootPoint = new Point(shootPointX, shootPointY)
            };
            var field = new Field(5, 5);

            field.CellsMatrix[shootPointY, shootPointX].CellState = CellState.Empty;

            void Action() => shootStrategyAtPoint.Shoot(field);

            Assert.Throws <ShootCellCheckedException>(Action);
        }
Пример #3
0
        public void Shoot_MissShipCell(int shootPointX, int shootPointY)
        {
            var shootStrategyAtPoint = new ShootStrategyAtPoint
            {
                ShootPoint = new Point(shootPointX, shootPointY)
            };
            var field = new Field(5, 5);

            field.CellsMatrix[shootPointY + 1, shootPointX].CellState = CellState.Ship;

            var shootCell = shootStrategyAtPoint.Shoot(field);


            Assert.True(shootCell.CellState == CellState.Empty);
        }