Execute() public method

public Execute ( IContext context ) : void
context IContext
return void
Example #1
0
        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"));
        }
Example #2
0
        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"));
        }