Exemplo n.º 1
0
 public void GetSupportedMethods()
 {
     Assert.That(
         TakeExpressionNode.GetSupportedMethods(),
         Is.EquivalentTo(
             new[]
     {
         GetGenericMethodDefinition(() => Queryable.Take <object> (null, 0)),
         GetGenericMethodDefinition(() => Enumerable.Take <object> (null, 0))
     }));
 }
Exemplo n.º 2
0
        public void SetUp()
        {
            _methodInfoBasedNodeTypeRegistry = new MethodInfoBasedNodeTypeRegistry();

            _methodInfoBasedNodeTypeRegistry.Register(WhereExpressionNode.GetSupportedMethods(), typeof(WhereExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(SelectExpressionNode.GetSupportedMethods(), typeof(SelectExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(TakeExpressionNode.GetSupportedMethods(), typeof(TakeExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(CountExpressionNode.GetSupportedMethods(), typeof(CountExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(JoinExpressionNode.GetSupportedMethods(), typeof(JoinExpressionNode));

            _parser = new MethodCallExpressionParser(_methodInfoBasedNodeTypeRegistry);

            _source = ExpressionNodeObjectMother.CreateMainSource();
        }
Exemplo n.º 3
0
        public void Resolve_PassesExpressionToSource()
        {
            var sourceMock     = MockRepository.GenerateMock <IExpressionNode>();
            var node           = new TakeExpressionNode(CreateParseInfo(sourceMock), Expression.Constant(2));
            var expression     = ExpressionHelper.CreateLambdaExpression();
            var parameter      = ExpressionHelper.CreateParameterExpression();
            var expectedResult = ExpressionHelper.CreateExpression();

            sourceMock.Expect(mock => mock.Resolve(parameter, expression, ClauseGenerationContext)).Return(expectedResult);

            var result = node.Resolve(parameter, expression, ClauseGenerationContext);

            sourceMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(expectedResult));
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            _methodInfoBasedNodeTypeRegistry = new MethodInfoBasedNodeTypeRegistry();

            _methodInfoBasedNodeTypeRegistry.Register(WhereExpressionNode.GetSupportedMethods(), typeof(WhereExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(SelectExpressionNode.GetSupportedMethods(), typeof(SelectExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(TakeExpressionNode.GetSupportedMethods(), typeof(TakeExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(CountExpressionNode.GetSupportedMethods(), typeof(CountExpressionNode));
            _methodInfoBasedNodeTypeRegistry.Register(ContainsExpressionNode.GetSupportedMethods(), typeof(ContainsExpressionNode));

            _expressionTreeParser = new ExpressionTreeParser(
                _methodInfoBasedNodeTypeRegistry,
                new PartialEvaluatingExpressionTreeProcessor(new TestEvaluatableExpressionFilter()));

            _intSource = new[] { 1, 2, 3 }.AsQueryable();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a <see cref="MethodInfoBasedNodeTypeRegistry"/> and registers all relevant <see cref="IExpressionNode"/> implementations in the <b>Remotion.Linq</b> assembly.
        /// </summary>
        /// <returns>
        /// A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types in the <b>Remotion.Linq</b> assembly registered.
        /// </returns>
        public static MethodInfoBasedNodeTypeRegistry CreateFromRelinqAssembly()
        {
            var registry = new MethodInfoBasedNodeTypeRegistry();

            registry.Register(AggregateExpressionNode.GetSupportedMethods(), typeof(AggregateExpressionNode));
            registry.Register(AggregateFromSeedExpressionNode.GetSupportedMethods(), typeof(AggregateFromSeedExpressionNode));
            registry.Register(AllExpressionNode.GetSupportedMethods(), typeof(AllExpressionNode));
            registry.Register(AnyExpressionNode.GetSupportedMethods(), typeof(AnyExpressionNode));
            registry.Register(AsQueryableExpressionNode.GetSupportedMethods(), typeof(AsQueryableExpressionNode));
            registry.Register(AverageExpressionNode.GetSupportedMethods(), typeof(AverageExpressionNode));
            registry.Register(CastExpressionNode.GetSupportedMethods(), typeof(CastExpressionNode));
            registry.Register(ConcatExpressionNode.GetSupportedMethods(), typeof(ConcatExpressionNode));
            registry.Register(ContainsExpressionNode.GetSupportedMethods(), typeof(ContainsExpressionNode));
            registry.Register(CountExpressionNode.GetSupportedMethods(), typeof(CountExpressionNode));
            registry.Register(DefaultIfEmptyExpressionNode.GetSupportedMethods(), typeof(DefaultIfEmptyExpressionNode));
            registry.Register(DistinctExpressionNode.GetSupportedMethods(), typeof(DistinctExpressionNode));
            registry.Register(ExceptExpressionNode.GetSupportedMethods(), typeof(ExceptExpressionNode));
            registry.Register(FirstExpressionNode.GetSupportedMethods(), typeof(FirstExpressionNode));
            registry.Register(GroupByExpressionNode.GetSupportedMethods(), typeof(GroupByExpressionNode));
            registry.Register(GroupByWithResultSelectorExpressionNode.GetSupportedMethods(), typeof(GroupByWithResultSelectorExpressionNode));
            registry.Register(GroupJoinExpressionNode.GetSupportedMethods(), typeof(GroupJoinExpressionNode));
            registry.Register(IntersectExpressionNode.GetSupportedMethods(), typeof(IntersectExpressionNode));
            registry.Register(JoinExpressionNode.GetSupportedMethods(), typeof(JoinExpressionNode));
            registry.Register(LastExpressionNode.GetSupportedMethods(), typeof(LastExpressionNode));
            registry.Register(LongCountExpressionNode.GetSupportedMethods(), typeof(LongCountExpressionNode));
            registry.Register(MaxExpressionNode.GetSupportedMethods(), typeof(MaxExpressionNode));
            registry.Register(MinExpressionNode.GetSupportedMethods(), typeof(MinExpressionNode));
            registry.Register(OfTypeExpressionNode.GetSupportedMethods(), typeof(OfTypeExpressionNode));
            registry.Register(OrderByDescendingExpressionNode.GetSupportedMethods(), typeof(OrderByDescendingExpressionNode));
            registry.Register(OrderByExpressionNode.GetSupportedMethods(), typeof(OrderByExpressionNode));
            registry.Register(ReverseExpressionNode.GetSupportedMethods(), typeof(ReverseExpressionNode));
            registry.Register(SelectExpressionNode.GetSupportedMethods(), typeof(SelectExpressionNode));
            registry.Register(SelectManyExpressionNode.GetSupportedMethods(), typeof(SelectManyExpressionNode));
            registry.Register(SingleExpressionNode.GetSupportedMethods(), typeof(SingleExpressionNode));
            registry.Register(SkipExpressionNode.GetSupportedMethods(), typeof(SkipExpressionNode));
            registry.Register(SumExpressionNode.GetSupportedMethods(), typeof(SumExpressionNode));
            registry.Register(TakeExpressionNode.GetSupportedMethods(), typeof(TakeExpressionNode));
            registry.Register(ThenByDescendingExpressionNode.GetSupportedMethods(), typeof(ThenByDescendingExpressionNode));
            registry.Register(ThenByExpressionNode.GetSupportedMethods(), typeof(ThenByExpressionNode));
            registry.Register(UnionExpressionNode.GetSupportedMethods(), typeof(UnionExpressionNode));
            registry.Register(WhereExpressionNode.GetSupportedMethods(), typeof(WhereExpressionNode));

            return(registry);
        }
Exemplo n.º 6
0
 public override void SetUp()
 {
     base.SetUp();
     _node = new TakeExpressionNode(CreateParseInfo(), Expression.Constant(3));
 }