Пример #1
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Toy Robot (Type 'help' to show the list of commands)");
            Console.ResetColor();

            Toy robot = new Robot(5,0); // 5 X 5 table size
            ToyArgs inputArgs = null;

            for (; ; )
            {
                string inputCommand = GetInput();

                if (string.Equals("exit", inputCommand, StringComparison.CurrentCultureIgnoreCase) ||
                string.Equals("quit", inputCommand, StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }
                else if (string.Equals("help", inputCommand, StringComparison.CurrentCultureIgnoreCase))
                {
                    DisplayHelpInstructions();
                }
                else
                {
                    //ProcessCommand(inputCommand, robot, inputArgs);
                    ProcessCommand(inputCommand, robot);
                }
            }
        }
Пример #2
0
        public void PorcessCorrectActionSeq(CommandSequences cmdSeq)
        {
            Toy robot = new Robot(5, 0);
            bool isSuccessful = false;
            string message = string.Empty;

            foreach (string command in cmdSeq.Commands)
            {
                isSuccessful = CommandProcessor.ProcessCommand(robot, command, out message);
                if (isSuccessful)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            Assert.AreEqual(cmdSeq.ResultMessage.ToLower(), message.ToLower());
            Assert.AreEqual(cmdSeq.IsSuccessful, isSuccessful);
        }