public void GetReleaseReport1()
        {
            var zenHubReleaseId = MockServer.ZenHubReleaseId;

            var result = _zenhubClient.GetReleaseClient(zenHubReleaseId).GetReportAsync().GetAwaiter().GetResult();

            Assert.NotNull(result);
            Assert.AreEqual("59d3cd520a430a6344fd3bdb", result.Value.ReleaseId);
        }
Exemplo n.º 2
0
        public void ReleasesMethods_Null()
        {
            ZenHubClient zh    = new ZenHubClient("dummy");
            var          relCl = zh.GetReleaseClient("release");

            Assert.Throws <ArgumentNullException>(() => relCl.AddRepositoryAsync(null).GetAwaiter().GetResult());
            Assert.Throws <ArgumentNullException>(() => relCl.RemoveRepositoryAsync(null).GetAwaiter().GetResult());
        }
        private async Task <Dictionary <IssueType, List <Issue> > > GetIssuesByType(string releaseId)
        {
            var issuesByType = new Dictionary <IssueType, List <Issue> >();

            ZenHubReleaseClient releaseClient = ZenHubClient.GetReleaseClient(releaseId);

            IssueDetails[] zenHubIssueList   = (await releaseClient.GetIssuesAsync()).Value;
            string[]       repoParts         = Options.Repo.Split('/');
            var            primaryRepository = await GitHubClient.Repository.Get(repoParts[0], repoParts[1]);

            foreach (IssueDetails details in zenHubIssueList)
            {
                if (details.RepositoryId != primaryRepository.Id)
                {
                    // skip all issues which aren't in our primary repo
                    continue;
                }

                Issue issue = await GitHubClient.Issue.Get(repoParts[0], repoParts[1], details.IssueNumber);

                bool      issueFixed = true;
                bool      hidden     = false;
                IssueType issueType  = IssueType.None;
                bool      epicLabel  = false;
                bool      regressionDuringThisVersion = false;
                bool      engImproveOrDocs            = false;
                string    requiredLabel      = Options.RequiredLabel?.ToLower();
                bool      foundRequiredLabel = string.IsNullOrEmpty(requiredLabel);

                if (issue.State == ItemState.Open)
                {
                    issueType = IssueType.StillOpen;
                }
                else
                {
                    foreach (var label in issue.Labels)
                    {
                        if (label.Name.Contains(IssueLabels.ClosedPrefix))
                        {
                            issueFixed = false;
                        }

                        if (label.Name == IssueLabels.RegressionDuringThisVersion)
                        {
                            regressionDuringThisVersion = true;
                            hidden = true;
                        }

                        if (label.Name == IssueLabels.EngImprovement || label.Name == IssueLabels.Test || label.Name == IssueLabels.Docs)
                        {
                            engImproveOrDocs = true;
                            hidden           = true;
                        }

                        if (!foundRequiredLabel && label.Name.ToLower() == requiredLabel)
                        {
                            foundRequiredLabel = true;
                        }

                        if (label.Name == IssueLabels.Epic)
                        {
                            epicLabel = true;
                        }
                        else if (label.Name == IssueLabels.Feature)
                        {
                            issueType = IssueType.Feature;
                        }
                        else if (label.Name == IssueLabels.DCR)
                        {
                            issueType = IssueType.DCR;
                        }
                        else if (label.Name == IssueLabels.Bug)
                        {
                            issueType = IssueType.Bug;
                        }
                        else if (label.Name == IssueLabels.Spec)
                        {
                            issueType = IssueType.Spec;
                        }
                    }
                }
                if (!foundRequiredLabel)
                {
                    hidden = true;
                }

                // if an issue is an epicLabel and has a real IssueType (feature/bug/dcr),
                // then hide it... we want to show the primary epic issue only.
                if (epicLabel)
                {
                    if (issueType == IssueType.None)
                    {
                        issueType = IssueType.Feature;
                    }
                    else
                    {
                        hidden = true;
                    }
                }
                else if (issueType == IssueType.None)
                {
                    if (!(issueFixed && !regressionDuringThisVersion && !engImproveOrDocs))
                    {
                        hidden = true;
                    }
                }

                if (!hidden && issueFixed)
                {
                    if (!issuesByType.ContainsKey(issueType))
                    {
                        issuesByType.Add(issueType, new List <Issue>());
                    }

                    issuesByType[issueType].Add(issue);
                }
            }

            return(issuesByType);
        }
Exemplo n.º 4
0
        public void GetReleaseClient_Null()
        {
            ZenHubClient zh = new ZenHubClient("dummy");

            Assert.Throws <ArgumentNullException>(() => zh.GetReleaseClient(null));
        }