Пример #1
0
        public async Task ANewEnvironmentIsBeingCreatedWithProperInformation()
        {
            //arrange
            var app = Application.Create("TestApp", "DEV", false);
            await _appRepository.AddAsync(app);

            var createdEnvironment = new AddEnvironmentModel {
                ApplicationId = app.Id, EnvName = "QA", DefaultToggleValue = true, RequireReasonToChangeWhenToggleEnabled = true, RequireReasonToChangeWhenToggleDisabled = false, SortOrder = 99
            };

            //act
            var result = await _featureToggleController.AddEnvironment(createdEnvironment);

            //assert
            result.Should().BeOfType <OkResult>();
            var savedApp = await _appRepository.FindByIdAsync(app.Id);

            savedApp.DeploymentEnvironments.Count.Should().Be(2);
            var qaEnv = savedApp.DeploymentEnvironments.FirstOrDefault(x => x.EnvName.Equals("QA"));

            qaEnv.Should().NotBeNull();
            qaEnv.DefaultToggleValue.Should().BeTrue();
            qaEnv.SortOrder.Should().Be(99);
            qaEnv.RequireReasonWhenToggleDisabled.Should().BeFalse();
            qaEnv.RequireReasonWhenToggleEnabled.Should().BeTrue();
        }
Пример #2
0
        public void AddEnvironment_FeatureToggleStatus_IsCreated_ForEveryFeatureToggle()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var newEnvironment = new AddEnvironmentModel {
                ApplicationId = 1, EnvName = "DEV"
            };
            var featureOne = new FeatureToggle {
                Application = app, Id = 1, ApplicationId = app.Id, ToggleName = "TestToggle"
            };
            var featureTwo = new FeatureToggle {
                Application = app, Id = 2, ApplicationId = app.Id, ToggleName = "OtherTestToggle"
            };

            _context.Applications.Add(app);
            _context.FeatureToggles.AddRange(featureOne, featureTwo);
            _context.SaveChanges();
            var controller = new FeatureTogglesController(_context);

            //act
            var result = controller.AddEnvironment(newEnvironment);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.FeatureToggleStatuses.Count().Should().Be(2);
        }
Пример #3
0
        public void AddEnvironment_ReturnBadRequestResult_WhenModelStateIsInvalid()
        {
            //arrange
            var controller = new FeatureTogglesController(_context);

            controller.ModelState.AddModelError("error", "some error");

            //act
            var result = controller.AddEnvironment(new AddEnvironmentModel());

            //assert
            result.Should().BeOfType <BadRequestObjectResult>().Which.Should().NotBeNull();
        }
Пример #4
0
        public void AddEnvironment_EnvironmentIsBeingCreated()
        {
            //arrange
            var newEnvironment = new AddEnvironmentModel {
                ApplicationId = 1, EnvName = "DEV"
            };

            var controller = new FeatureTogglesController(_context);

            //act
            var result = controller.AddEnvironment(newEnvironment);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.DeployEnvironments.Count().Should().Be(1);
        }
Пример #5
0
        public void CreateEnvironment_A_NewEnvironmentIsBeingStoredInDB()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var createdEnvironment = new AddEnvironmentModel {
                ApplicationId = app.Id, EnvName = "DEV"
            };
            var controller = new FeatureTogglesController(_context);

            //act
            var result = controller.AddEnvironment(createdEnvironment);

            //assert
            result.Should().BeOfType <OkResult>();
            _context.DeployEnvironments.FirstOrDefault(x => x.EnvName.Equals(createdEnvironment.EnvName)).Should()
            .NotBeNull();
            _context.DeployEnvironments.FirstOrDefault(x => x.DefaultToggleValue == false).Should().NotBeNull();
        }