Пример #1
0
        public async Task AzDeploymentsSampleControllerIntegrationTest()
        {
            //Arrange
            bool   getSampleData    = true;
            string patToken         = Configuration["AppSettings:AzureDevOpsPatToken"];
            string organization     = "samsmithnz";
            string project          = "SamLearnsAzure";
            string branch           = "refs/heads/master";
            string buildName        = "SamLearnsAzure.CI";
            int    numberOfDays     = 7;
            int    maxNumberOfItems = 20;
            bool   useCache         = false;
            DeploymentFrequencyController controller = new DeploymentFrequencyController(Configuration);

            //Act
            DeploymentFrequencyModel model = await controller.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken, organization, project, branch, buildName, numberOfDays, maxNumberOfItems, useCache);

            //Assert
            Assert.AreEqual(DevOpsPlatform.AzureDevOps, model.TargetDevOpsPlatform);
            Assert.AreEqual(buildName, model.DeploymentName);
            Assert.AreEqual(10f, model.DeploymentsPerDayMetric);
            Assert.AreEqual("Elite", model.DeploymentsPerDayMetricDescription);
            Assert.AreEqual(10, model.BuildList.Count);
            Assert.AreEqual(70, model.BuildList[0].BuildDurationPercent);
            Assert.AreEqual("1", model.BuildList[0].BuildNumber);
            Assert.AreEqual("master", model.BuildList[0].Branch);
            Assert.AreEqual("completed", model.BuildList[0].Status);
            Assert.AreEqual("https://dev.azure.com/samsmithnz/samlearnsazure/1", model.BuildList[0].Url);
            Assert.IsTrue(model.BuildList[0].StartTime > DateTime.MinValue);
            Assert.IsTrue(model.BuildList[0].EndTime > DateTime.MinValue);
        }
Пример #2
0
        public async Task AzDeploymentsCacheControllerIntegrationTest()
        {
            //https://devopsmetrics-prod-eu-service.azurewebsites.net//api/DeploymentFrequency/GetAzureDevOpsDeploymentFrequency?getSampleData=False&patToken=&organization=samsmithnz&project=SamLearnsAzure&branch=refs/heads/master&buildName=SamLearnsAzure.CI&buildId=3673&numberOfDays=30&maxNumberOfItems=20&useCache=true

            //Arrange
            bool   getSampleData    = false;
            string patToken         = Configuration["AppSettings:AzureDevOpsPatToken"];
            string organization     = "samsmithnz";
            string project          = "SamLearnsAzure";
            string branch           = "refs/heads/master";
            string buildName        = "SamLearnsAzure.CI";
            int    numberOfDays     = 30;
            int    maxNumberOfItems = 20;
            bool   useCache         = true;
            DeploymentFrequencyController controller = new DeploymentFrequencyController(Configuration);

            //Act
            DeploymentFrequencyModel model = await controller.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken, organization, project, branch, buildName, numberOfDays, maxNumberOfItems, useCache);

            //Assert
            Assert.IsTrue(model != null);
            if (model.RateLimitHit == false)
            {
                Assert.AreEqual(DevOpsPlatform.AzureDevOps, model.TargetDevOpsPlatform);
                Assert.AreEqual(buildName, model.DeploymentName);
                Assert.IsTrue(model.DeploymentsPerDayMetric >= 0f);
                Assert.IsTrue(string.IsNullOrEmpty(model.DeploymentsPerDayMetricDescription) == false);
                Assert.IsTrue(model.BuildList.Count >= 0);
                if (model.BuildList.Count > 0)
                {
                    Assert.IsTrue(model.BuildList[0].BuildDurationPercent >= 0f);
                    Assert.IsTrue(string.IsNullOrEmpty(model.BuildList[0].BuildNumber) == false);
                    Assert.IsTrue(string.IsNullOrEmpty(model.BuildList[0].Branch) == false);
                    Assert.IsTrue(string.IsNullOrEmpty(model.BuildList[0].Status) == false);
                    Assert.IsTrue(string.IsNullOrEmpty(model.BuildList[0].Url) == false);
                    Assert.IsTrue(model.BuildList[0].StartTime > DateTime.MinValue);
                    Assert.IsTrue(model.BuildList[0].EndTime > DateTime.MinValue);
                }
                Assert.AreEqual(numberOfDays, model.NumberOfDays);
                Assert.AreEqual(maxNumberOfItems, model.MaxNumberOfItems);
                Assert.IsTrue(model.TotalItems > 0);
            }
        }