public void RotateRight(Direction expectedResult, Direction initialdirection)
        {
            var rover = _roverFactory.CreateMarsRover(1, 1, initialdirection);

            _movingService.AssignPlateau(5, 5);
            _movingService.AssignRover(rover);
            _movingService.Rotate("R");
            Assert.AreEqual(rover.Direction, expectedResult);
        }
Пример #2
0
        public ActionResult Post([FromBody] RoverInstructions roverInstructions)
        {
            if (roverInstructions.Instructions == null || roverInstructions.Instructions == string.Empty)
            {
                return(BadRequest("Error: Instructions are empty"));
            }

            var stringBuilder = new StringBuilder();

            _navigationService.AssignPlateau(roverInstructions.PlateauHeight, roverInstructions.PlateauWidth);
            stringBuilder.AppendLine(string.Format("for Plateau ( {0} , {1} )", roverInstructions.PlateauHeight,
                                                   roverInstructions.PlateauWidth));
            stringBuilder.AppendLine("-->" + _navigationService.ReceiveInstructions(roverInstructions.Instructions));
            return(Ok((stringBuilder.ToString())));
        }
 public ActionResult Post([FromForm] RoverFiles file)
 {
     try
     {
         if (file.FormFile == null)
         {
             return(BadRequest("Error: Please upload a File "));
         }
         _navigationService.AssignPlateau(file.PlateauHeight, file.PlateauWidth);
         var instructions  = _fileReaderHelper.ReadInstructionsFile(file.ConvertToByteArray(), file.FileName);
         var stringBuilder = new StringBuilder();
         stringBuilder.AppendLine(string.Format("for Plateau ( {0} , {1} )   File: {2} ", file.PlateauWidth, file.PlateauHeight, file.FileName));
         stringBuilder.Append(_navigationService.ReceiveMultipleInstructions(instructions));
         return(Ok(stringBuilder.ToString()));
     }
     catch (InvalidFileException e)
     {
         return(BadRequest("Error: Invalid File. Please Update a .csv file with 1 column named Instruction"));
     }
 }