public void SetUp()
        {
            var builder    = new NHibernateSagaStorage();
            var properties = SQLiteConfiguration.InMemory();

            var configuration = new Configuration().AddProperties(properties);
            var settings      = new SettingsHolder();

            var metaModel = new SagaMetadataCollection();
            var types     = new [] { typeof(TestSaga), typeof(TestSagaData), typeof(TestComponent), typeof(PolymorphicPropertyBase),
                                     typeof(AlsoDerivedFromTestSagaWithTableNameAttributeActualSaga), typeof(AlsoDerivedFromTestSagaWithTableNameAttribute),
                                     typeof(DerivedFromTestSagaWithTableNameAttributeActualSaga), typeof(DerivedFromTestSagaWithTableNameAttribute),
                                     typeof(TestSagaWithTableNameAttributeActualSaga), typeof(TestSagaWithTableNameAttribute),
                                     typeof(SagaWithVersionedPropertyAttributeActualSaga), typeof(SagaWithVersionedPropertyAttribute),
                                     typeof(SagaWithoutVersionedPropertyAttributeActualSaga), typeof(SagaWithoutVersionedPropertyAttribute),
                                     typeof(object) };

            metaModel.Initialize(types);
            settings.Set <SagaMetadataCollection>(metaModel);

            settings.Set("TypesToScan", types);
            builder.ApplyMappings(settings, configuration);
            sessionFactory = configuration.BuildSessionFactory() as SessionFactoryImpl;

            persisterForTestSaga = sessionFactory.GetEntityPersisterFor <TestSagaData>();
        }
Esempio n. 2
0
        public void SetUp()
        {
            var builder = new SessionFactoryBuilder(new[] { typeof(SagaWithAbstractBaseClass), typeof(ContainSagaData), typeof(MyOwnAbstractBase) });

            var properties = SQLiteConfiguration.InMemory();

            sessionFactory = builder.Build(new Configuration().AddProperties(properties)) as SessionFactoryImpl;
        }
Esempio n. 3
0
        public void SetUp()
        {
            var assemblyContainingSagas = typeof(TestSaga).Assembly;
            var types = assemblyContainingSagas.GetTypes().ToList();

            types.Add(typeof(ContainSagaData));

            var builder    = new SessionFactoryBuilder(types);
            var properties = SQLiteConfiguration.InMemory();

            sessionFactory = builder.Build(new Configuration().AddProperties(properties)) as SessionFactoryImpl;
        }
Esempio n. 4
0
        public void Should_throw_if_class_is_derived()
        {
            var builder    = new NHibernateSagaStorage();
            var properties = SQLiteConfiguration.InMemory();

            var configuration = new Configuration().AddProperties(properties);
            var settings      = new SettingsHolder();

            settings.Set("TypesToScan", new[] { typeof(MyDerivedClassWithRowVersion) });

            Assert.Throws <MappingException>(() => builder.ApplyMappings(settings, configuration));
        }
Esempio n. 5
0
        public void SetUp()
        {
            var builder    = new NHibernateSagaStorage();
            var properties = SQLiteConfiguration.InMemory();

            var configuration = new Configuration().AddProperties(properties);
            var settings      = new SettingsHolder();

            settings.Set("TypesToScan", new[] { typeof(SagaWithAbstractBaseClass), typeof(ContainSagaData), typeof(MyOwnAbstractBase) });
            builder.ApplyMappings(settings, configuration);
            sessionFactory = configuration.BuildSessionFactory() as SessionFactoryImpl;
        }
Esempio n. 6
0
        public static SessionFactoryImpl Build()
        {
            var types = Types();

            var builder    = new NHibernateSagaStorage();
            var properties = SQLiteConfiguration.InMemory();

            var configuration = new Configuration().AddProperties(properties);
            var settings      = new SettingsHolder();

            settings.Set("TypesToScan", types);
            builder.ApplyMappings(settings, configuration);
            return(configuration.BuildSessionFactory() as SessionFactoryImpl);
        }
Esempio n. 7
0
        public void SetUp()
        {
            var nhibernateProperties = SQLiteConfiguration.UsingFile(Path.GetTempFileName());

            SessionFactory = new SessionFactoryBuilder(typeof(TestSaga).Assembly.GetTypes())
                             .Build(nhibernateProperties, true);

            SagaPersister = new SagaPersister {
                SessionFactory = SessionFactory
            };

            UnitOfWork = new UnitOfWorkManager {
                SessionFactory = SessionFactory
            };
        }
        public static SessionFactoryImpl Build(Type[] types)
        {
            var builder    = new NHibernateSagaStorage();
            var properties = SQLiteConfiguration.InMemory();

            var configuration = new Configuration().AddProperties(properties);
            var settings      = new SettingsHolder();

            var metaModel = new SagaMetadataCollection();

            metaModel.Initialize(types);
            settings.Set <SagaMetadataCollection>(metaModel);

            settings.Set("TypesToScan", types);
            builder.ApplyMappings(settings, configuration);
            return(configuration.BuildSessionFactory() as SessionFactoryImpl);
        }
        public void Database_schema_should_be_updated_if_requested()
        {
            var nhibernateProperties = SQLiteConfiguration.UsingFile(Path.GetTempFileName());

            File.WriteAllText("sqlite.txt", "");

            foreach (var property in nhibernateProperties)
            {
                File.AppendAllText("sqlite.txt", String.Format("{{ \"{0}\", \"{1}\" }}\n", property.Key, property.Value));
            }

            var sessionFactory = new SessionFactoryBuilder(typeof(TestSaga).Assembly.GetTypes())
                                 .Build(nhibernateProperties, true);

            using (var session = sessionFactory.OpenSession())
            {
                session.CreateCriteria(typeof(TestSaga)).List <TestSaga>();
            }
        }
Esempio n. 10
0
        public void SetUp()
        {
            var assemblyContainingSagas = typeof(TestSaga).Assembly;

            var builder = new SessionFactoryBuilder(assemblyContainingSagas.GetTypes());

            //var properties = SQLiteConfiguration.Standard
            //  .InMemory()
            //  .ToProperties();

            //File.WriteAllText("sqlite.txt", "");

            //foreach (var property in properties)
            //{
            //  File.AppendAllText("sqlite.txt", String.Format("{{ \"{0}\", \"{1}\" }}\n", property.Key, property.Value));

            //}

            var properties = SQLiteConfiguration.InMemory();

            sessionFactory = builder.Build(properties, false) as SessionFactoryImpl;

            persisterForTestSaga = sessionFactory.GetEntityPersisterFor <TestSaga>();
        }