public void Test_ValidationRule_InvalidPlaceCommandThrowsException(int x, int y, Direction f)
        {
            IToyRobot toyRobot = CreateSut();

            Assert.Throws <Exception>(() => toyRobot.Place(new RobotPosition()
            {
                X = x,
                Y = y,
                F = f
            }));
        }
        public void Test_PlaceCommand_SetsCurrentPosition(int x, int y, Direction f)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x,
                Y = y,
                F = f
            });
            var currentPosition = toyRobot.Report();

            Assert.Equal(x, currentPosition.X);
            Assert.Equal(y, currentPosition.Y);
            Assert.Equal(f, currentPosition.F);
        }
        public void Test_RightCommand_RotatesPerpendicularInRightDirection(int x, int y, Direction currentDirection, Direction expectedDirection)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x,
                Y = y,
                F = currentDirection
            });
            toyRobot.Right();
            var currentPosition = toyRobot.Report();

            Assert.Equal(x, currentPosition.X);
            Assert.Equal(y, currentPosition.Y);
            Assert.Equal(expectedDirection, currentPosition.F);
        }
        public void Test_MoveCommand_OneUnitInCurrentDirection(int x1, int y1, Direction f1, int x2, int y2, Direction f2)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x1,
                Y = y1,
                F = f1
            });
            toyRobot.Move();
            var currentPosition = toyRobot.Report();

            Assert.Equal(x2, currentPosition.X);
            Assert.Equal(y2, currentPosition.Y);
            Assert.Equal(f2, currentPosition.F);
        }
        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);
        }