public void ExecuteForEachCommand() { IExpression addToX = new ArithmeticBinaryExpression(ArithmeticOperator.Add, new VariableExpression("b"), new VariableExpression("a")); ICommand setX = new SetVariableCommand("a", addToX); IExpression values = new ConstantExpression(new int [] { 1, 2, 3 }); ForEachCommand foreachcmd = new ForEachCommand("b", values, setX); Context context = new Context(); context.SetValue("a", 0); foreachcmd.Execute(context); Assert.AreEqual(6, context.GetValue("a")); }
public void ExecuteForEachCommand() { IExpression addToX = new ArithmeticBinaryExpression(ArithmeticOperator.Add, new VariableExpression("y"), new VariableExpression("x")); ICommand setX = new SetVariableCommand("x", addToX); IExpression values = new ConstantExpression(new int [] { 1, 2, 3 }); ForEachCommand foreachcmd = new ForEachCommand("y", values, setX); BindingEnvironment environment = new BindingEnvironment(); environment.SetValue("x", 0); foreachcmd.Execute(environment); Assert.AreEqual(6, environment.GetValue("x")); }