public void TestExecutingAnInteractiveSimulatorUsingSensitiveByCommandStringShouldReturnRobotIsNotPlaced()
        {
            // Arrange
            uint width                = 5;
            uint height               = 5;
            var  table                = new Table(width, height);
            var  toyRobot             = new ToyRobot(table);
            var  interactiveSimulator = new InteractiveSimulator(toyRobot);

            var commandStringSeparator = " ";
            var ignoreCase             = false;
            var commandList            = new List <string>
            {
                "place 1,2,NORTH", // TEST KEY: place is sensitive, so it will always return validation is false before executing command
                "REPORT"
            };
            var commandString = string.Join(commandStringSeparator, commandList);

            //Assert
            Assert.NotNull(interactiveSimulator);

            //ACT
            interactiveSimulator.Execute(commandString, new[] { commandStringSeparator }, ignoreCase);

            // Assert
            Assert.False(toyRobot.IsPlaced);// no PLACE Command, so it will return false obviously
            Assert.False(toyRobot.X.HasValue);
            Assert.False(toyRobot.Y.HasValue);
            Assert.False(toyRobot.Direction.HasValue);
        }
        public void TestExecutingAnInteractiveSimulatorByCommandStringShouldReturnCorrectResult()
        {
            // Arrange
            uint width                = 5;
            uint height               = 5;
            var  table                = new Table(width, height);
            var  toyRobot             = new ToyRobot(table);
            var  interactiveSimulator = new InteractiveSimulator(toyRobot);

            var commandStringSeparator = " ";
            var ignoreCase             = true;
            var commandList            = new List <string>
            {
                "PLACE 1,2,NORTH MOVE",
                "MOVE1",          // (Test key) this command shouldn't execute
                "MOVE RIGHT",
                "PLACE 0,0,EAST", // using new place, ignoring all of previous actions
                "MOVE LEFT REPORT"
            };
            var commandString = string.Join(commandStringSeparator, commandList);

            //Assert
            Assert.NotNull(interactiveSimulator);

            //ACT
            interactiveSimulator.Execute(commandString, new[] { commandStringSeparator }, ignoreCase);

            var expectX         = 1;
            var expectY         = 0;
            var expectDirection = Direction.NORTH;

            Assert.True(toyRobot.X == expectX && toyRobot.Y == expectY && toyRobot.Direction == expectDirection);
        }
        /// <summary>
        /// this main function is running interactive simulator
        /// </summary>
        private static void RunInteractiveSimulator()
        {
            // initializing a toy robot in the origin (0,0) facing to North
            var toyRobot             = new ToyRobot(new Table(TableWidth, TableHeight));
            var interactiveSimulator = new InteractiveSimulator(toyRobot);

            // showing description text
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("These are valid command in the interactive mode");
            Console.WriteLine("PLACE x,y,f");
            Console.ResetColor();
            Console.WriteLine("- Where x and y is coordinates and f (facing) must be either NORTH, SOUTH, WEST or EAST");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("MOVE");
            Console.ResetColor();
            Console.WriteLine("- Will move the robot one unit in current direct");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("LEFT");
            Console.ResetColor();
            Console.WriteLine("- Will rotate the robot 90 degrees to the left");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("RIGHT");
            Console.ResetColor();
            Console.WriteLine("- Will rotate the robot 90 degrees to the right");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("REPORT");
            Console.ResetColor();
            Console.WriteLine("- The robot will say the current position and facing direction");

            Console.WriteLine();
            Console.WriteLine("--------------------------------------------Constraints--------------------------------------------------------");
            Console.WriteLine();
            Console.WriteLine("- The toy robot must not fall off the table during movement. This also includes the initial placement of the toy robot");
            Console.WriteLine("- Any move that would cause the robot to fall must be ignored");
            Console.WriteLine();
            Console.WriteLine("---------------------------------------------------------------------------------------------------------------");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("--------------------------------------------Sample command-----------------------------------------------------");
            Console.WriteLine();
            Console.WriteLine("PLACE 1,1,NORTH MOVE MOVE RIGHT REPORT");
            Console.WriteLine("PLACE 1,2,NORTH MOVE MOVE RIGHT REPORT PLACE 3,2,EAST REPORT");
            Console.WriteLine("PLACE 2,3,NORTH MOVE MOVE LEFT PLACE 0,0,EAST REPORT");
            Console.WriteLine("");
            Console.WriteLine("Or you can just one by one input then press enter");
            Console.WriteLine("PLACE 1,1,NORTH");
            Console.WriteLine("MOVE");
            Console.WriteLine("RIGHT");
            Console.WriteLine("REPORT");
            Console.WriteLine();
            Console.WriteLine("---------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("");
            Console.WriteLine($"Now you have a table size of {toyRobot.Table?.Width ?? 0} units x {toyRobot.Table?.Height ?? 0} units to play with... It's time to try some commands or you can input 'q' to quit in anytime");
            Console.ResetColor();
            Console.WriteLine("");

            while (true)
            {
                var commandString = Console.ReadLine();

                // if user wanna quit in the cmd
                if (string.Equals(commandString, "q", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(commandString, "quit", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(commandString, "exit", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                interactiveSimulator.Execute(commandString, CmdLineStringSeparator, IgnoreCase);
            }
        }