public void ApplySorts_UsesDefaultWhenNoSorts()
        {
            var factory = new SortFactory <User, long>(new SortSpecification[0], new Dictionary <string, dynamic>());
            var list    = new List <User>()
            {
                new User()
                {
                    Id = 3
                },
                new User()
                {
                    Id = 1
                },
                new User()
                {
                    Id = 4
                }
            }.AsQueryable();

            var sorted = factory.ApplySorts(list);

            Assert.Equal(1, sorted.First().Id);
            Assert.Equal(3, sorted.ElementAt(1).Id);
            Assert.Equal(4, sorted.Last().Id);
        }
        public void ApplySorts_AppliesAllSorts(SortDirection dir, string expFirst1, string expFirst2)
        {
            var specs = new SortSpecification[]
            {
                new SortSpecification("Id", SortDirection.Ascending),
                new SortSpecification("First", dir),
            };
            var available = new Dictionary <string, dynamic>()
            {
                { "Id", (Expression <Func <User, long> >)(u => u.Id) },
                { "First", (Expression <Func <User, string> >)(u => u.First) }
            };

            var factory = new SortFactory <User, long>(specs, available);
            var list    = new List <User>()
            {
                new User()
                {
                    Id = 3, First = expFirst1
                },
                new User()
                {
                    Id = 3, First = expFirst2
                },
                new User()
                {
                    Id = 1
                },
                new User()
                {
                    Id = 4
                }
            }.AsQueryable();

            var sorted = factory.ApplySorts(list);

            Assert.Equal(1, sorted.First().Id);
            Assert.Equal(expFirst1, sorted.ElementAt(1).First);
            Assert.Equal(expFirst2, sorted.ElementAt(2).First);
            Assert.Equal(4, sorted.Last().Id);
        }