Пример #1
0
        public void Insert(int index, ICommand item)
        {
            var parsedCommand = _toStringParser.ParseCommand(item);

            _commands.Insert(index, item);
            _logger.Write($"Command \"{parsedCommand}\" inserted at \"{index}\"\n");
        }
Пример #2
0
        public void StopParse()
        {
            var command       = new Stop();
            var commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = "stop";

            Assert.AreEqual(result, parsedCommand);
        }
Пример #3
0
        public void CloseConditionParse()
        {
            var command       = new CloseCondition();
            var commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = "endif";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #4
0
        private string CommandsToString(ICommand[] commands)
        {
            var builder          = new StringBuilder();
            var commandsToString = new CommandToStringParser();

            for (int num = 0; num < commands.Length; num++)
            {
                builder.AppendLine($"{num}) " + commandsToString.ParseCommand(commands[num]));
            }
            return(builder.ToString());
        }
Пример #5
0
        public void ConditionParse()
        {
            const string conditionName = "condition";
            var          command       = new Condition(conditionName);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = $"if {conditionName} then";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #6
0
        public void IntParse()
        {
            const string name          = "commandName";
            var          command       = new NewInt(name);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim('\n', ' ', '\r');
            var desiredResult = $"int {name}";

            Assert.AreEqual(parsedCommand, desiredResult);
        }
Пример #7
0
        public void PrintParse()
        {
            const string variableName  = "somekindofvariable";
            var          command       = new Print(variableName);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = $"print {variableName}";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #8
0
        public void GetRandomParse()
        {
            const string targetName    = "target";
            const string maxValueName  = "cat";
            var          command       = new GetRandom(targetName, maxValueName);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim('\n', ' ', '\r');
            var result        = $"{targetName} = random {maxValueName}";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #9
0
        public void CloneValueParse()
        {
            const string targetName    = "target";
            const string sourceName    = "source";
            var          command       = new CloneValue(targetName, sourceName);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = $"{targetName} = {sourceName}";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #10
0
        public void GetStateParse()
        {
            const string targetName    = "target";
            const int    direction     = 2;
            var          command       = new GetState(targetName, direction);
            var          commandParser = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = $"{targetName} = getState {direction}";

            Assert.AreEqual(parsedCommand, result);
        }
Пример #11
0
        public void MinusParse()
        {
            const string targetName       = "targetName";
            const string firstSourceName  = "firstSourseName";
            const string secondSourceName = "secondSourceName";
            var          command          = new Minus(targetName, firstSourceName, secondSourceName);
            var          commandParser    = new CommandToStringParser();

            var parsedCommand = commandParser.ParseCommand(command).Trim(' ', '\n', '\r');
            var result        = $"{targetName} = {firstSourceName} - {secondSourceName}";

            Assert.AreEqual(parsedCommand, result);
        }