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

            var dependingFeature = new NamespaceB.MyFeature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new NamespaceA.MyFeature
            {
                OnActivation = f => order.Add(f)
            };

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

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

            settings.EnableFeatureByDefault<NamespaceA.MyFeature>();

            featureSettings.SetupFeatures(null, null);

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<NamespaceA.MyFeature>(order.First(), "Upstream dependencies should be activated first");
        }
        public void Should_activate_named_dependency_first()
        {
            var order = new List<Feature>();

            var dependingFeature = new DependsOnOneByName_Feature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new MyFeature2
            {
                OnActivation = f => order.Add(f)
            };

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

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

            settings.EnableFeatureByDefault<MyFeature2>();

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

            Assert.True(dependingFeature.IsActive);
            Assert.IsInstanceOf<MyFeature2>(order.First(), "Upstream dependencies should be activated first");
        }
        public void Should_activate_upstream_dependencies_first()
        {
            var order = new List <Feature>();

            var dependingFeature = new DependsOnOne_Feature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new MyFeature1
            {
                OnActivation = f => order.Add(f)
            };

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

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

            settings.EnableFeatureByDefault <MyFeature1>();

            featureSettings.SetupFeatures(new FakeFeatureConfigurationContext());

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf <MyFeature1>(order.First(), "Upstream dependencies should be activated first");
        }
        public void Should_activate_upstream_deps_first()
        {
            var defaultsOrder = new List<Feature>();

            var dependingFeature = new DependsOnOne_Feature
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature = new MyFeature1
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };

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

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

            settings.EnableFeatureByDefault<MyFeature1>();

            featureSettings.SetupFeatures(new FeatureConfigurationContext(null));

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<MyFeature1>(defaultsOrder.First(), "Upstream deps should be activated first");
        }
        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");
        }
Exemple #6
0
        protected AzureServiceBusTransportInfrastructure(SettingsHolder settings)
        {
            TransactionMode  = settings.SupportedTransactionMode();
            Settings         = settings;
            TopologySettings = settings.GetOrCreate <TopologySettings>();

            var individualizationStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Individualization.Strategy);

            individualization = individualizationStrategyType.CreateInstance <IIndividualizationStrategy>(Settings);

            var compositionStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Composition.Strategy);
            var compositionStrategy     = compositionStrategyType.CreateInstance <ICompositionStrategy>(Settings);

            var sanitizationStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.Strategy);
            var sanitizationStrategy     = sanitizationStrategyType.CreateInstance <ISanitizationStrategy>(Settings);

            addressingLogic = new AddressingLogic(sanitizationStrategy, compositionStrategy);

            settings.EnableFeatureByDefault <TransactionScopeSuppressFeature>();
        }
Exemple #7
0
        public AzureServiceBusTransportInfrastructure(SettingsHolder settings, string connectionString)
        {
            this.settings           = settings;
            connectionStringBuilder = new ServiceBusConnectionStringBuilder(connectionString);

            if (settings.TryGet(SettingsKeys.TransportType, out TransportType transportType))
            {
                connectionStringBuilder.TransportType = transportType;
            }

            settings.TryGet(SettingsKeys.CustomTokenProvider, out tokenProvider);

            if (!settings.TryGet(SettingsKeys.TopicName, out topicName))
            {
                topicName = defaultTopicName;
            }

            settings.EnableFeatureByDefault <TransactionScopeSuppressFeature>();

            namespacePermissions = new NamespacePermissions(connectionStringBuilder, tokenProvider);

            WriteStartupDiagnostics();
        }
Exemple #8
0
 private void SetupTimeoutSettings(SettingsHolder s)
 {
     Logger.Debug("Enabling EntityFramework timeout storage");
     s.EnableFeatureByDefault <EntityFrameworkTimeoutStorageFeature>();
 }
Exemple #9
0
 private void SetupSubscriptionSettings(SettingsHolder s)
 {
     Logger.Debug("Enabling EntityFramework subscription storage");
     s.EnableFeatureByDefault <EntityFrameworkSubscriptionStorageFeature>();
 }
Exemple #10
0
 private void SetupSagasSettings(SettingsHolder s)
 {
     Logger.Debug("Enabling EntityFramework saga storage");
     s.EnableFeatureByDefault <EntityFrameworkSagaStorageFeature>();
 }
Exemple #11
0
 /// <summary>
 /// Marks the given feature as enabled by default.
 /// </summary>
 public static SettingsHolder EnableFeatureByDefault <T>(this SettingsHolder settings) where T : Feature
 {
     Guard.AgainstNull(nameof(settings), settings);
     settings.EnableFeatureByDefault(typeof(T));
     return(settings);
 }
 static void EnableSession(SettingsHolder s)
 {
     s.EnableFeatureByDefault <StorageSessionFeature>();
 }
        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);

            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");
        }
Exemple #14
0
 private void SetupOutboxSettings(SettingsHolder s)
 {
     Logger.Debug("Enabling EntityFramework outbox storage");
     s.EnableFeatureByDefault <EntityFrameworkOutboxStorageFeature>();
 }
Exemple #15
0
 /// <summary>
 /// Marks the given feature as enabled by default
 /// </summary>
 public static SettingsHolder EnableFeatureByDefault <T>(this SettingsHolder settings) where T : Feature
 {
     settings.EnableFeatureByDefault(typeof(T));
     return(settings);
 }