Пример #1
0
        public void EditEnvironment_EnvironmentIsBeingModified()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Application = app, ApplicationId = app.Id, EnvName = "DEV"
            };

            _context.DeployEnvironments.Add(environment);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            var updatedEnvironmentName = "QA";

            var updatedEnvironment = new UpdateEnvironmentModel
            {
                ApplicationId  = environment.ApplicationId,
                InitialEnvName = environment.EnvName,
                NewEnvName     = updatedEnvironmentName
            };

            //act
            var result = controller.UpdateEnvironment(updatedEnvironment);

            //assert
            result.Should().BeOfType <OkResult>();
            environment.EnvName.Should().Be(updatedEnvironmentName);
        }
        public IHttpActionResult PuttblEnvironment(int id, DeployEnvironment tblEnvironment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblEnvironment.envID)
            {
                return(BadRequest());
            }

            db.Entry(tblEnvironment).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblEnvironmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public void DeleteEnvironment_EnvironmentIsDeletedWithInvalidID_ThrowsInvalidOperationException()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv"
            };

            _context.DeployEnvironments.Add(environment);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            var environmentToRemove = new DeleteEnvironmentModel
            {
                ApplicationId = environment.ApplicationId + 1,
                EnvName       = environment.EnvName
            };

            //act
            controller.RemoveEnvironment(environmentToRemove);

            //assert
            //throws InvalidOperationException
        }
Пример #4
0
        public void GetEnvironments_ReturnsAList_WithAllTheDistinctEnvironments_ForTheGivenApplication()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var dev = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 10, EnvName = "DEV"
            };
            var qa = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 11, EnvName = "QA"
            };
            var duplicateQa = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 12, EnvName = "QA"
            };

            var expectedEnvNames = new List <string> {
                dev.EnvName, qa.EnvName
            };

            _context.DeployEnvironments.AddRange(dev, qa, duplicateQa);
            _context.SaveChanges();
            var controller = new FeatureTogglesController(_context);

            //act
            var results = controller.GetEnvironments(app.Id) as OkObjectResult;

            //assert
            results.Value.Should().BeEquivalentTo(expectedEnvNames);
        }
Пример #5
0
        public void AddFeatureToggle_FeatureToggleStatus_IsCreated_ForEveryEnvironment()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "BCC"
            };
            var newFeatureToggle = new AddFeatureToggleModel {
                ApplicationId = app.Id, FeatureToggleName = "TestToggle"
            };
            var devEnv = new DeployEnvironment {
                Application = app, Id = 1, ApplicationId = app.Id, EnvName = "DEV"
            };
            var qaEnv = new DeployEnvironment {
                Application = app, Id = 2, ApplicationId = app.Id, EnvName = "QA"
            };


            _context.DeployEnvironments.AddRange(devEnv, qaEnv);
            _context.Applications.Add(app);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            //act
            var result = controller.AddFeatureToggle(newFeatureToggle);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.FeatureToggleStatuses.Count().Should().Be(2);
        }
Пример #6
0
        public static void GetEnvironmentFromPath_ReturnsExpectedResult(string path,
                                                                        DeployEnvironment expectedEnvironment)
        {
            var result = ConfigParser.GetEnvironmentFromPath(path);

            Assert.That(result, Is.EqualTo(expectedEnvironment));
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var json = JObject.Load(reader);

            var config = new AsimovConfig();
            serializer.Populate(json.CreateReader(), config);

            var self = GetSelf(json);
            if (self != null)
                serializer.Populate(self.CreateReader(), config);
            else
                Log.ErrorFormat("Could not find agent specific config / environment for: {0}", _machineName);

            var environments = config.Environment.Split(',');

            foreach (var environment in environments)
            {
                var envConfigFile = Path.Combine(_configDir, $"config.{environment.Trim()}.json");

                if (!File.Exists(envConfigFile))
                    continue;

                Log.DebugFormat("Loading config file {0}", envConfigFile);
				PopulateFromFile(envConfigFile, serializer, config);

				var env = new DeployEnvironment();
				PopulateFromFile(envConfigFile, serializer, env);
				config.Environments.Add(env);
			}

            return config;
        }
