Пример #1
0
        public void ShouldCreateExpressionWithSimpleLambda()
        {
            var generator = new LambdaExpressionGenerator(() => new Foo());
            var expression = generator.GenerateExpression(typeof(Foo));

            Assert.NotNull(expression);
            var unary = expression as UnaryExpression;
            Assert.IsNotNull(unary);
            Assert.AreEqual(ExpressionType.Convert, unary.NodeType);
        }
Пример #2
0
        public void ShouldCreateCompilableExpression()
        {
            var generator = new LambdaExpressionGenerator(() => new Foo());
            var expression = generator.GenerateExpression(typeof(Foo));
            var func = Expression.Lambda<Func<Foo>>(expression).Compile();

            var o = func();
            Assert.IsNotNull(o);
        }