Evaluate() public method

public Evaluate ( Context context ) : object
context Context
return object
示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        public void EvaluateConstantBody()
        {
            Function function = new Function(null, new object[] { }, new ConstantExpression(1));

            Assert.AreEqual(1, function.Evaluate(null));
        }