public void Robot_PlacedAndTurnedRight_ReportsCorrectPosition()
        {
            var robot = new Robot();

            robot.Place(1, 1, Facing.North);
            robot.Right();
            Assert.AreEqual("1,1,EAST", robot.Report());
        }
示例#2
0
        /// <summary>
        /// Sends incoming command to robot.
        /// </summary>
        /// <param name="userInput">command for robot</param>
        /// <returns></returns>
        public string ExecuteSingleCommand(string userInput)
        {
            try
            {
                string           output    = userInput;
                CommandArguments arguments = new CommandArguments();
                if (ParseCommand(userInput, arguments))
                {
                    switch (arguments.Instruction)
                    {
                    case Command.PLACE:
                        _robot.Place(arguments.X, arguments.Y, arguments.Face);
                        break;

                    case Command.MOVE:
                        _robot.Move();
                        break;

                    case Command.LEFT:
                        _robot.Left();
                        break;

                    case Command.RIGHT:
                        _robot.Right();
                        break;

                    case Command.REPORT:
                        output = _robot.Report();
                        Console.WriteLine(output);
                        break;

                    default:
                        break;
                    }
                }
                return(output);
            }
            catch (Exception)
            {
                throw;
            }
        }