예제 #1
0
        public void VisitExtensionExpression_ReducedExpressionIsVisited()
        {
            ExpressionTreeVisitor visitor = new TestThrowingConstantExpressionTreeVisitor();
            var constantExpression        = Expression.Constant(0);
            var expression = new TestExtensionExpression(constantExpression);

            var result = visitor.VisitExpression(expression);

            Assert.That(result, Is.Not.SameAs(constantExpression));
            Assert.That(((ConstantExpression)result).Value, Is.EqualTo("ConstantExpression was visited"));
        }
예제 #2
0
        public void VisitExtensionExpression_NonReducibleExpression()
        {
            ExpressionTreeVisitor visitor = new TestThrowingConstantExpressionTreeVisitor();

            var nonReducibleExpression = MockRepository.GenerateStub <ExtensionExpression> (typeof(int));

            nonReducibleExpression
            .Stub(stub => stub.Accept(Arg <ExpressionTreeVisitor> .Is.Anything))
            .WhenCalled(mi => PrivateInvoke.InvokeNonPublicMethod(mi.Arguments[0], "VisitExtensionExpression", nonReducibleExpression))
            .Return(nonReducibleExpression);
            nonReducibleExpression.Stub(stub => stub.CanReduce).Return(false);
            nonReducibleExpression.Stub(stub => stub.ToString()).Return("Test");

            visitor.VisitExpression(nonReducibleExpression);
        }