/// <summary> /// Creates the parser. /// </summary> private static QueryParser CreateParser() { var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); var proc = new TransformingExpressionTreeProcessor(transformerRegistry); var parser = new ExpressionTreeParser(ExpressionTreeParser.CreateDefaultNodeTypeProvider(), proc); return new QueryParser(parser); }
public void Process () { var inputExpression = Expression.Constant (1); var transformedExpression = Expression.Constant (2); var transformationProviderMock = MockRepository.GenerateStrictMock<IExpressionTranformationProvider>(); transformationProviderMock .Expect (mock => mock.GetTransformations (inputExpression)) .Return (new ExpressionTransformation[] { expr => transformedExpression }); transformationProviderMock .Expect (mock => mock.GetTransformations (transformedExpression)) .Return (new ExpressionTransformation[0]); transformationProviderMock.Replay(); var processor = new TransformingExpressionTreeProcessor (transformationProviderMock); var result = processor.Process (inputExpression); transformationProviderMock.VerifyAllExpectations(); Assert.That (result, Is.SameAs (transformedExpression)); }