Esempio n. 1
0
        public void GetPullRequests_NotAuthenticated_Authenticates()
        {
            _repoBrowser.AuthService.IsAuthenticatedReturn = false;
            PullRequestResponse response = RepoBrowserFactory.GetPullRequests(_request, _repoBrowser).Result;

            Assert.True(_repoBrowser.AuthService.AuthenticateHit);

            // Restore
            _repoBrowser.AuthService.AuthenticateHit = false;
        }
Esempio n. 2
0
        public void GetPullRequests_Authentication_AllHit()
        {
            _repoBrowser.AuthService.AfterResponseHit      = false;
            _repoBrowser.AuthService.BeforeRequestHit      = false;
            _repoBrowser.AuthService.AuthenticateHit       = false;
            _repoBrowser.AuthService.IsAuthenticatedReturn = false;
            PullRequestResponse response = RepoBrowserFactory.GetPullRequests(_request, _repoBrowser).Result;

            Assert.True(_repoBrowser.AuthService.AuthenticateHit);
            Assert.True(_repoBrowser.AuthService.AfterResponseHit);
            Assert.True(_repoBrowser.AuthService.BeforeRequestHit);
        }
Esempio n. 3
0
        public void GetPullRequests_All_Returns10()
        {
            // Setup 10 PRs
            List <PullRequest> pullRequests = new List <PullRequest>();

            for (int i = 0; i < 10; i++)
            {
                pullRequests.Add(new PullRequest());
            }
            _repoBrowser.TransformService.PRResponseToReturn = new PullRequestResponse()
            {
                PullRequests = pullRequests
            };

            PullRequestResponse response = RepoBrowserFactory.GetPullRequests(_request, _repoBrowser).Result;

            Assert.NotNull(response);
            Assert.Equal(10, response.PullRequests.Count);
        }
Esempio n. 4
0
        public async Task <ActionResult> Get(int id,
                                             [FromQuery] string repo, [FromQuery] string state)
        {
            // Check if organization exists, otherwise not found
            if (!DoesOrganizationExist(id, out Organization organization))
            {
                return(NotFound());
            }

            // Then fetch data from PRs using that organization
            _logger.LogDebug("Fetching PRs for organization ID: " + id);

            // Create internal PullRequestRequest from data and fetch it
            PullRequestRequest  request  = CreatePullRequest(repo, state, organization.Repository.Name);
            IRepoBrowser        browser  = RepoBrowserFactory.CreateRepoBrowser(organization, _repoConfig, _memoryCache);
            PullRequestResponse response = await RepoBrowserFactory.GetPullRequests(request, browser);

            return(Json(response));
        }
Esempio n. 5
0
 public void CreateSearchRepository_NoBitBucket_ThrowsException()
 {
     Assert.Throws <NotSupportedException>(() =>
                                           RepoBrowserFactory.CreateRepoBrowser(_bitBucketOrg, _repoConfigList, null));
 }
Esempio n. 6
0
        public void CreateSearchRepository_GH_RepoCreated()
        {
            IRepoBrowser searchRepo = RepoBrowserFactory.CreateRepoBrowser(_gitHubOrg, _repoConfigList, null);

            Assert.IsType <GithubRepoBrowser>(searchRepo);
        }