public void IfTest2() { VariableExpression vaexp = new VariableExpression(); vaexp.Name = "VAR1"; VariableExpression vaexp2 = new VariableExpression(); vaexp2.Name = "VAR2"; ConstExpression cst = new ConstExpression(); cst.SetValue(true); ConstExpression cst2 = new ConstExpression(); cst2.SetValue(10); ConstExpression cst3 = new ConstExpression(); cst3.SetValue(5); ConstExpression cst4 = new ConstExpression(); cst4.SetValue(7); IfBlock ifblk = new IfBlock(); ElseBlock elseblk = new ElseBlock(); SetVarBlock setvar1 = new SetVarBlock(); SetVarBlock setvar2 = new SetVarBlock(); SetVarBlock setvar3 = new SetVarBlock(); ifblk.Condition = cst; ifblk.InnerBlock = setvar1; ifblk.NextBlock = elseblk; elseblk.InnerBlock = setvar2; elseblk.NextBlock = setvar3; setvar1.VarName = "VAR1"; setvar1.ValueExp = cst2; setvar2.VarName = "VAR1"; setvar2.ValueExp = cst3; setvar3.VarName = "VAR2"; setvar3.ValueExp = cst4; ifblk.Execute(); Assert.AreEqual(vaexp.Value, 10); Assert.AreEqual(vaexp2.Value, 7); cst.SetValue(false); ifblk.Execute(); Assert.AreEqual(vaexp.Value, 5); Assert.AreEqual(vaexp2.Value, 7); }
internal void Execute(Context context) { if ((dynamic)ConditionCallback(context)) { IfBlock.Execute(); } else { ElseBlock.Execute(); } }