public async Task GetApplicationFeatureToggleValue_ReturnsTheStatus_OfTheGivenFeatureToggle() { //arrange var app = Application.Create("TestApp", "DEV", false); app.AddDeployEnvironment("QA", false, false, false); app.AddFeatureToggle("t1", "", "workItemId1"); var toggle = app.FeatureToggles.FirstOrDefault(f => f.ToggleName == "t1"); app.SetToggle(toggle.Id, "DEV", false, "username"); app.SetToggle(toggle.Id, "QA", true, "username"); await _appRepository.AddAsync(app); //act var result = await _featureToggleController.GetApplicationFeatureToggleValue(app.AppName, "QA", "t1") as OkObjectResult; var okObjectResult = result.Value as ApplicationFeatureToggleViewModel; //assert okObjectResult.FeatureToggleName.Should().Be("t1"); okObjectResult.IsEnabled.Should().BeTrue(); }
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(); }