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")); }
public void ExecuteIfCommandElseWhenFalse() { IExpression condition = new ConstantExpression(false); ICommand setXCommand = new SetVariableCommand("a", new ConstantExpression(1)); ICommand setYCommand = new SetVariableCommand("b", new ConstantExpression(2)); IfCommand command = new IfCommand(condition, setXCommand, setYCommand); Context context = new Context(); command.Execute(context); Assert.AreEqual(Undefined.Instance, context.GetValue("a")); Assert.AreEqual(2, context.GetValue("b")); }