示例#1
0
        public void CorrectValueFor_VariableExpr_ValueType()
        {
            var eval = new Evaluator();
            Expression<Func<bool>> expr = () => 1 == two;
            Expression rightExpr = (expr.Body as BinaryExpression).Right;

            object rightVal = eval.GetMemberVal(rightExpr);

            Assert.AreEqual(rightVal, 2);
        }
示例#2
0
        public void CorrectValueFor_StaticCallExpr_ValueType()
        {
            var eval = new Evaluator();
            Expression<Func<bool>> expr = () => Sample.GetStaticTrue();
            Expression call = (expr.Body as MethodCallExpression);

            object val = eval.GetMemberVal(call);

            Assert.AreEqual(val, true);
        }
示例#3
0
        public void CorrectValueFor_MemberVariableExpr_Instance()
        {
            var tester = new Sample();
            var eval = new Evaluator();
            Expression<Func<bool>> expr = () => one == tester.Two;
            Expression rightExpr = (expr.Body as BinaryExpression).Right;

            object rightVal = eval.GetMemberVal(rightExpr);

            Assert.AreEqual(rightVal, 2);
        }
示例#4
0
        public void CorrectValueFor_StaticCallExpr_RefType()
        {
            var eval = new Evaluator();
            Expression<Func<string>> expr = () => Sample.GetStaticString();
            Expression call = (expr.Body as MethodCallExpression);

            object val = eval.GetMemberVal(call);

            Assert.AreEqual(val, "str");
        }
示例#5
0
        public void CorrectValueFor_InstanceCallExpr_ValueType()
        {
            var eval = new Evaluator();
            var tester = new Sample();
            Expression<Func<bool>> expr = () => tester.GetTrue();
            Expression call = (expr.Body as MethodCallExpression);

            object val = eval.GetMemberVal(call);

            Assert.AreEqual(val, true);
        }