Example #1
0
        public async Task <LeadTimeForChangesModel> GetAzureDevOpsLeadTimeForChanges(bool getSampleData, string patToken,
                                                                                     string organization, string project, string repositoryId, string branch, string buildName,
                                                                                     int numberOfDays, int maxNumberOfItems, bool useCache)
        {
            LeadTimeForChangesModel model = new LeadTimeForChangesModel();

            try
            {
                TableStorageAuth     tableStorageAuth = Common.GenerateTableAuthorization(Configuration);
                LeadTimeForChangesDA da = new LeadTimeForChangesDA();
                model = await da.GetAzureDevOpsLeadTimesForChanges(getSampleData, patToken, tableStorageAuth,
                                                                   organization, project, repositoryId, branch, buildName, numberOfDays, maxNumberOfItems, useCache);
            }
            catch (Exception ex)
            {
                if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).")
                {
                    model.ProjectName  = project;
                    model.RateLimitHit = true;
                }
                else
                {
                    throw;
                }
            }
            return(model);
        }
Example #2
0
        public async Task AzLeadTimeForChangesDAIntegrationTest()
        {
            //Arrange
            bool             getSampleData    = true;
            string           patToken         = Configuration["AppSettings:AzureDevOpsPatToken"];
            TableStorageAuth tableStorageAuth = Common.GenerateTableAuthorization(Configuration);
            string           organization     = "samsmithnz";
            string           project          = "SamLearnsAzure";
            string           repositoryId     = "SamLearnsAzure";
            string           masterBranch     = "refs/heads/master";
            string           buildName        = "SamLearnsAzure.CI";
            int  numberOfDays     = 7;
            int  maxNumberOfItems = 20;
            bool useCache         = true;

            //Act
            LeadTimeForChangesDA    da    = new LeadTimeForChangesDA();
            LeadTimeForChangesModel model = await da.GetAzureDevOpsLeadTimesForChanges(getSampleData, patToken, tableStorageAuth,
                                                                                       organization, project, repositoryId, masterBranch, buildName,
                                                                                       numberOfDays, maxNumberOfItems, useCache);

            //Assert
            Assert.IsTrue(model != null);
            Assert.AreEqual(project, model.ProjectName);
            Assert.IsTrue(model.PullRequests.Count > 0);
            Assert.IsTrue(model.PullRequests.Count <= 20);
            Assert.AreEqual("123", model.PullRequests[0].PullRequestId);
            Assert.AreEqual("branch1", model.PullRequests[0].Branch);
            Assert.AreEqual(1, model.PullRequests[0].BuildCount);
            Assert.IsTrue(model.PullRequests[0].Commits.Count > 0);
            Assert.AreEqual("abc", model.PullRequests[0].Commits[0].commitId);
            Assert.IsTrue(model.PullRequests[0].Commits[0].date >= DateTime.MinValue);
            Assert.AreEqual("name1", model.PullRequests[0].Commits[0].name);
            Assert.AreEqual(60, Math.Round(model.PullRequests[0].Duration.TotalMinutes, 0));
            Assert.AreEqual(33f, model.PullRequests[0].DurationPercent);
            Assert.IsTrue(model.PullRequests[0].StartDateTime >= DateTime.MinValue);
            Assert.IsTrue(model.PullRequests[0].EndDateTime >= DateTime.MinValue);
            Assert.AreEqual(1f, model.AverageBuildHours);
            Assert.AreEqual(12f, model.AveragePullRequestHours);
            Assert.AreEqual(13f, model.LeadTimeForChangesMetric);
            Assert.AreEqual("Elite", model.LeadTimeForChangesMetricDescription);
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems > 0);
            Assert.IsTrue(model.TotalItems > 0);
        }