Пример #8
0
        public async Task <List <HocPhanExtend> > getListUnRegistableAsync()
        {
            try
            {
                List <HocPhanExtend> listHocPhan = new List <HocPhanExtend>();
                BaseConnector        connector   = BaseConnector.getInstance();
                BaseResponse         res         = await connector.GetObject(DeployEnvironment.GetEnvironment().GetUnEnrolablePath());

                if (res.status)
                {
                    JsonAttributes jsonAttr = JsonAttributeGetter.GetJsonAttributes();
                    List <Object>  listO    = JsonGetter.getList(res.obj.ToString(), jsonAttr.RES_RESULT());
                    for (int i = 0; i < listO.Count; i++)
                    {
                        HocPhanExtend hocPhan = new HocPhanExtend()
                        {
                            hocPhan = HocPhan.Parse(JsonGetter.getObject(listO[i].ToString(), jsonAttr.RES_SUBJECT())),
                            lyDo    = JsonGetter.getString(listO[i].ToString(), jsonAttr.RES_REASON())
                        };
                        listHocPhan.Add(hocPhan);
                    }
                }
                return(listHocPhan);
            }
            catch (Exception ex)
            {
                LogHelper.Log("ERROR: " + ex);
                return(null);
            }
        }
Пример #9
0
        public void EditEnvironment_EnvironmentIsModifiedWithInvalidID_ThrowsInvalidOperationException()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Application = app, ApplicationId = app.Id, EnvName = "DEV"
            };

            _context.DeployEnvironments.Add(environment);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            var updatedEnvironmentName = "QA";

            var updatedEnvironment = new UpdateEnvironmentModel
            {
                ApplicationId  = environment.ApplicationId + 1,
                InitialEnvName = environment.EnvName,
                NewEnvName     = updatedEnvironmentName
            };

            //act
            controller.UpdateEnvironment(updatedEnvironment);

            //assert
            //throws InvalidOperationException
        }
Пример #10
0
 // ReSharper disable once MemberCanBePrivate.Global
 internal static void SetDeployEnvironment(
     IEnumerable <ISettingWithEnvironment> settings,
     DeployEnvironment environment)
 {
     foreach (var setting in settings)
     {
         setting.Environment = environment;
     }
 }
Пример #11
0
        public static async Task <bool> sendAuth(string un, string pw)
        {
            BaseConnector connector = BaseConnector.getInstance();
            BaseResponse  res       = await connector.PostObject(DeployEnvironment.GetEnvironment().GetLoginPath(), new AuthRequest()
            {
                mssv = un, password = pw
            });

            return(res.status);
        }
        public async Task <bool> SetListEnrol(List <int> listMaMon)
        {
            BaseConnector        connector = BaseConnector.getInstance();
            RequestEnrolOrCancel req       = new RequestEnrolOrCancel();

            req.subject_ids = listMaMon.ToArray();
            BaseResponse res = await connector.PostObject(DeployEnvironment.GetEnvironment().GetEnrolPath(), req);

            return(res.status);
        }
        public IHttpActionResult PosttblEnvironment(DeployEnvironment tblEnvironment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DeployEnvironments.Add(tblEnvironment);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tblEnvironment.envID }, tblEnvironment));
        }
Пример #14
0
        public void DeleteEnvironment_EnvironmentIsDeleted_FeatureTogglesAreNotDeleted()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv"
            };

            var featureToggle = new FeatureToggle {
                Id = 1
            };

            var controller = new FeatureTogglesController(_context);

            var firstFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 1, FeatureToggle = featureToggle, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var secondFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 2, FeatureToggle = featureToggle, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var thirdFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 3, FeatureToggle = featureToggle, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };

            featureToggle.FeatureToggleStatuses.AddRange(new List <FeatureToggleStatus>()
            {
                firstFeatureStatus, secondFeatureStatus, thirdFeatureStatus
            });

            _context.FeatureToggles.Add(featureToggle);
            _context.FeatureToggleStatuses.AddRange(firstFeatureStatus, secondFeatureStatus, thirdFeatureStatus);
            _context.Applications.Add(app);
            _context.DeployEnvironments.Add(environment);
            _context.SaveChanges();

            var environmentToRemove = new DeleteEnvironmentModel
            {
                ApplicationId = environment.ApplicationId,
                EnvName       = environment.EnvName
            };
            //act
            var result = controller.RemoveEnvironment(environmentToRemove);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.DeployEnvironments.Count().Should().Be(0);
            _context.FeatureToggleStatuses.Count().Should().Be(0);
            _context.FeatureToggles.Count().Should().Be(1);
            _context.FeatureToggles.FirstOrDefault(x => x.Id == 1).FeatureToggleStatuses.Count().Should().Be(0);
        }
