Beispiel #1
0
        public void Null_Position_Return_False()
        {
            int                tableLength       = 5;
            int                tableWidth        = 5;
            Position           currentPosition   = null;
            IPositionValidator positionValidator = new PositionValidator(tableLength, tableWidth);

            bool isValid = positionValidator.Validate(currentPosition);

            Assert.That(!isValid);
        }
Beispiel #2
0
        public void Move(int [,] galaxyMatrix, int rows, int cols)
        {
            var positionValidator = new PositionValidator();

            while (Row >= 0 && Col < galaxyMatrix.GetLength(1))
            {
                if (positionValidator.Validate(Row, Col, rows, cols))
                {
                    CollectedStarsValue += galaxyMatrix[Row, Col];
                }

                Col++;
                Row--;
            }
        }
Beispiel #3
0
        public void Move(int[,] galaxyMatrix, int rows, int cols)
        {
            var positionValidator = new PositionValidator();

            while (Row >= 0 && Col >= 0)
            {
                if (positionValidator.Validate(Row, Col, rows, cols))
                {
                    galaxyMatrix[Row, Col] = 0;
                }

                Row--;
                Col--;
            }
        }
Beispiel #4
0
        public void Invalid_Positions_Return_False(int xPosition, int yPosition)
        {
            int      tableLength     = 5;
            int      tableWidth      = 5;
            Position currentPosition = new Position
            {
                Facing = Direction.NORTH,
                X      = xPosition,
                Y      = yPosition
            };
            IPositionValidator positionValidator = new PositionValidator(tableLength, tableWidth);

            bool isValid = positionValidator.Validate(currentPosition);

            Assert.That(!isValid);
        }
        public SaveResult <PositionEntryModel> Save(PositionDTO positionDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = positionValidator.Validate(positionDTO);
            bool success             = false;
            PositionEntryModel model = null;

            if (validationResult.IsValid)
            {
                success = true;
                Update(positionDTO, dateStamp);
                Db.SaveChanges();
                model = positionEntryDataProvider.Get(positionDTO.Position_PK);
            }

            return(new SaveResult <PositionEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }