MakeContext() public method

public MakeContext ( IList arguments ) : Context
arguments IList
return Context
Exemplo n.º 1
0
        public void CannotMakeContextByNoMatch()
        {
            Function function = new Function(null, new object[] { new Variable("X"), new Variable("X") }, new AddExpression(new VariableExpression(new Variable("X")), new VariableExpression(new Variable("X"))));

            Context context = function.MakeContext(new object[] { 1, 2 });

            Assert.IsNull(context);
        }
Exemplo n.º 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));
        }