Пример #15
0
        public void DeleteApp_AppIsDeleted_EnvironmentsFeatureTogglesAndStatusesAreDeleted()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };

            var environment = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv"
            };
            var environment2 = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv2"
            };
            var environment3 = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv3"
            };

            var featureStatus1 = new FeatureToggleStatus {
                Enabled = false, Id = 1, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var featureStatus2 = new FeatureToggleStatus {
                Enabled = false, Id = 2, IsDeployed = false, Environment = environment2, EnvironmentId = environment2.Id
            };
            var featureStatus3 = new FeatureToggleStatus {
                Enabled = false, Id = 3, IsDeployed = false, Environment = environment3, EnvironmentId = environment3.Id
            };

            var feature = new FeatureToggle {
                Id = 1, Application = app, ApplicationId = app.Id, FeatureToggleStatuses = new List <FeatureToggleStatus> {
                    featureStatus1, featureStatus2, featureStatus3
                }, ToggleName = "Test"
            };

            _context.FeatureToggleStatuses.AddRange(featureStatus1, featureStatus2, featureStatus3);
            _context.Applications.Add(app);
            _context.DeployEnvironments.AddRange(environment, environment2, environment3);
            _context.FeatureToggles.Add(feature);
            _context.SaveChanges();

            var controller = new ApplicationsController(_context);

            //act
            var result = controller.RemoveApp(app.Id);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.Applications.Count().Should().Be(0);
            _context.FeatureToggles.Count().Should().Be(0);
            _context.DeployEnvironments.Count().Should().Be(0);
            _context.FeatureToggleStatuses.Count().Should().Be(0);
        }
        public IHttpActionResult DeletetblEnvironment(int id)
        {
            DeployEnvironment tblEnvironment = db.DeployEnvironments.Find(id);

            if (tblEnvironment == null)
            {
                return(NotFound());
            }

            db.DeployEnvironments.Remove(tblEnvironment);
            db.SaveChanges();

            return(Ok(tblEnvironment));
        }
Пример #17
0
 public async Task <SinhVien> GetSinhVienDetailAsync()
 {
     try
     {
         BaseConnector connector = BaseConnector.getInstance();
         sv.GetDataFromObject((await connector.GetObject(DeployEnvironment.GetEnvironment().GetStudentInfoPath(sv.mssv))).obj);
         return(sv);
     }
     catch (Exception ex)
     {
         LogHelper.Log("ERROR: " + ex);
         return(null);
     }
 }
Пример #18
0
        public void Deploy(DeployEnvironment environment)
        {
            bool startStop = false;
            string displayProfile = "";
            switch (environment)
            {
                case DeployEnvironment.LocalTemp:
                    displayProfile = "Deploy to Local Temp Folder";
                    break;
                case DeployEnvironment.LocalBuildServer:
                    displayProfile = "Deploy to Local Build Server";
                    startStop = true;
                    break;
                case DeployEnvironment.AmazonQa:
                    displayProfile = "Deploy to AWS QA Server";
                    break;
            }

            _feedback.Text("Deploy Profile: " + displayProfile, _feedback.HeaderFontSize, _feedback.HeaderColor);
            _feedback.LineBreak();

            _feedback.Hyperlink("deploy folder", DeployPathConstants.TaasAppDeployFolder);
            _feedback.LineBreak();
            _feedback.LineBreak();

            _feedback.Text("delete deploy folder: " + DeployPathConstants.TaasAppDeployFolder);
            if (_execute)
            {
                if (Directory.Exists(DeployPathConstants.TaasAppDeployFolder))
                    Directory.Delete(DeployPathConstants.TaasAppDeployFolder, true);
                Directory.CreateDirectory(DeployPathConstants.TaasAppDeployFolder);
                _feedback.Text(" deleted and created", null, _feedback.ActionTakenColor);
            }
            _feedback.LineBreak();
            _feedback.LineBreak();

            CopyTaasConsoleFiles();
            CopyToolBox();
            CopyRealTime();
            CopyTaasClientFiles();

            if (startStop)
            {
                _feedback.Text("STEP - Stop Service (if deploying to local build server)", _feedback.HeaderFontSize, _feedback.HeaderColor, true);
                _feedback.LineBreak();
            }
        }
