public void CreateFeature_ReturnsFeature_ForDisabledFeatureService() { // Arrange var moduleId = new ModuleId("Test"); var featureId = new FeatureId(moduleId, "Test"); var config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string> { ["Features:Test.Test:Enabled"] = "false" }) .Build(); var featureStateProvider = CreateFeatureStateProvider( new FeatureState(featureId, config.GetSection("Features:Test.Test"), false)); var workContext = new WorkContext(); var factory = new FeatureFactory <string>(featureStateProvider, workContext); // Act var feature = factory.CreateFeature( CreateServiceProvider((string)null), featureId); // Assert Assert.NotNull(feature); Assert.Null(feature.Service); Assert.False(feature.Enabled); Assert.True(feature.Missing); }
public void CreateFeature_ReturnsFeature_ForValidFeatureService() { // Arrange var moduleId = new ModuleId("Test"); var featureId = new FeatureId(moduleId, "Test"); var config = new ConfigurationBuilder().Build(); var featureStateProvider = CreateFeatureStateProvider( new FeatureState(featureId, config.GetSection("Features:Test.Test"), true)); var workContext = new WorkContext(); var factory = new FeatureFactory <string>(featureStateProvider, workContext); // Act var feature = factory.CreateFeature( CreateServiceProvider("StringService"), featureId); // Assert Assert.NotNull(feature); Assert.Equal("StringService", feature.Service); Assert.True(feature.Enabled); Assert.False(feature.Missing); }