예제 #1
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);
        }
예제 #2
0
        public void AddFeatureToggle_ReturnBadRequestResult_WhenModelStateIsInvalid()
        {
            //arrange
            var controller = new FeatureTogglesController(_context);

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

            //act
            var result = controller.AddFeatureToggle(new AddFeatureToggleModel());

            //assert
            result.Should().BeOfType <BadRequestObjectResult>().Which.Should().NotBeNull();
        }
예제 #3
0
        public void AddFeatureToggle_ReturnBadRequestResult_WhenApplicationNotSpecified()
        {
            //arrange
            var newFeatureToggle = new AddFeatureToggleModel {
                FeatureToggleName = "TestToggle"
            };

            var controller = new FeatureTogglesController(_context);

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

            //assert
            result.Should().BeOfType <BadRequestObjectResult>().Which.Should().NotBeNull();
        }
예제 #4
0
        public async Task ReturnBadRequestResult_WhenModelStateIsInvalid()
        {
            //arrange
            _featureToggleController.ModelState.AddModelError("error", "some error");

            //act
            var result = await _featureToggleController.AddFeatureToggle(new AddFeatureToggleModel());

            //assert
            result.Should().BeOfType <BadRequestObjectResult>().Which.Should().NotBeNull();
        }
예제 #5
0
        public void AddFeatureToggle_FeatureToggleIsCreated()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "BCC"
            };
            var newFeatureToggle = new AddFeatureToggleModel {
                ApplicationId = app.Id, FeatureToggleName = "TestToggle"
            };

            var controller = new FeatureTogglesController(_context);

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

            //assert
            result.Should().BeOfType <OkResult>();
            _context.FeatureToggles.FirstOrDefault(x => x.ApplicationId == newFeatureToggle.ApplicationId).Should().NotBeNull();
        }
예제 #6
0
        public void AddFeatureToggle_ReturnBadRequestResult_WhenFeatureAlreadyExists()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "BCC"
            };
            var existingFeatureToggle = new FeatureToggle {
                Application = app, Id = 2, ApplicationId = app.Id, ToggleName = "TestToggle"
            };
            var newFeatureToggle = new AddFeatureToggleModel {
                ApplicationId = app.Id, FeatureToggleName = "TestToggle"
            };

            _context.FeatureToggles.Add(existingFeatureToggle);
            _context.SaveChanges();

            var controller = new FeatureTogglesController(_context);

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

            //assert
            result.Should().BeOfType <BadRequestObjectResult>().Which.Should().NotBeNull();
        }