Esempio n. 1
0
        static void Main(string[] args)
        {
            const string fileName = "BulkDeploy.txt";

            using (var streamReader = File.OpenText(fileName))
            {
                var line = streamReader.ReadLine();

                if (line != null)
                {
                    var   plateau = Plateau.CreatePlateau(line);
                    var   count   = 0;
                    Rover rover   = null;

                    while ((line = streamReader.ReadLine()) != null)
                    {
                        if (count % 2 == 0)
                        {
                            rover = Rover.CreateRover(line);
                            rover.SetPlateau(plateau);
                        }
                        else
                        {
                            rover.ExecuteBatchCmds(line);
                            Console.WriteLine(rover.GetPosition());
                        }

                        count++;
                    }
                }
            }
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Esempio n. 2
0
        public void CreatePlateau_55_CoordinatesEqual55ReturnTrue()
        {
            // Act
            var plateau     = Plateau.CreatePlateau("5 5");
            var coordinates = new Coordinates(5, 5);

            // Assert
            Assert.That(plateau.UpperRight.Y == coordinates.Y && plateau.UpperRight.X == coordinates.X);
        }
Esempio n. 3
0
        public void PreparePlateau(PlateauModel model)
        {
            if (model.ErrorTracer == null)
            {
                _plateaus = Plateau.CreatePlateau(this);

                if (model.UpperRight <= 0 && model.LowerLeft <= 0)
                {
                    _plateaus.ErrorMessage = MessageConstant.PlateauLimitsFail;
                }

                _plateaus.LowerLeft  = model.LowerLeft;
                _plateaus.UpperRight = model.UpperRight;
            }
        }
Esempio n. 4
0
 public HttpResponseMessage DeployRover([FromBody]  RoverConfig roverconfig)
 {
     try
     {
         Rover rover   = null;
         var   plateau = Plateau.CreatePlateau(roverconfig.Plateau);
         rover = Rover.CreateRover(roverconfig.StartPosition);
         rover.SetPlateau(plateau);
         rover.ExecuteBatchCmds(roverconfig.MoveCommands);
         return(Request.CreateResponse(HttpStatusCode.Created, rover.GetPosition()));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message: ex.Message));
     }
 }
Esempio n. 5
0
 public void CreatePlateau_XX_WrongDimensionsExceptionReturnFalse()
 {
     // Act
     Plateau.CreatePlateau("X X");
 }