public void GivenExpressionWhenExecuteCalledThenShouldTransformExpressionAndCallSourceProvider()
        {
            var query    = new TestQueryableWrapper();
            var provider = new QueryInterceptingProvider <IdType>(query);

            provider.RegisterInterceptor(e => Expression.Constant(1));
            var target = provider.Execute(Expression.Constant(2));

            Assert.IsType <ConstantExpression>(target);
            Assert.Equal(1, (target as ConstantExpression).Value);
        }
        public void GivenRegistrationWhenChildProvidersExistThenRegistrationShouldBePassedToChildren()
        {
            var list = new List <IdType> {
                new IdType(), new IdType(), new IdType()
            };
            var query     = list.AsQueryable().Take(1);
            var swapQuery = list.AsQueryable().Skip(1).Take(1).Select(i => Tuple.Create(i.Id, i.IdVal));
            var provider  = new QueryInterceptingProvider <IdType>(query);
            var host      = new QueryHost <IdType, QueryInterceptingProvider <IdType> >(query.Expression, provider);
            // force resolution of a different type
            var notIntercepted = host.Select(i => Tuple.Create(i.Id, i.IdVal)).ToList();

            // now register
            provider.RegisterInterceptor(e => swapQuery.Expression);
            var intercepted = host.Select(i => Tuple.Create(i.Id, i.IdVal)).ToList();

            Assert.Single(intercepted);
            Assert.Equal(list[1].Id, intercepted[0].Item1);
        }