Пример #19
0
        public void GetApplicationFeatureToggles_ReturnsExistingFeaturesStatuses_ForTheGivenApplicationNameAndEnvironmentName()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Application = app, ApplicationId = app.Id, EnvName = "TestEnv"
            };
            var firstFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 1, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var secondFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 2, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var thirdFeatureStatus = new FeatureToggleStatus {
                Enabled = false, Id = 3, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };
            var discardedFeature = new FeatureToggleStatus {
                Enabled = false, Id = 5, IsDeployed = false, Environment = new DeployEnvironment {
                    EnvName = "AnotherEnv"
                }, EnvironmentId = 67
            };
            var feature = new FeatureToggle {
                Id = 1, Application = app, ApplicationId = app.Id, FeatureToggleStatuses = new List <FeatureToggleStatus> {
                    firstFeatureStatus, secondFeatureStatus, thirdFeatureStatus
                }, ToggleName = "Test"
            };

            _context.FeatureToggleStatuses.AddRange(firstFeatureStatus, secondFeatureStatus, thirdFeatureStatus, discardedFeature);
            _context.Applications.Add(app);
            _context.DeployEnvironments.Add(environment);
            _context.FeatureToggles.Add(feature);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            //act
            var result         = controller.GetApplicationFeatureToggles(app.AppName, environment.EnvName) as OkObjectResult;
            var okObjectResult = result.Value as IEnumerable <ApplicationFeatureToggleViewModel>;

            //assert
            okObjectResult.ToList().Count.Should().Be(3);
            okObjectResult.First().FeatureToggleName.Should().Be(firstFeatureStatus.FeatureToggle.ToggleName);
            okObjectResult.First().IsEnabled.Should().Be(firstFeatureStatus.Enabled);
        }
Пример #20
0
        private void Radio_OnChecked(object sender, RoutedEventArgs e)
        {
            if (rbLocalTemp.IsChecked == true)
            {
                _environment = DeployEnvironment.LocalTemp;
            }
            else if (rbLocalBuild.IsChecked == true)
            {
                _environment = DeployEnvironment.LocalBuildServer;
            }
            else if (rbAmazonQA.IsChecked == true)
            {
                _environment = DeployEnvironment.AmazonQa;
            }

            if (IsUcLoaded)
                MainWindow.MainWindowInstance.btnValidate_Click(null, null);
        }
Пример #21
0
        public void SetDeployEnvironment_ReturnsExpectedResult()
        {
            IEnumerable <ISettingWithEnvironment> settings = new[]
            {
                new AssemblyReference {
                    Environment = DeployEnvironment.Production
                },
                new AssemblyReference {
                    Environment = DeployEnvironment.Training
                }
            };

            const DeployEnvironment expectedEnvironment = DeployEnvironment.Lab;

            ConfigParser.SetDeployEnvironment(settings, expectedEnvironment);

            Assert.That(settings.All(s => s.Environment == expectedEnvironment));
        }
Пример #22
0
        public void GetToggles_ReturnsAList_WithAllTheToggles_AndTheStatusesOfThoseToggles_ForTheGivenApplication()
        {
            //arrange
            var app = new Application {
                AppName = "BCC", Id = 1
            };

            var featureToggle = new FeatureToggle {
                Application = app, ApplicationId = app.Id
            };

            var env = new DeployEnvironment {
                Application = app, EnvName = "DEV"
            };

            var devFeatureStatus = new FeatureToggleStatus {
                Id = 1, Environment = env, FeatureToggle = featureToggle, FeatureToggleId = app.Id, Enabled = true, IsDeployed = true
            };
            var qaFeatureStatus = new FeatureToggleStatus {
                Id = 2, Environment = env, FeatureToggle = featureToggle, FeatureToggleId = app.Id, Enabled = false, IsDeployed = false
            };

            _context.FeatureToggles.Add(featureToggle);
            _context.Applications.Add(app);
            _context.DeployEnvironments.Add(env);
            _context.FeatureToggleStatuses.AddRange(devFeatureStatus, qaFeatureStatus);

            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            //act
            var result = controller.GetToggles(app.Id) as OkObjectResult;

            result.Should().NotBeNull();
            var list = result.Value as IEnumerable <FeatureToggleViewModel>;

            //assert
            list.First().Statuses.Count.Should().Be(2);
        }
Пример #23
0
        public void GetApplicationFeatureToggleValue_ReturnsTheStatus_OfTheGivenFeatureToggle()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var environment = new DeployEnvironment
            {
                Id = 2, Application = app, ApplicationId = app.Id, EnvName = "TestEnv"
            };
            var featureStatus = new FeatureToggleStatus {
                Enabled = true, Id = 1, IsDeployed = false, Environment = environment, EnvironmentId = environment.Id
            };

            var feature = new FeatureToggle {
                Id = 1, Application = app, ApplicationId = app.Id, FeatureToggleStatuses = new List <FeatureToggleStatus> {
                    featureStatus
                }, ToggleName = "Test"
            };

            _context.FeatureToggleStatuses.Add(featureStatus);
            _context.Applications.Add(app);
            _context.DeployEnvironments.Add(environment);
            _context.FeatureToggles.Add(feature);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

            //act
            var result         = controller.GetApplicationFeatureToggleValue(app.AppName, environment.EnvName, feature.ToggleName) as OkObjectResult;
            var okObjectResult = result.Value as ApplicationFeatureToggleViewModel;

            //assert
            okObjectResult.FeatureToggleName.Should().Be(feature.ToggleName);
            okObjectResult.IsEnabled.Should().BeTrue();
        }
