public async Task GHDeploymentFrequencyDAIntegrationTest() { //Arrange bool getSampleData = true; string clientId = Configuration["AppSettings:GitHubClientId"]; string clientSecret = Configuration["AppSettings:GitHubClientSecret"]; TableStorageAuth tableStorageAuth = Common.GenerateTableAuthorization(Configuration); string owner = "samsmithnz"; string repo = "DevOpsMetrics"; string branch = "master"; string workflowName = "DevOpsMetrics CI/CD"; string workflowId = "1162561"; int numberOfDays = 30; int maxNumberOfItems = 20; bool useCache = true; //Act DeploymentFrequencyDA da = new DeploymentFrequencyDA(); DeploymentFrequencyModel model = await da.GetGitHubDeploymentFrequency(getSampleData, clientId, clientSecret, tableStorageAuth, owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems, useCache); //Assert Assert.IsTrue(model.DeploymentsPerDayMetric > 0f); Assert.AreEqual(false, string.IsNullOrEmpty(model.DeploymentsPerDayMetricDescription)); Assert.AreNotEqual("Unknown", model.DeploymentsPerDayMetricDescription); Assert.AreEqual(10f, model.DeploymentsToDisplayMetric); Assert.AreEqual("per day", model.DeploymentsToDisplayUnit); Assert.AreEqual(numberOfDays, model.NumberOfDays); Assert.IsTrue(model.MaxNumberOfItems > 0); Assert.IsTrue(model.TotalItems > 0); Assert.IsTrue(model.IsProjectView == false); Assert.IsTrue(model.ItemOrder == 0); }
public async Task <DeploymentFrequencyModel> GetGitHubDeploymentFrequency(bool getSampleData, string clientId, string clientSecret, string owner, string repo, string branch, string workflowName, string workflowId, int numberOfDays, int maxNumberOfItems, bool useCache) { DeploymentFrequencyModel model = new DeploymentFrequencyModel(); try { TableStorageAuth tableStorageAuth = Common.GenerateTableAuthorization(Configuration); DeploymentFrequencyDA da = new DeploymentFrequencyDA(); model = await da.GetGitHubDeploymentFrequency(getSampleData, clientId, clientSecret, tableStorageAuth, owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems, useCache); } catch (Exception ex) { if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).") { model.DeploymentName = workflowName; model.RateLimitHit = true; } else { throw; } } return(model); }
public async Task AzDeploymentFrequencyDAIntegrationTest() { //Arrange bool getSampleData = true; string patToken = Configuration["AppSettings:AzureDevOpsPatToken"]; TableStorageAuth tableStorageAuth = Common.GenerateTableAuthorization(Configuration); string organization = "samsmithnz"; string project = "SamLearnsAzure"; string branch = "refs/heads/master"; string buildName = "SamLearnsAzure.CI"; int numberOfDays = 30; int maxNumberOfItems = 20; bool useCache = true; //Act DeploymentFrequencyDA da = new DeploymentFrequencyDA(); DeploymentFrequencyModel model = await da.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken, tableStorageAuth, organization, project, branch, buildName, numberOfDays, maxNumberOfItems, useCache); //Assert Assert.IsTrue(model.DeploymentsPerDayMetric > 0f); Assert.AreEqual(false, string.IsNullOrEmpty(model.DeploymentsPerDayMetricDescription)); Assert.AreNotEqual("Unknown", model.DeploymentsPerDayMetricDescription); Assert.AreEqual(10f, model.DeploymentsToDisplayMetric); Assert.AreEqual("per day", model.DeploymentsToDisplayUnit); Assert.AreEqual(numberOfDays, model.NumberOfDays); Assert.IsTrue(model.MaxNumberOfItems > 0); Assert.IsTrue(model.TotalItems > 0); Assert.IsTrue(model.IsProjectView == false); Assert.IsTrue(model.ItemOrder == 0); }
public async Task <DeploymentFrequencyModel> GetAzureDevOpsDeploymentFrequency(bool getSampleData, string patToken, string organization, string project, string branch, string buildName, int numberOfDays, int maxNumberOfItems, bool useCache) { DeploymentFrequencyModel model = new DeploymentFrequencyModel(); try { TableStorageAuth tableStorageAuth = Common.GenerateTableAuthorization(Configuration); DeploymentFrequencyDA da = new DeploymentFrequencyDA(); model = await da.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken, tableStorageAuth, organization, project, branch, buildName, numberOfDays, maxNumberOfItems, useCache); } catch (Exception ex) { if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).") { model.DeploymentName = buildName; model.RateLimitHit = true; } else { throw; } } return(model); }