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); }
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]); } }
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()); }
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(); }
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; }