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); }
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--; } }
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--; } }
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 }); }