Example #1
0
        public void ExecutesAll()
        {
            var queryable = GetIQueryable();
            var particles = new List <Mock <IFilterParticle <IQueryableApplyTests> > >()
            {
                GetParticle(),
                GetParticle(),
                GetParticle(),
                GetParticle(),
            };

            // Create the MockSequence to validate the call order
            var sequence = new MockSequence();

            foreach (var p in particles)
            {
                p.InSequence(sequence)
                .Setup(x => x.GetExpression(It.IsAny <ParameterExpression>()))
                .Returns <Expression>(x =>
                {
                    return(Expression.Constant(true));
                });
            }

            var result = IQueryableExtensions.Apply(
                source: GetIQueryable(),
                particles: particles.Select(x => x.Object).AsEnumerable()
                );

            foreach (var p in particles)
            {
                p.Verify(x => x.GetExpression(It.IsAny <ParameterExpression>()));
            }
        }
Example #2
0
        public void HandlesEmptyList()
        {
            var result = IQueryableExtensions.Apply(
                source: GetIQueryable(),
                particles: Array.Empty <IFilterParticle <IQueryableApplyTests> >()
                );

            Assert.NotNull(result);
        }
Example #3
0
 public void ThrowsOnNullParticles()
 {
     Assert.Throws <ArgumentNullException>("particles", () =>
     {
         IQueryableExtensions.Apply(
             source: GetIQueryable(),
             particles: (IEnumerable <IFilterParticle <IQueryableApplyTests> >)null
             );
     });
 }