public void ProcessSimulation_Place()
        {
            //arrage
            var input          = "Place 1,2,North";
            var expectedReport = "Output: 1,2,North";

            //act
            _robotSimulator.ProcessSimulation(input);
            var report = _toyRobot.GetCurrentReport();

            //assert
            Assert.AreEqual(expectedReport, report);
        }
Exemplo n.º 2
0
        public string ProcessSimulation(string input)
        {
            var command = _inputHelper.GetCommand(input);

            switch (command)
            {
            case Commands.Place:
                var position = _inputHelper.GetPosition(input);
                if (_tableTop.IsValid(position))
                {
                    var direction = _inputHelper.GetDirection(input);
                    _toyRobot.Place(direction, position);
                }
                break;

            case Commands.Move:
                var newPosition = _toyRobot.GetNewPosition();
                if (_tableTop.IsValid(newPosition))
                {
                    _toyRobot.SetNewPosition(newPosition);
                }
                break;

            case Commands.Left:
                _toyRobot.Rotate(Commands.Left);
                break;

            case Commands.Right:
                _toyRobot.Rotate(Commands.Right);
                break;

            case Commands.Report:
                return(_toyRobot.GetCurrentReport());
            }
            return(string.Empty);
        }