public void Execute(IContext context)
{
object result = this.condition.Evaluate(context);
if (Predicates.IsTrue(result))
this.thenCommand.Execute(context);
else if (this.elseCommand != null)
this.elseCommand.Execute(context);
}
public void ExecuteIfCommandWhenTrue() { IExpression condition = new ConstantExpression(true); ICommand setCommand = new SetVariableCommand("a", new ConstantExpression(1)); IfCommand command = new IfCommand(condition, setCommand); Context context = new Context(); command.Execute(context); Assert.AreEqual(1, context.GetValue("a")); }