public void CreateAndExecuteCompositeCommand() { IEnumerable<ICommand> commands = new ICommand[] { new SetVariableCommand("a", new ConstantExpression(1)), new SetVariableCommand("b", new ConstantExpression(2)) }; CompositeCommand command = new CompositeCommand(commands); Context context = new Context(); Assert.IsNotNull(command.Commands); Assert.AreEqual(2, command.Commands.Count()); Assert.AreEqual(2, command.Execute(context)); Assert.AreEqual(1, context.GetValue("a")); Assert.AreEqual(2, context.GetValue("b")); }
private static void EvaluateCommands(string text, Context context) { Parser parser = new Parser(text); var result = parser.ParseCommands(); var command = new CompositeCommand(result); command.Execute(context); }