示例#1
0
        private static void EnterCommand()
        {
            Console.WriteLine();
            Console.Write("Please enter command, followed by enter: ");

            var input = Console.ReadLine();

            var command = _commandParser.Parse(input);

            if (command != null)
            {
                try
                {
                    _rover.AddCommand(command);

                    _flashMessage = FlashMessage.Success("Command added successfully");
                }
                catch (Exception ex)
                {
                    _flashMessage = FlashMessage.Error(ex.Message);
                }
            }
            else
            {
                _flashMessage = FlashMessage.Warning("Invalid command");
            }
        }
示例#2
0
        public void AddCommand_CantAddMoreThanFive()
        {
            _rover.AddCommand(new MoveCommand(50));
            _rover.AddCommand(new TurnCommand(TurnDirection.Left));
            _rover.AddCommand(new MoveCommand(23));
            _rover.AddCommand(new TurnCommand(TurnDirection.Left));
            _rover.AddCommand(new MoveCommand(4));

            Assert.Throws <CommandQueueDepthExceeded>(() => _rover.AddCommand(new TurnCommand(TurnDirection.Left)));
        }