public void EvaluateExpressionBody() { Function function = new Function(null, new object[] { }, new AddExpression(new VariableExpression(new Variable("X")), new VariableExpression(new Variable("Y")))); Context context = new Context(); context.SetValue("X", 1); context.SetValue("Y", 2); Assert.AreEqual(3, function.Evaluate(context)); }
public void MakeContextAndEvaluateExpressionBody() { Function function = new Function(null, new object[] { new Variable("X"), new Variable("Y") }, new AddExpression(new VariableExpression(new Variable("X")), new VariableExpression(new Variable("Y")))); Context context = function.MakeContext(new object[] { 1, 2 }); Assert.IsNotNull(context); Assert.AreEqual(1, context.GetValue("X")); Assert.AreEqual(2, context.GetValue("Y")); Assert.AreEqual(3, function.Evaluate(context)); }
public void EvaluateConstantBody() { Function function = new Function(null, new object[] { }, new ConstantExpression(1)); Assert.AreEqual(1, function.Evaluate(null)); }