public void CanGenerateExpressionWithNullSortDescription()
        {
            var param = Expression.Parameter(typeof(IQueryable<ClassA>), "q");
            var expr = new SortVisitor<ClassA>().Visit(param, null);

            Assert.AreEqual("q", expr.ToString());
        }
        public void CanSortBySingleAttributeDescending()
        {
            var sort = Helper.Sort("PropB.PropDateTimeNullable", ListSortDirection.Descending);

            var param = Expression.Parameter(typeof(IQueryable<ClassA>), "q");
            var expr = new SortVisitor<ClassA>().Visit(param, sort);

            Assert.AreEqual("q.OrderByDescending(x => x.PropB.PropDateTimeNullable)", expr.ToString());
        }
        public void CanSortByThreeAttributesOneDescendingOtherAscendingLastDescending()
        {
            var sort = Helper.Sorts(
                Helper.Sort("PropInt", ListSortDirection.Descending),
                Helper.Sort("PropString", ListSortDirection.Ascending),
                Helper.Sort("PropB.PropDecimalNullable", ListSortDirection.Descending)
                );

            var param = Expression.Parameter(typeof(IQueryable<ClassA>), "q");
            var expr = new SortVisitor<ClassA>().Visit(param, sort);

            Assert.AreEqual("q.OrderByDescending(x => x.PropInt).ThenBy(x => x.PropString).ThenByDescending(x => x.PropB.PropDecimalNullable)", expr.ToString());
        }
        public void CanSortByTwoAttributesAllDescending()
        {
            var sort = Helper.Sorts(
                Helper.Sort("PropInt", ListSortDirection.Descending),
                Helper.Sort("PropString", ListSortDirection.Descending));

            var param = Expression.Parameter(typeof(IQueryable<ClassA>), "q");
            var expr = new SortVisitor<ClassA>().Visit(param, sort);

            Assert.AreEqual("q.OrderByDescending(x => x.PropInt).ThenByDescending(x => x.PropString)", expr.ToString());
        }