AjScript.Commands.Tests.CommandsTests.ExecuteWhileCommand C# (CSharp) Метод

ExecuteWhileCommand() приватный Метод

private ExecuteWhileCommand ( ) : void
Результат void
        public void ExecuteWhileCommand()
        {
            IExpression incrementX = new ArithmeticBinaryExpression(ArithmeticOperator.Add, new ConstantExpression(1), new VariableExpression("a"));
            IExpression decrementY = new ArithmeticBinaryExpression(ArithmeticOperator.Subtract, new VariableExpression("b"), new ConstantExpression(1));
            ICommand setX = new SetVariableCommand("a", incrementX);
            ICommand setY = new SetVariableCommand("b", decrementY);
            List<ICommand> commands = new List<ICommand>();
            commands.Add(setX);
            commands.Add(setY);
            ICommand command = new CompositeCommand(commands);
            IExpression yexpr = new VariableExpression("b");

            WhileCommand whilecmd = new WhileCommand(yexpr, command);

            Context context = new Context();

            context.SetValue("a", 0);
            context.SetValue("b", 5);

            whilecmd.Execute(context);

            Assert.AreEqual(0, context.GetValue("b"));
            Assert.AreEqual(5, context.GetValue("a"));
        }