コード例 #1
0
        public void GetMethodInfoStaticFunctionVariableTest()
        {
            Expression <Func <int> > expression = () => Test8.Method5();
            var result = ReflectionExpressions.GetMethodInfo(expression);

            Assert.AreEqual("Method5", result.Name);
        }
コード例 #2
0
        public void GetMethodInfoInstanceFunctionWithArgumentsTest()
        {
            var result = ReflectionExpressions.GetMethodInfo <Test8>(methodObject =>
                                                                     methodObject.Method2(default(string), default(int)));

            Assert.AreEqual("Method2", result.Name);
        }
コード例 #3
0
        public void GetMethodInfoInstanceFunctionVariableTest()
        {
            Expression <Func <Test8, int> > expression = methodObject => methodObject.Method1();
            var result = ReflectionExpressions.GetMethodInfo(expression);

            Assert.AreEqual("Method1", result.Name);
        }
コード例 #4
0
        public void ExpandExpressionsExpand1QuoteTest()
        {
            Expression <Func <int, int> > f1 = y => y + 2;

            var x = Expression.Parameter(typeof(int), "x");
            Expression <Func <int, int> > f2 = Expression.Lambda <Func <int, int> >(
                Expression.Multiply(
                    Expression.Call(
                        ReflectionExpressions.GetMethodInfo <Expression <Func <int, int> > >(expression =>
                                                                                             expression.Evaluate(default(int))),
                        Expression.Quote(f1),
                        x),
                    Expression.Constant(3)),
                new[]
            {
                x
            });
            var result = f2.ExpandExpressions();

            NoDuplicateParameterAssertion.AssertNoDuplicateParameters(result);
            Assert.AreEqual(9, result.Compile()(1));
            NoEvaluationsAssertion.AssertNoEvaluations(result);
        }
コード例 #5
0
        public void GetMethodInfoStaticFunctionTest()
        {
            var result = ReflectionExpressions.GetMethodInfo(() => Test8.Method5());

            Assert.AreEqual("Method5", result.Name);
        }
コード例 #6
0
        public void GetMethodInfoInstanceVoidTest()
        {
            var result = ReflectionExpressions.GetMethodInfo <Test8>(methodObject => methodObject.Method3());

            Assert.AreEqual("Method3", result.Name);
        }