コード例 #1
0
        public void Setup()
        {
            Configure.ConfigurationSource = new DefaultConfigurationSource();

            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                { "NServiceBus/Persistence/NHibernate/dialect", dialect }
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings("NServiceBus/Persistence/NHibernate/Timeout", connectionString)
            };

            ConfigureNHibernate.Init();

            Configure.With(Enumerable.Empty <Type>())
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateTimeoutPersister();

            persister      = Configure.Instance.Builder.Build <TimeoutStorage>();
            sessionFactory = persister.SessionFactory;

            new Installer.Installer().Install(WindowsIdentity.GetCurrent().Name);
        }
コード例 #2
0
        public void Should_assign_overriden_connectionstring_if_specified()
        {
            NHibernateSettingRetriever.AppSettings       = () => new NameValueCollection {
            };
            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings("NServiceBus/Persistence", connectionString),
                new ConnectionStringSettings("NServiceBus/Persistence/NHibernate/Timeout",
                                             "timeout_connection_string")
            };

            ConfigureNHibernate.Init();

            var expectedForTimeout = new Dictionary <string, string>
            {
                { "connection.connection_string", "timeout_connection_string" }
            };

            var expectedDefault = new Dictionary <string, string>
            {
                { "connection.connection_string", connectionString }
            };

            CollectionAssert.IsSubsetOf(expectedDefault, ConfigureNHibernate.DistributorPersisterProperties);
            CollectionAssert.IsSubsetOf(expectedDefault, ConfigureNHibernate.GatewayPersisterProperties);
            CollectionAssert.IsSubsetOf(expectedDefault, ConfigureNHibernate.SagaPersisterProperties);
            CollectionAssert.IsSubsetOf(expectedDefault, ConfigureNHibernate.SubscriptionStorageProperties);
            CollectionAssert.IsSubsetOf(expectedForTimeout, ConfigureNHibernate.TimeoutPersisterProperties);
        }
コード例 #3
0
        public void Should_assign_all_optional_properties_to_all_persisters()
        {
            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                { "NServiceBus/Persistence/NHibernate/connection.provider", "provider" },
                { "NServiceBus/Persistence/NHibernate/connection.driver_class", "driver_class" },
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings("NServiceBus/Persistence", connectionString)
            };

            ConfigureNHibernate.Init();

            var expected = new Dictionary <string, string>
            {
                { "connection.connection_string", connectionString },
                { "connection.provider", "provider" },
                { "connection.driver_class", "driver_class" },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.DistributorPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.GatewayPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.SagaPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.SubscriptionStorageProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.TimeoutPersisterProperties);
        }
コード例 #4
0
        public void UseNHibernateTimeoutPersister_Reads_From_AppSettings_And_ConnectionStrings()
        {
            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                {
                    "NServiceBus/Persistence/NHibernate/dialect",
                    dialect
                }
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings(
                    "NServiceBus/Persistence",
                    connectionString)
            };

            ConfigureNHibernate.Init();

            Configure.With(Enumerable.Empty <Type>())
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateTimeoutPersister();

            var expected = new Dictionary <string, string>
            {
                { "dialect", dialect },
                { "connection.connection_string", connectionString },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.TimeoutPersisterProperties);
        }
コード例 #5
0
        public void UseNHibernateSubscriptionPersister_Reads_First_From_DBSubscriptionStorageConfig()
        {
            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                {
                    "NServiceBus/Persistence/NHibernate/dialect",
                    "Shouldn't be this"
                }
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings(
                    "NServiceBus/Persistence/NHibernate",
                    "Shouldn't be this")
            };
            ConfigureNHibernate.Init();

            Configure.ConfigurationSource = new FakeConfigurationSource();

            Configure.With(Enumerable.Empty <Type>())
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateSubscriptionPersister();

            var expected = new Dictionary <string, string>
            {
                { "dialect", dialect },
                { "connection.connection_string", connectionString },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.SubscriptionStorageProperties);
        }
コード例 #6
0
        public void Should_skip_settings_that_are_not_for_persistence()
        {
            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                { "myOtherSetting1", "provider" },
                { "myOtherSetting2", "driver_class" },
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings("NServiceBus/Persistence", connectionString)
            };

            ConfigureNHibernate.Init();

            var expected = new Dictionary <string, string>
            {
                { "connection.connection_string", connectionString },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.DistributorPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.GatewayPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.SagaPersisterProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.SubscriptionStorageProperties);
            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.TimeoutPersisterProperties);
        }
コード例 #7
0
            public IDictionary <string, string> Execute()
            {
                ConfigureNHibernate.Init();
                var configuration =
                    ConfigureNHibernate.CreateConfigurationWith(ConfigureNHibernate.DistributorPersisterProperties);

                return(configuration.Properties);
            }
コード例 #8
0
            public IDictionary <string, string> Execute()
            {
                NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
                {
                    new ConnectionStringSettings("NServiceBus/Persistence", "specified")
                };

                ConfigureNHibernate.Init();
                var configuration =
                    ConfigureNHibernate.CreateConfigurationWith(ConfigureNHibernate.DistributorPersisterProperties);

                return(configuration.Properties);
            }
コード例 #9
0
        public void UseNHibernateTimeoutPersisterWithSQLiteAndAutomaticSchemaGeneration_Automatically_Configure_SqlLite()
        {
            ConfigureNHibernate.Init();

            Configure.With(Enumerable.Empty <Type>())
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateTimeoutPersisterWithSQLiteAndAutomaticSchemaGeneration();

            var expected = new Dictionary <string, string>
            {
                { "dialect", dialect },
                { "connection.connection_string", "Data Source=.\\NServiceBus.Timeouts.sqlite;Version=3;New=True;" },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.TimeoutPersisterProperties);
        }
コード例 #10
0
        public void SetUp()
        {
            string connectionString = String.Format(@"Data Source={0};Version=3;New=True;", Path.GetTempFileName());

            Configure.ConfigurationSource = new FakeConfigurationSource();

            NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
            {
                { "NServiceBus/Persistence/NHibernate/dialect", dialect }
            };

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
            {
                new ConnectionStringSettings("NServiceBus/Persistence/NHibernate/Saga", connectionString)
            };

            ConfigureNHibernate.Init();

            Configure.Features.Enable <Features.Sagas>();

            var types = typeof(TestSaga).Assembly.GetTypes().ToList();

            types.Add(typeof(ContainSagaData));

            Configure.With(types)
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateSagaPersister();

            var builder    = new SessionFactoryBuilder(Configure.TypesToScan);
            var properties = ConfigureNHibernate.SagaPersisterProperties;

            SessionFactory = builder.Build(ConfigureNHibernate.CreateConfigurationWith(properties));

            UnitOfWork = new UnitOfWorkManager {
                SessionFactory = SessionFactory
            };

            SagaPersister = new SagaPersister {
                UnitOfWorkManager = (UnitOfWorkManager)UnitOfWork
            };

            new Installer().Install(WindowsIdentity.GetCurrent().Name);
        }
コード例 #11
0
        public void UseNHibernateTimeoutPersister_Reads_From_TimeoutPersisterConfig()
        {
            Configure.ConfigurationSource = new FakeConfigurationSource();

            ConfigureNHibernate.Init();

            Configure.With(Enumerable.Empty <Type>())
            .DefineEndpointName("Foo")
            .DefaultBuilder()
            .UseNHibernateTimeoutPersister();

            var expected = new Dictionary <string, string>
            {
                { "dialect", dialect },
                { "connection.connection_string", connectionString },
            };

            CollectionAssert.IsSubsetOf(expected, ConfigureNHibernate.TimeoutPersisterProperties);
        }