Example #1
0
        public bool Execute(IEnumerable <ICommand> parsedCommands, IExecutorToolset executorToolset)
        {
            _variables  = new Dictionary <string, int?>();
            _console    = new StringBuilder();
            _conditions = new Stack <bool>();
            _conditions.Push(true);
            _stop            = false;
            _isExecutable    = true;
            _executorToolset = executorToolset;

            foreach (var parsedCommand in parsedCommands)
            {
                Execute(parsedCommand);
                if (!_isExecutable)
                {
                    break;
                }
            }
            if (_conditions.Count > 1)
            {
                _isExecutable = false;
            }

            return(_isExecutable);
        }
Example #2
0
        protected void Check(string commands, IExecutorToolset executorToolset, params int[] values)
        {
            var parsedCommands = new Parser().ProcessCommands(commands).ToArray();
            var output =
                new Executor().Execute(parsedCommands, executorToolset)
                    .Replace("\r\n", "\n")
                    .Split('\n')
                    .Where(item => !string.IsNullOrEmpty(item))
                    .Select(int.Parse)
                    .ToList();

            Assert.AreEqual(values.Count(), output.Count());

            for (var i = 0; i < values.Count(); i++)
            {
                Assert.AreEqual(values[i], output[i]);
            }
        }
Example #3
0
        protected void Check(string commands, IExecutorToolset executorToolset, params int[] values)
        {
            var parsedCommands = new Parser().ProcessCommands(commands).ToArray();
            var output         =
                new Executor().Execute(parsedCommands, executorToolset)
                .Replace("\r\n", "\n")
                .Split('\n')
                .Where(item => !string.IsNullOrEmpty(item))
                .Select(int.Parse)
                .ToList();

            Assert.AreEqual(values.Count(), output.Count());

            for (var i = 0; i < values.Count(); i++)
            {
                Assert.AreEqual(values[i], output[i]);
            }
        }
Example #4
0
        public string Execute(IEnumerable <ICommand> parsedCommands, IExecutorToolset executorToolset)
        {
            _variables  = new Dictionary <string, int?>();
            _console    = new StringBuilder();
            _conditions = new Stack <bool>();
            _conditions.Push(true);
            _stop = false;

            _executorToolset = executorToolset;

            foreach (var parsedCommand in parsedCommands)
            {
                if (_stop)
                {
                    break;
                }

                Execute(parsedCommand);
            }

            return(_console.ToString());
        }
Example #5
0
        public string Execute(IEnumerable<ICommand> parsedCommands, IExecutorToolset executorToolset)
        {
            _variables = new Dictionary<string, int?>();
            _console = new StringBuilder();
            _conditions = new Stack<bool>();
            _conditions.Push(true);
            _stop = false;

            _executorToolset = executorToolset;

            foreach (var parsedCommand in parsedCommands)
            {
                if (_stop) break;

                Execute(parsedCommand);
            }

            return _console.ToString();
        }
Example #6
0
        public bool Execute(IEnumerable<ICommand> parsedCommands, IExecutorToolset executorToolset)
        {
            _variables = new Dictionary<string, int?>();
            _console = new StringBuilder();
            _conditions = new Stack<bool>();
            _conditions.Push(true);
            _stop = false;
            _isExecutable = true;
            _executorToolset = executorToolset;

            foreach (var parsedCommand in parsedCommands)
            {
                Execute(parsedCommand);
                if (!_isExecutable)
                    break;
            }
            if (_conditions.Count > 1) _isExecutable = false;

            return _isExecutable;
        }