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); }
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); }
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); }
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"); }
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); }