Пример #24
0
        public static void GetEnvironmentFromSourcePath_ReturnsExpectedResult(string path, DeployEnvironment expectedResult)
        {
            var result = Tools.GetEnvironmentFromSourcePath(path);

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Пример #25
0
 public BuildTaskInfo(string branchName, DeployEnvironment environment, string installerContentRootServerPath)
 {
     this.BranchName  = branchName;
     this.Environment = environment;
     this.InstallerContentRootServerPath = installerContentRootServerPath;
 }
Пример #26
0
 private CommandLineParameters(DeployEnvironment environment, string branchName)
 {
     this.Environment = environment;
     this.BranchName  = branchName;
 }
Пример #27
0
 public DeployableFileDefinition(string relativePath, DeployEnvironment environment)
 {
     this.RelativePath = relativePath;
     this.Environment  = environment;
 }
Пример #28
0
        public static void MapEnvironment_ReturnsExpectedResult(string input, DeployEnvironment expectedOutput)
        {
            var result = DeployEnvironmentHelper.Map(input, true);

            Assert.That(result, Is.EqualTo(expectedOutput));
        }
Пример #29
0
 public BuildOutputFileDefinition(string buildOutputRelativePath, string distributionRelativePath, DeployEnvironment deployEnvironment)
 {
     this.BuildOutputRelativePath  = buildOutputRelativePath;
     this.DistributionRelativePath = distributionRelativePath;
     this.DeployEnvironment        = deployEnvironment;
 }
Пример #30
0
        public async Task <DeployProxyResult> DeployProxyAsync(
            ICakeContext ctx,
            string orgName,
            string envName,
            string proxyName,
            string revisionNumber,
            DeployProxySettings settings)
        {
            ctx.Log.Information("Deploying {0} to Apigee environment {1}", proxyName, envName);
            string url = baseUri
                         + $"v1/o/{orgName}/environments/{envName}/apis/{proxyName}/revisions/{revisionNumber}/deployments";
            List <string> queryParams = new List <string>();

            if (settings?.Override ?? false)
            {
                queryParams.Add("override=" + settings?.Override.Value);
            }

            if (settings?.Delay != null)
            {
                queryParams.Add("delay=" + settings?.Delay.Value.TotalSeconds);
            }

            if (queryParams.Any())
            {
                url += "?" + string.Join("&", queryParams.ToArray());
            }

            using (HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, url))
            {
                if (!string.IsNullOrEmpty(settings?.Credentials?.Username))
                {
                    AddAuthorization(settings.Credentials, message);
                }

                message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                message.Content = new StringContent(string.Empty, Encoding.UTF8, "application/x-www-form-urlencoded");
                var result = await SendMessage <DeployProxyResult>(ctx, message, settings);

                // First deploy results in state being set
                if (result.State == "deployed")
                {
                    return(result);
                }

                // Otherwise need to check the environments
                DeployEnvironment environment = null;
                if (result.Environment != null)
                {
                    if (result.Environment is JArray)
                    {
                        var environments = ((JArray)result.Environment).ToObject <IEnumerable <DeployEnvironment> >();
                        environment =
                            environments.FirstOrDefault(
                                env =>
                                env.Revision == revisionNumber &&
                                env.State == "deployed" &&
                                env.Environment == envName);
                    }
                    else
                    {
                        environment = ((JObject)result.Environment).ToObject <DeployEnvironment>();

                        // Dirty
                        if (environment.State != "deployed")
                        {
                            environment = null;
                        }
                    }
                }

                if (environment == null)
                {
                    throw new Exception("Did not find a successful deployment");
                }

                return(result);
            }
        }
Пример #31
0
        public static void MapEnvironment_ReturnsExpectedResult(string path, DeployEnvironment expectedResult)
        {
            var result = DeployEnvironmentHelper.MapEnvironment(path);

            Assert.That(result, Is.EqualTo(expectedResult));
        }