public async Task FlipToggles_HavingSheduledTimeInThePast()
        {
            //arrange
            var app = Application.Create("tst", "DEV", false);

            app.AddFeatureToggle("offToggle", null, "workItemId1");
            app.AddFeatureToggle("onToggle", null, "workItemId1");
            app.SetToggle(app.FeatureToggles.Single(f => f.ToggleName == "offToggle").Id, "DEV", false, "username");
            app.SetToggle(app.FeatureToggles.Single(f => f.ToggleName == "onToggle").Id, "DEV", true, "username");
            await _appRepository.AddAsync(app);

            var schedule  = ToggleSchedule.Create("tst", "offToggle", new[] { "DEV" }, true, _dateInThePast, "updatedBy", true);
            var schedule2 = ToggleSchedule.Create("tst", "onToggle", new[] { "DEV" }, false, _dateInThePast, "updatedBy", true);
            await _toggleSchedulesRepository.AddAsync(schedule);

            await _toggleSchedulesRepository.AddAsync(schedule2);

            //act
            await _sut.StartAsync(_cts.Token);

            await _sut.StopAsync(_cts.Token);

            //assert
            var updatedApp = await _appRepository.FindByIdAsync(app.Id);

            var status = FeatureToggleTestHelper.GetFeatureToggleStatus(updatedApp, "offtoggle", "DEV");

            status.Enabled.Should().BeTrue();
            var status2 = FeatureToggleTestHelper.GetFeatureToggleStatus(updatedApp, "onToggle", "DEV");

            status2.Enabled.Should().BeFalse();
        }
        public async Task WhenThereAreNoSchedulesDoNothing()
        {
            //arrange
            var app = Application.Create("tst", "DEV", false);

            app.AddFeatureToggle("t1", null, "workItemId1");
            await _appRepository.AddAsync(app);

            //act
            await _sut.StartAsync(_cts.Token);

            await _sut.StopAsync(_cts.Token);

            //assert
            var updatedApp = await _appRepository.FindByIdAsync(app.Id);

            var status = FeatureToggleTestHelper.GetFeatureToggleStatus(updatedApp, "t1", "DEV");

            status.Enabled.Should().BeFalse();
        }
Пример #3
0
        public async Task EveryExistingFeatureToggle_IsMarkedAs_Off_ForTheNewEnvironment()
        {
            //arrange
            var app = Application.Create("TestApp", "DEV", false);

            app.AddFeatureToggle("t1", string.Empty, "workItemId1");
            app.AddFeatureToggle("t2", string.Empty, "workItemId2");
            await _appRepository.AddAsync(app);

            var newEnvironment = new AddEnvironmentModel {
                ApplicationId = app.Id, EnvName = "QA"
            };

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

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

            FeatureToggleTestHelper.GetFeatureToggleStatus(savedApp, "t1", "QA").Enabled.Should().BeFalse();
            FeatureToggleTestHelper.GetFeatureToggleStatus(savedApp, "t2", "QA").Enabled.Should().BeFalse();
        }