public async Task SearchResultsFromQuery()
        {
            Dictionary <string, object> paramDict; paramDict = socialGist.GetBaseParameters();

            paramDict.Add("query", "frogs");
            paramDict.Add("dn", "reddit.com");
            paramDict.Add("sort_mode", "time_desc");
            paramDict.Add("keep_original", "true");
            paramDict.Add("group_mode", "thread");
            paramDict.Add("match_mode", "boolean");

            var expected = new List <SearchMatch>
            {
                ApiTestHelper.ThreadIdToMatch("url1"),
                ApiTestHelper.ThreadIdToMatch("url1")
            };

            paginator.Setup(x => x.PageThroughCallResults <SearchApiResponse, SearchResponse, SearchMatches, SearchMatch>(
                                "https://redditapi.socialgist.com/v1/Boards/Search",
                                paramDict,
                                socialGist.ResultLimitPerPage
                                )).ReturnsAsync(expected);

            var threadIdSet = await socialGist.MatchesForQuery("frogs", null);

            CollectionAssert.AreEquivalent(threadIdSet, new SortedSet <SocialGistPostId>()
            {
                new SocialGistPostId()
                {
                    Url = "url1"
                }
            });
        }
        public async Task PagingWithSearchResults()
        {
            var matches = new List <SearchMatch>
            {
                ApiTestHelper.ThreadIdToMatch("id3"),
                ApiTestHelper.ThreadIdToMatch("id3"),
                ApiTestHelper.ThreadIdToMatch("id2")
            };
            var jsonResponseMessage1 = ApiTestHelper.CreateJsonSearchResponseMessage(matches, 6);

            httpClient.Setup(x => x.GetJsonAsync <SearchApiResponse>(It.Is <Uri>(y =>
                                                                                 y.AbsolutePath == "/v1/Boards/Search" &&
                                                                                 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 <SearchMatch>
            {
                ApiTestHelper.ThreadIdToMatch("id1"),
                ApiTestHelper.ThreadIdToMatch("id4"),
                ApiTestHelper.ThreadIdToMatch("id2")
            };
            var jsonResponseMessage2 = ApiTestHelper.CreateJsonSearchResponseMessage(matches2, 6);

            httpClient.Setup(x => x.GetJsonAsync <SearchApiResponse>(It.Is <Uri>(y =>
                                                                                 y.AbsolutePath == "/v1/Boards/Search" &&
                                                                                 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 <SearchApiResponse, SearchResponse, SearchMatches, SearchMatch>(
                    "https://redditapi.socialgist.com/v1/Boards/Search",
                    paramDict,
                    resultLimitPerPage
                    );

            var expected = new List <SearchMatch>();

            expected.AddRange(matches);
            expected.AddRange(matches2);
            CollectionAssert.AreEquivalent(expected, actualMatches);

            httpClient.VerifyAll();
        }