Exemplo n.º 1
0
        public void DelegateInvocationInliner_NoDelegate()
        {
            var f = (Expression <Func <int, int> >)(x => x * 2);
            var i = Expression.Invoke(f, Expression.Constant(1));

            var a = DelegateInvocationInliner.Apply(i, inlineNonPublicMethods: true);

            Assert.AreSame(i, a);
        }
Exemplo n.º 2
0
        public void DelegateInvocationInliner_Multicast()
        {
            var f = new Func <int, int>(x => x * x);
            var g = new Func <int, int>(x => x + x);
            var d = Expression.Constant(f + g);
            var i = Expression.Invoke(d, Expression.Constant(1));

            var a = DelegateInvocationInliner.Apply(i, inlineNonPublicMethods: true);

            Assert.AreSame(i, a);
        }
Exemplo n.º 3
0
        public void DelegateInvocationInliner_Instance()
        {
            var c = new Bar();
            var f = new Func <int, int>(c.Twice);
            var d = Expression.Constant(f);
            var i = Expression.Invoke(d, Expression.Constant(1));

            var a = DelegateInvocationInliner.Apply(i, inlineNonPublicMethods: true);

            Assert.AreNotSame(i, a);

            var m = a as MethodCallExpression;

            Assert.IsNotNull(m);
            Assert.AreEqual(f.Method, m.Method);

            Assert.AreEqual(f(1), a.Evaluate <int>());
        }
Exemplo n.º 4
0
 public void DelegateInvocationInliner_ArgumentChecking()
 {
     AssertEx.ThrowsException <ArgumentNullException>(() => DelegateInvocationInliner.Apply(expression: null, inlineNonPublicMethods: true), ex => Assert.AreEqual("expression", ex.ParamName));
 }