public void TestNonExistantCase()
        {
            var interpreter = new OrderByClientRequestInterpreter(
                new EmptyHttpContextStorage(), new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery(new[] { "p1" });

            Assert.Empty(result);
        }
        public void TestEmptyCase()
        {
            var interpreter = new OrderByClientRequestInterpreter(
                new HttpContextStorage().SetOrderByValue(string.Empty),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery(new[] { "p1" });

            Assert.Empty(result);
        }
        public void TestAscendingOrder()
        {
            var interpreter = new OrderByClientRequestInterpreter(
                new HttpContextStorage().SetOrderByValue(Property.ToLower()),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery(new[] { Property })
                         .ToList();

            Assert.Single(result);
            var request = result.First();

            Assert.Equal(Property, request.Property);
            Assert.Equal(Property.ToLower(), request.OriginalProperty);
            Assert.Equal(OrderByDirection.Ascending, request.Direction);
        }
        public void TestMultipleOrderBys()
        {
            var orderByRequests = new List <OrderByRequest>
            {
                new OrderByRequest("p1", OrderByDirection.Ascending),
                new OrderByRequest("-p2", "p2", OrderByDirection.Descending),
            };
            var orderBy = orderByRequests.Select(o => o.OriginalProperty)
                          .Aggregate((current, next) => $"{current},{next}");
            var interpreter = new OrderByClientRequestInterpreter(
                new HttpContextStorage().SetOrderByValue(orderBy),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery(new[] { "p1", "p2" })
                         .ToList();

            Assert.Equal(orderByRequests, result, new PropertyComparer <OrderByRequest>());
        }