public void TestNonExistantCase()
        {
            var interpreter = new PaginationByClientRequestInterpreter(
                new EmptyHttpContextStorage(), new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Null(result.Limit);
            Assert.Null(result.Offset);
        }
        public void TestSuccessfulEntriesPerPageValue()
        {
            const int limit       = 5;
            var       interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetLimitValue(limit.ToString()),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Equal(limit, result.Limit);
        }
        public void TestSuccessfulPageValue()
        {
            const int offset      = 5;
            var       interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetOffsetValue(offset.ToString()),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Equal(offset, result.Offset);
        }
        public void NotSupportedLimitTheory(string entriesPerPage)
        {
            var interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetLimitValue(entriesPerPage),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Null(result.Limit);
            Assert.Null(result.Offset);
        }
        public void TestEmptyEntriesPerPageCase()
        {
            var interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetLimitValue(string.Empty),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Null(result.Limit);
            Assert.Null(result.Offset);
        }
        public void RangeHeaderTheory(int rangeStart, int rangeEnd, int limit)
        {
            var interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetRangeHeader($"items={rangeStart}-{rangeEnd}"),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Equal(rangeStart, result.Offset);
            Assert.Equal(limit, result.Limit);
        }
        public void RangeHeaderMalformattedTheory(string rangeValue)
        {
            var interpreter = new PaginationByClientRequestInterpreter(
                new HttpContextStorage().SetRangeHeader(rangeValue),
                new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Null(result.Limit);
            Assert.Null(result.Offset);
        }
        public void TestPrecedence()
        {
            const int offset  = 10;
            const int limit   = 10;
            var       context = new HttpContextStorage()
                                .SetRangeHeader($"items={0}-{29}")
                                .SetOffsetValue(offset.ToString())
                                .SetLimitValue(limit.ToString());
            var interpreter = new PaginationByClientRequestInterpreter(
                context, new MockPropertyNameResolver());
            var result = interpreter.ParseRequestQuery();

            Assert.Equal(offset, result.Offset);
            Assert.Equal(limit, result.Limit);
        }