public void GetFeatureState_ReturnsDisabledFeatureState_ForDisabledParentFeature() { // Arrange var moduleId = new ModuleId("Test"); var parentFeatureId = new FeatureId(moduleId, "ParentFeature"); var parentFeature = new TestFeature(parentFeatureId); var childFeatureId = new FeatureId(moduleId, parentFeatureId, "ChildFeature"); var childFeature = new TestFeature(childFeatureId); var featureProvider = CreateFeatureProvider(parentFeature, childFeature); var configuration = CreateConfiguration(new Dictionary <string, string> { ["Features:Test.ParentFeature:Enabled"] = "false", ["Features:Test.ParentFeature.ChildFeature:Enabled"] = "true" }); var featureStateProvider = new FeatureStateProvider(featureProvider, configuration); // Act var state = featureStateProvider.GetFeatureState(childFeatureId); // Assert Assert.NotNull(state); Assert.Equal(childFeatureId, state.FeatureId); Assert.False(state.Enabled); Assert.NotNull(state.ConfigurationSection); }
public void GetFeatureState_ReturnsFeatureState_ForUnknownFeature() { // Arrange var moduleId = new ModuleId("Test"); var featureId = new FeatureId(moduleId, "FeatureA"); var featureProvider = CreateFeatureProvider(); var configuration = CreateConfiguration(new Dictionary <string, string> { }); var featureStateProvider = new FeatureStateProvider(featureProvider, configuration); // Act var state = featureStateProvider.GetFeatureState(featureId); // Assert Assert.NotNull(state); Assert.Equal(featureId, state.FeatureId); Assert.False(state.Enabled); Assert.NotNull(state.ConfigurationSection); }
public void GetFeatureState_ReturnsEnabledFeatureState_WhenConfigurationMissing_AndFeatureEnabledByDefault() { // Arrange var moduleId = new ModuleId("Test"); var featureId = new FeatureId(moduleId, "FeatureA"); var feature = new TestFeature(featureId, enabledByDefault: true); var featureProvider = CreateFeatureProvider(feature); var configuration = CreateConfiguration(new Dictionary <string, string> { }); var featureStateProvider = new FeatureStateProvider(featureProvider, configuration); // Act var state = featureStateProvider.GetFeatureState(featureId); // Assert Assert.NotNull(state); Assert.Equal(featureId, state.FeatureId); Assert.True(state.Enabled); Assert.NotNull(state.ConfigurationSection); }
public void GetFeatureState_ReturnsDisabledFeatureState_ForNestedBooleanValue() { // Arrange var moduleId = new ModuleId("Test"); var featureId = new FeatureId(moduleId, "FeatureA"); var feature = new TestFeature(featureId); var featureProvider = CreateFeatureProvider(feature); var configuration = CreateConfiguration(new Dictionary <string, string> { ["Features:Test.FeatureA:Enabled"] = "false" }); var featureStateProvider = new FeatureStateProvider(featureProvider, configuration); // Act var state = featureStateProvider.GetFeatureState(featureId); // Assert Assert.NotNull(state); Assert.Equal(featureId, state.FeatureId); Assert.False(state.Enabled); Assert.NotNull(state.ConfigurationSection); }