public async Task PagingNotNeeded()
        {
            // set up expectated results
            var expectedMatches = new List <MockMatch>
            {
                ApiTestHelper.AuthorToThreadMatch("Author 1"),
                ApiTestHelper.AuthorToThreadMatch("Author 2")
            };
            var jsonResponseMessage = ApiTestHelper.CreateJsonThreadResponseMessage(expectedMatches, 2);

            // set up mocks and stubs
            httpClient.Setup(x => x.GetJsonAsync <MockApiResponse>(It.Is <Uri>(y =>
                                                                               y.AbsolutePath == "/v1/Boards/Thread" &&
                                                                               y.Query.Contains("limit=3") &&
                                                                               y.Query.Contains("offset=0")),
                                                                   It.Is <TimeSpan>(t => t == TimeSpan.FromSeconds(65)),
                                                                   It.IsAny <AuthenticationHeaderValue>()))
            .Returns(Task.FromResult(jsonResponseMessage));

            // apply method under test
            var actualMatches =
                await paginator.PageThroughCallResults <MockApiResponse, MockResponse, MockMatches, MockMatch>(
                    "http://api.boardreader.com/v1/Boards/Thread",
                    paramDict,
                    resultLimitPerPage
                    );

            // validate
            CollectionAssert.AreEquivalent(expectedMatches, actualMatches);

            httpClient.VerifyAll();
        }
        public async Task ExactlyOnePageReturnedWithResults()
        {
            // Setup the first response
            var expectedMatches = new List <MockMatch>
            {
                ApiTestHelper.AuthorToThreadMatch("Author 1"),
                ApiTestHelper.AuthorToThreadMatch("Author 2"),
                ApiTestHelper.AuthorToThreadMatch("Author 3")
            };
            var jsonResponseMessage1 = ApiTestHelper.CreateJsonThreadResponseMessage(expectedMatches, 3);

            httpClient.Setup(x => x.GetJsonAsync <MockApiResponse>(It.Is <Uri>(y =>
                                                                               y.AbsolutePath == "/v1/Boards/Thread" &&
                                                                               y.Query.Contains("limit=3") &&
                                                                               y.Query.Contains("offset=0")),
                                                                   It.Is <TimeSpan>(t => t == TimeSpan.FromSeconds(65)),
                                                                   It.IsAny <AuthenticationHeaderValue>()))
            .Returns(Task.FromResult(jsonResponseMessage1));


            // apply method under test
            var actualMatches =
                await paginator.PageThroughCallResults <MockApiResponse, MockResponse, MockMatches, MockMatch>(
                    "http://api.boardreader.com/v1/Boards/Thread",
                    paramDict,
                    resultLimitPerPage
                    );

            httpClient.VerifyAll();
        }
        public async Task OneFullPageOnePartialPage()
        {
            // Setup the first response
            var matches = new List <MockMatch>
            {
                ApiTestHelper.AuthorToThreadMatch("Author 1"),
                ApiTestHelper.AuthorToThreadMatch("Author 2"),
                ApiTestHelper.AuthorToThreadMatch("Author 3")
            };
            var jsonResponseMessage1 = ApiTestHelper.CreateJsonThreadResponseMessage(matches, 5);

            httpClient.Setup(x => x.GetJsonAsync <MockApiResponse>(It.Is <Uri>(y =>
                                                                               y.AbsolutePath == "/v1/Boards/Thread" &&
                                                                               y.Query.Contains("limit=3") &&
                                                                               y.Query.Contains("offset=0")),
                                                                   It.Is <TimeSpan>(t => t == TimeSpan.FromSeconds(65)),
                                                                   It.IsAny <AuthenticationHeaderValue>()))
            .Returns(Task.FromResult(jsonResponseMessage1));

            // Setup the second response
            var matches2 = new List <MockMatch>();

            matches2.Add(ApiTestHelper.AuthorToThreadMatch("Author 4"));
            matches2.Add(ApiTestHelper.AuthorToThreadMatch("Author 5"));
            var jsonResponseMessage2 = ApiTestHelper.CreateJsonThreadResponseMessage(matches2, 5);

            httpClient.Setup(x => x.GetJsonAsync <MockApiResponse>(It.Is <Uri>(y =>
                                                                               y.AbsolutePath == "/v1/Boards/Thread" &&
                                                                               y.Query.Contains("limit=3") &&
                                                                               y.Query.Contains("offset=3")),
                                                                   It.Is <TimeSpan>(t => t == TimeSpan.FromSeconds(65)),
                                                                   It.IsAny <AuthenticationHeaderValue>()))
            .Returns(Task.FromResult(jsonResponseMessage2));

            // apply method under test
            var actualMatches =
                await paginator.PageThroughCallResults <MockApiResponse, MockResponse, MockMatches, MockMatch>(
                    "http://api.boardreader.com/v1/Boards/Thread",
                    paramDict,
                    resultLimitPerPage
                    );

            // Check Results
            var expected = new List <MockMatch>();

            expected.AddRange(matches);
            expected.AddRange(matches2);

            CollectionAssert.AreEquivalent(expected, actualMatches);

            httpClient.VerifyAll();
        }