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 }
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 async Task EnvironmentIsBeingModified() { //arrange var app = Application.Create("TestApp", "DEV", false); await _appRepository.AddAsync(app); var updatedEnvironmentName = "QA"; var updatedEnvironment = new UpdateEnvironmentModel { ApplicationId = app.Id, InitialEnvName = "DEV", NewEnvName = updatedEnvironmentName, RequireReasonForChangeWhenToggleEnabled = false, RequireReasonForChangeWhenToggleDisabled = true }; //act var result = await _featureToggleController.UpdateEnvironment(updatedEnvironment); //assert result.Should().BeOfType <OkResult>(); (await _appRepository.FindByIdAsync(app.Id)).DeploymentEnvironments.First().EnvName.Should().Be(updatedEnvironmentName); }