public void Should_enable_features_in_defaults() { var defaultsOrder = new List <Feature>(); var activatedOrder = new List <Feature>(); var level1 = new Activate1 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level2 = new Activate2 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level3 = new Activate3 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var settings = new SettingsHolder(); var featureSettings = new FeatureActivator(settings); //the orders matter here to expose a bug featureSettings.Add(level3); featureSettings.Add(level2); featureSettings.Add(level1); featureSettings.SetupFeatures(new FeatureConfigurationContext(null)); Assert.True(level1.IsActive, "Activate1 wasn't activated"); Assert.True(level2.IsActive, "Activate2 wasn't activated"); Assert.True(level3.IsActive, "Activate3 wasn't activated"); Assert.IsInstanceOf <Activate1>(defaultsOrder[0], "Upstream deps should be activated first"); Assert.IsInstanceOf <Activate2>(defaultsOrder[1], "Upstream deps should be activated first"); Assert.IsInstanceOf <Activate3>(defaultsOrder[2], "Upstream deps should be activated first"); CollectionAssert.AreEqual(defaultsOrder, activatedOrder); }
public void Should_enable_features_in_defaults() { var defaultsOrder = new List<Feature>(); var activatedOrder = new List<Feature>(); var level1 = new Activate1 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level2 = new Activate2 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level3 = new Activate3 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var settings = new SettingsHolder(); var featureSettings = new FeatureActivator(settings); //the orders matter here to expose a bug featureSettings.Add(level3); featureSettings.Add(level2); featureSettings.Add(level1); featureSettings.SetupFeatures(new FeatureConfigurationContext(null)); Assert.True(level1.IsActive, "Activate1 wasn't activated"); Assert.True(level2.IsActive, "Activate2 wasn't activated"); Assert.True(level3.IsActive, "Activate3 wasn't activated"); Assert.IsInstanceOf<Activate1>(defaultsOrder[0], "Upstream deps should be activated first"); Assert.IsInstanceOf<Activate2>(defaultsOrder[1], "Upstream deps should be activated first"); Assert.IsInstanceOf<Activate3>(defaultsOrder[2], "Upstream deps should be activated first"); CollectionAssert.AreEqual(defaultsOrder, activatedOrder); }