private string ExecSimulator(string[] simulatorArguments)
        {
            if (!(simulatorArguments.First().Contains((ToyCommandEnum.Place).ToString())))
            {
                throw new Exception("Error: Please give Place as first value");
            }
            foreach (string command in simulatorArguments)
            {
                ToyCommandEnum toyCommand;
                if (command.Contains((ToyCommandEnum.Place).ToString()))
                {
                    toyCommand = ToyCommandEnum.Place;
                }
                else
                {
                    toyCommand = (ToyCommandEnum)Enum.Parse(typeof(ToyCommandEnum), command);
                }

                switch (toyCommand)
                {
                case ToyCommandEnum.Place:
                    string[]    placeCommand             = Regex.Replace(command, "Place ", "", RegexOptions.IgnoreCase).Split(',');
                    int         toyPosition_XCoordinate  = Convert.ToInt32(placeCommand[0]);
                    int         toyPosition_YCoordainate = Convert.ToInt32(placeCommand[1]);
                    ToyPosition position           = new ToyPosition(toyPosition_XCoordinate, toyPosition_YCoordainate);
                    string      toyFacingDirection = placeCommand[2].ToString();
                    if (toyboard.CheckPositionAvailability(position))
                    {
                        toyRobotPlacement.PlaceToy(position, (ToyFacingDirectionEnum)Enum.Parse(typeof(ToyFacingDirectionEnum), toyFacingDirection));
                    }
                    break;

                case ToyCommandEnum.Move:
                    var newPosition = toyRobotPlacement.GetNextAvailablePosition();
                    if (toyboard.CheckPositionAvailability(newPosition))
                    {
                        toyRobotPlacement.Position = newPosition;
                    }
                    break;

                case ToyCommandEnum.Left:
                    toyRobotPlacement.Rotate(ToyCommandEnum.Left);
                    break;

                case ToyCommandEnum.Right:
                    toyRobotPlacement.Rotate(ToyCommandEnum.Right);
                    break;

                case ToyCommandEnum.Report:
                    string report = string.Format("Output: {0},{1},{2}", toyRobotPlacement.Position.X_Coordinate,
                                                  toyRobotPlacement.Position.Y_Coordinate, toyRobotPlacement.Direction.ToString().ToUpper());
                    return(report);
                }
            }
            return(string.Empty);
        }
        public void TestBoardAvailabilityInValid()
        {
            // arrange
            IToyBoardService toyBoardService = new ToyBoardService(5, 5);
            ToyPosition      toyposition     = new ToyPosition(7, 8);

            // act
            var result = toyBoardService.CheckPositionAvailability(toyposition);

            // assert
            Assert.IsFalse(result);
        }
        public void TestValidPositionDirection()
        {
            // arrange
            var toyPosition = new ToyPosition(3, 3);
            var toyRobot    = new ToyRobotPlacementService();

            // act
            toyRobot.PlaceToy(toyPosition, ToyFacingDirectionEnum.North);

            // assert
            Assert.AreEqual(3, toyRobot.Position.X_Coordinate);
            Assert.AreEqual(3, toyRobot.Position.Y_Coordinate);
            Assert.AreEqual(ToyFacingDirectionEnum.North, toyRobot.Direction);
        }
        //Function to determine the next available position of the toy
        public ToyPosition GetNextAvailablePosition()
        {
            var newPosition = new ToyPosition(Position.X_Coordinate, Position.Y_Coordinate);

            switch (Direction)
            {
            case ToyFacingDirectionEnum.North:
                ++newPosition.Y_Coordinate;
                break;

            case ToyFacingDirectionEnum.East:
                ++newPosition.X_Coordinate;
                break;

            case ToyFacingDirectionEnum.South:
                --newPosition.Y_Coordinate;
                break;

            case ToyFacingDirectionEnum.West:
                --newPosition.X_Coordinate;
                break;
            }
            return(newPosition);
        }
 public void PlaceToy(ToyPosition position, ToyFacingDirectionEnum direction)
 {
     this.Position  = position;
     this.Direction = direction;
 }
 // Function checks if position is available within the limits
 public bool CheckPositionAvailability(ToyPosition position)
 {
     return(position.X_Coordinate <= Columns_Y && position.X_Coordinate >= 0 &&
            position.Y_Coordinate <= Rows_X && position.Y_Coordinate >= 0);
 }