public void GetUserSearchResponse__returns_search_results_from_github_user_search_api()
        {
            //Arrange
            GitUserSearchResponse gitResponse = new GitUserSearchResponse
            {
                id = 1
            };
            GitBaseResponse <GitUserSearchResponse> response = new GitBaseResponse <GitUserSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitUserSearchResponse>()
                {
                    gitResponse
                },
                sort       = sort,
                order      = order,
                perPage    = perPage,
                pageNumber = pageNumber
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitUserSearchResponse> >(GitSearchType.users, searchTerm, sort, order, perPage, pageNumber).Returns(response);

            //Act
            var result = subject.GetUserSearchResponse(searchTerm, sort, order, perPage, pageNumber);

            //Assert
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitUserSearchResponse> >(GitSearchType.users, searchTerm, sort, order, perPage, pageNumber);
            result.Result.Should().BeEquivalentTo(response);
        }
        public void GetInitialSearchResponse__returns_search_results_from_github_search_api()
        {
            //Arrange
            GitRepositorySearchResponse gitRepoResponse = new GitRepositorySearchResponse
            {
                id = 1
            };
            GitBaseResponse <GitRepositorySearchResponse> RepoResponse = new GitBaseResponse <GitRepositorySearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitRepositorySearchResponse>()
                {
                    gitRepoResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitRepositorySearchResponse> >(GitSearchType.repositories, searchTerm, null, null, 1, 1).Returns(RepoResponse);

            GitCodeSearchResponse gitCodeResponse = new GitCodeSearchResponse
            {
                name = "name"
            };
            GitBaseResponse <GitCodeSearchResponse> CodeResponse = new GitBaseResponse <GitCodeSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitCodeSearchResponse>()
                {
                    gitCodeResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitCodeSearchResponse> >(GitSearchType.code, searchTerm + " org:github", null, null, 1, 1).Returns(CodeResponse);

            GitCommitSearchResponse gitCommitResponse = new GitCommitSearchResponse
            {
                node_id = "node_id"
            };
            GitBaseResponse <GitCommitSearchResponse> CommitResponse = new GitBaseResponse <GitCommitSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitCommitSearchResponse>()
                {
                    gitCommitResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitCommitSearchResponse> >(GitSearchType.commits, searchTerm, null, null, 1, 1).Returns(CommitResponse);

            GitIssueSearchResponse gitIssueResponse = new GitIssueSearchResponse
            {
                node_id = "node_id"
            };
            GitBaseResponse <GitIssueSearchResponse> IssueResponse = new GitBaseResponse <GitIssueSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitIssueSearchResponse>()
                {
                    gitIssueResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitIssueSearchResponse> >(GitSearchType.issues, searchTerm, null, null, 1, 1).Returns(IssueResponse);

            GitTopicSearchResponse gitTopicResponse = new GitTopicSearchResponse
            {
                description = "description"
            };
            GitBaseResponse <GitTopicSearchResponse> TopicResponse = new GitBaseResponse <GitTopicSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitTopicSearchResponse>()
                {
                    gitTopicResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitTopicSearchResponse> >(GitSearchType.topics, searchTerm, null, null, 1, 1).Returns(TopicResponse);

            GitUserSearchResponse gitUserResponse = new GitUserSearchResponse
            {
                id = 1
            };
            GitBaseResponse <GitUserSearchResponse> UserResponse = new GitBaseResponse <GitUserSearchResponse>
            {
                total_count        = 1,
                incomplete_results = false,
                items = new List <GitUserSearchResponse>()
                {
                    gitUserResponse
                },
                sort       = null,
                order      = null,
                perPage    = 1,
                pageNumber = 1
            };

            mockGithubHttpClient.GetSearchResponse <GitBaseResponse <GitUserSearchResponse> >(GitSearchType.users, searchTerm, null, null, 1, 1).Returns(UserResponse);

            AutoCompleteSearchResponse response = new AutoCompleteSearchResponse
            {
                search_term       = searchTerm,
                repository_search = RepoResponse,
                code_search       = CodeResponse,
                commit_search     = CommitResponse,
                topic_search      = TopicResponse,
                issue_search      = IssueResponse,
                user_search       = UserResponse
            };

            //Act
            var result = subject.GetInitialResponse(searchTerm);

            //Assert
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitRepositorySearchResponse> >(GitSearchType.repositories, searchTerm, null, null, 1, 1);
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitCodeSearchResponse> >(GitSearchType.code, searchTerm + " org:github", null, null, 1, 1);
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitCommitSearchResponse> >(GitSearchType.commits, searchTerm, null, null, 1, 1);
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitIssueSearchResponse> >(GitSearchType.issues, searchTerm, null, null, 1, 1);
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitTopicSearchResponse> >(GitSearchType.topics, searchTerm, null, null, 1, 1);
            mockGithubHttpClient.Received(1).GetSearchResponse <GitBaseResponse <GitUserSearchResponse> >(GitSearchType.users, searchTerm, null, null, 1, 1);
            result.Result.Should().BeEquivalentTo(response);
        }