Ejemplo n.º 1
0
        public void Test_Accepted_By_OrderByApplicator_Apply()
        {
            // Act
            var results = OrderByExpressionBuilder.Build <TestType>("IntValue, StringValue desc, DecValue").ToList();
            var query   = new List <TestType>().AsQueryable();

            // Assert
            query = OrderByApplicator.Apply(query, results);
            Assert.True(true);
        }
Ejemplo n.º 2
0
        public void Test_SingleField_Descending()
        {
            // Act
            var results = OrderByExpressionBuilder.Build <TestType>("IntValue desc").ToList();

            // Assert
            Assert.Single(results);

            var result = results.First();

            Assert.True(result.Descending);
            Assert.Equal("item => item.IntValue", result.Expression.ToString());
        }
Ejemplo n.º 3
0
        public void Test_MultipleFields_Mixed()
        {
            // Act
            var results = OrderByExpressionBuilder.Build <TestType>("IntValue, StringValue desc, DecValue").ToList();

            // Assert
            Assert.Equal(3, results.Count);

            Assert.False(results[0].Descending);
            Assert.Equal("item => item.IntValue", results[0].Expression.ToString());

            Assert.True(results[1].Descending);
            Assert.Equal("item => item.StringValue", results[1].Expression.ToString());

            Assert.False(results[2].Descending);
            Assert.Equal("item => item.DecValue", results[2].Expression.ToString());
        }
Ejemplo n.º 4
0
        public static IQueryable <T> OrderByDefault <T>(this IQueryable <T> query)
        {
            var expressions = OrderByExpressionBuilder.BuildDefault <T>();

            return(OrderByApplicator.Apply(query, expressions));
        }
Ejemplo n.º 5
0
        public static IQueryable <T> OrderBy <T>(this IQueryable <T> query, string orderBy)
        {
            var expressions = OrderByExpressionBuilder.Build <T>(orderBy);

            return(OrderByApplicator.Apply(query, expressions));
        }