Пример #1
0
        public void SpliteSingleCommandTest()
        {
            var result = commandSplitter.SplitCommands("sample meaningless command");

            Assert.AreEqual(new string[] { "sample meaningless command" }, result);

            Assert.Pass();
        }
        public void Run()
        {
            string nextLine;

            string[] previousResults;

            SendDesctiptionMessage();

            while (true)
            {
                nextLine        = logger.Read();
                previousResults = new string[0];
                bool cancelNextOutput = false;

                var CommandStrings = commandSplitter.SplitCommands(nextLine.Replace("=", " = "));

                foreach (var command in CommandStrings)
                {
                    var splittedCommand = commandParser.SplitCommand(command.Trim()).Concat(previousResults).ToArray();
                    try
                    {
                        cancelNextOutput = variableManager.ReplaceVariables(splittedCommand);
                    }
                    catch (Exception ex)
                    {
                        cancelNextOutput = true;
                        logger.Log(ex.Message);
                    }

                    if (cancelNextOutput)
                    {
                        previousResults = new string[0];
                    }
                    else
                    {
                        previousResults = commandExecutor.Execute(splittedCommand);
                    }
                }
                foreach (var argument in previousResults)
                {
                    logger.Log(argument + Environment.NewLine);
                }
                logger.Log(Environment.NewLine);
            }
        }