Beispiel #1
0
            public void GeneratesNextLinkForSimpleUrl2()
            {
                // Arrange
                var requestUri  = new Uri("https://localhost:8081/api/v2/Packages");
                var resultCount = 210; // our result set contains 210 elements

                // Act
                var nextLink = SearchAdaptor.GetNextLink(requestUri, resultCount, null,
                                                         GetODataQueryOptionsForTest(requestUri),
                                                         GetODataQuerySettingsForTest());

                // Assert
                Assert.Equal(new Uri("https://localhost:8081/api/v2/Packages?$skip=100"), nextLink);

                // Act 2
                nextLink = SearchAdaptor.GetNextLink(nextLink, resultCount, null,
                                                     GetODataQueryOptionsForTest(nextLink),
                                                     GetODataQuerySettingsForTest());

                // Assert 2
                Assert.Equal(new Uri("https://localhost:8081/api/v2/Packages?$skip=200"), nextLink);

                // Act 3
                nextLink = SearchAdaptor.GetNextLink(nextLink, resultCount, null,
                                                     GetODataQueryOptionsForTest(nextLink),
                                                     GetODataQuerySettingsForTest());

                // Assert 3
                Assert.Null(nextLink);
            }
Beispiel #2
0
            public void GeneratesNextLinkForComplexUrl()
            {
                // Arrange
                var requestUri  = new Uri("https://localhost:8081/api/v2/Search()?searchTerm='foo'&$orderby=Id&$skip=100&$top=1000");
                var resultCount = 2000; // our result set contains 2000 elements

                // Act
                var nextLink = SearchAdaptor.GetNextLink(requestUri, resultCount, new { searchTerm = "foo" },
                                                         GetODataQueryOptionsForTest(requestUri),
                                                         GetODataQuerySettingsForTest());

                // Assert
                Assert.Equal(new Uri("https://localhost:8081/api/v2/Search()?searchTerm='foo'&$orderby=Id&$skip=200&$top=1000"), nextLink);
            }
Beispiel #3
0
            public void DoesNotGenerateNextLinkWhenSkipCountLargerThanResultSet()
            {
                // Arrange
                var requestUri  = new Uri("https://localhost:8081/api/v2/Packages?$skip=300"); // skip 300 items
                var resultCount = 200;                                                         // our result set contains 200 elements

                // Act
                var nextLink = SearchAdaptor.GetNextLink(requestUri, resultCount, null,
                                                         GetODataQueryOptionsForTest(requestUri),
                                                         GetODataQuerySettingsForTest());

                // Assert
                Assert.Null(nextLink);
            }
Beispiel #4
0
            public void DoesNotGenerateNextLinkWhenNoAdditionalResultsOnPage()
            {
                // Arrange
                var requestUri  = new Uri("https://localhost:8081/api/v2/Packages");
                var resultCount = 20; // our result set contains 20 elements

                // Act
                var nextLink = SearchAdaptor.GetNextLink(requestUri, resultCount, null,
                                                         GetODataQueryOptionsForTest(requestUri),
                                                         GetODataQuerySettingsForTest());

                // Assert
                Assert.Null(nextLink);
            }