public void Accept()
        {
            var mockRepository = new MockRepository();
            var visitorMock    = mockRepository.StrictMultiMock <ExpressionVisitor> (typeof(ISqlCustomTextGeneratorExpressionVisitor));

            var customTextGeneratorExpression = new TestableSqlCustomTextGeneratorExpression(typeof(Cook));

            visitorMock
            .Expect(mock => ((ISqlCustomTextGeneratorExpressionVisitor)mock).VisitSqlCustomTextGenerator(customTextGeneratorExpression))
            .Return(customTextGeneratorExpression);
            visitorMock.Replay();

            ExtensionExpressionTestHelper.CallAccept(customTextGeneratorExpression, visitorMock);

            visitorMock.VerifyAllExpectations();
        }
Beispiel #2
0
        public void Visit_Extension()
        {
            var expectedResult = Expression.Constant(0);

            var visitor = new TestableExpressionVisitor();

            var extensionExpressionMock = MockRepository.StrictMock <ExtensionExpression> (typeof(int));

            extensionExpressionMock.Expect(mock => ExtensionExpressionTestHelper.CallAccept(mock, visitor)).Return(expectedResult);
            extensionExpressionMock.Replay();

            var result = visitor.Visit(extensionExpressionMock);

            extensionExpressionMock.VerifyAllExpectations();

            Assert.That(result, Is.SameAs(expectedResult));
        }
        public void VisitExtension_NonReducibleExpression()
        {
            RelinqExpressionVisitor visitor = new TestThrowingConstantExpressionVisitor();

#if !NET_3_5
            var nonReducibleExpression = MockRepository.GenerateStub <Expression>();
#else
            var nonReducibleExpression = MockRepository.GenerateStub <ExtensionExpression> (typeof(int));
#endif
            nonReducibleExpression
            .Stub(stub => ExtensionExpressionTestHelper.CallAccept(stub, Arg <RelinqExpressionVisitor> .Is.Anything))
            .WhenCalled(mi => PrivateInvoke.InvokeNonPublicMethod(mi.Arguments[0], "VisitExtension", nonReducibleExpression))
            .Return(nonReducibleExpression);
            nonReducibleExpression.Stub(stub => stub.CanReduce).Return(false);
            nonReducibleExpression.Stub(stub => stub.ToString()).Return("Test");

            visitor.Visit(nonReducibleExpression);
        }