public void Should_activate_all_upstream_dependencies_first()
        {
            var order = new List<Feature>();

            var dependingFeature = new DependsOnAtLeastOne_Feature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new MyFeature1
            {
                OnActivation = f => order.Add(f)
            };
            var feature2 = new MyFeature2
            {
                OnActivation = f => order.Add(f)
            };
            var feature3 = new MyFeature3
            {
                OnActivation = f => order.Add(f)
            };

            var settings = new SettingsHolder();
            var featureSettings = new FeatureActivator(settings);

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);
            featureSettings.Add(feature2);
            featureSettings.Add(feature3);

            settings.EnableFeatureByDefault<MyFeature1>();
            settings.EnableFeatureByDefault<MyFeature2>();
            settings.EnableFeatureByDefault<MyFeature3>();

            featureSettings.SetupFeatures(null, null, null, null);

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<MyFeature1>(order[0], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf<MyFeature2>(order[1], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf<MyFeature3>(order[2], "Upstream dependencies should be activated first");
        }
示例#2
0
        public void Should_activate_all_upstream_dependencies_first()
        {
            var defaultsOrder = new List <Feature>();

            var dependingFeature = new DependsOnAtLeastOne_Feature
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature = new MyFeature1
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature2 = new MyFeature2
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature3 = new MyFeature3
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);
            featureSettings.Add(feature2);
            featureSettings.Add(feature3);

            settings.EnableFeatureByDefault <MyFeature1>();
            settings.EnableFeatureByDefault <MyFeature2>();
            settings.EnableFeatureByDefault <MyFeature3>();

            featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf <MyFeature1>(defaultsOrder[0], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf <MyFeature2>(defaultsOrder[1], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf <MyFeature3>(defaultsOrder[2], "Upstream dependencies should be activated first");
        }
        public void Should_activate_all_upstream_dependencies_first()
        {
            var defaultsOrder = new List<Feature>();

            var dependingFeature = new DependsOnAtLeastOne_Feature
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature = new MyFeature1
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature2 = new MyFeature2
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature3 = new MyFeature3
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);
            featureSettings.Add(feature2);
            featureSettings.Add(feature3);

            settings.EnableFeatureByDefault<MyFeature1>();
            settings.EnableFeatureByDefault<MyFeature2>();
            settings.EnableFeatureByDefault<MyFeature3>();

            featureSettings.SetupFeatures(null, null);

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<MyFeature1>(defaultsOrder[0], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf<MyFeature2>(defaultsOrder[1], "Upstream dependencies should be activated first");
            Assert.IsInstanceOf<MyFeature3>(defaultsOrder[2], "Upstream dependencies should be activated first");
        }
        public void Should_activate_all_upstream_deps_first()
        {
            var order = new List<Feature>();

            var dependingFeature = new DependsOnAtLeastOne_Feature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new MyFeature1
            {
                OnActivation = f => order.Add(f)
            };
            var feature2 = new MyFeature2
            {
                OnActivation = f => order.Add(f)
            };
            var feature3 = new MyFeature3
            {
                OnActivation = f => order.Add(f)
            };

            var settings = new SettingsHolder();
            var featureSettings = new FeatureActivator(settings);

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);
            featureSettings.Add(feature2);
            featureSettings.Add(feature3);

            settings.EnableFeatureByDefault<MyFeature1>();
            settings.EnableFeatureByDefault<MyFeature2>();
            settings.EnableFeatureByDefault<MyFeature3>();

            featureSettings.SetupFeatures(new FeatureConfigurationContext(null));

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<MyFeature1>(order[0], "Upstream deps should be activated first");
            Assert.IsInstanceOf<MyFeature2>(order[1], "Upstream deps should be activated first");
            Assert.IsInstanceOf<MyFeature3>(order[2], "Upstream deps should be activated first");
        }