Пример #1
0
 /// <summary>
 /// NHibernate 용 Domain을 테스트하기 위해, 환경을 초기화합니다.
 /// </summary>
 /// <param name="containerConfigPath">Castle Windsor configuration file path</param>
 /// <param name="databaseEngine">Database 종류</param>
 /// <param name="databaseName">Database name</param>
 /// <param name="mappingInfo">Domain Model의 Mapping information</param>
 /// <param name="properties">NHibernate configuration 정보</param>
 /// <param name="configAction">NHIbernate configuration 을 추가해야 할 경우 (Listner 등)</param>
 /// <param name="conventions">Fluent NHibernate의 명명규칙</param>
 public static void InitializeNHibernateAndIoC(string containerConfigPath,
                                               DatabaseEngine databaseEngine,
                                               string databaseName,
                                               MappingInfo mappingInfo,
                                               IDictionary <string, string> properties,
                                               Action <NHibernate.Cfg.Configuration> configAction,
                                               params IConvention[] conventions)
 {
     NHibernateInitializer
     .Initialize(mappingInfo, configAction, conventions)
     .Using(databaseEngine, databaseName)
     .ConfiguredBy(properties)
     .AndIoC(containerConfigPath);
 }
Пример #2
0
        /// <summary>
        /// Release unmanaged resources. 내부 Container를 메모리에서 해제한다.
        /// </summary>
        public void Dispose()
        {
            _dbStrategy  = null;
            _mappingInfo = null;

            UnitOfWork.Stop();
            //UnitOfWork.CurrentSession = null;

            if (_container != null)
            {
                _container.Dispose();
                _container = null;
            }
        }
        public void TestThatNHInitializeAwareIsCalled()
        {
            var mock = new NHInitAwareMock
            {
                ConfiguredWasCalled  = 0,
                InitializedWasCalled = 0
            };

            InitializeNHibernateAndIoC(ContainerFilePath,
                                       DatabaseEngine.SQLite,
                                       ":memory:",
                                       MappingInfo.From().SetNHInitializationAware(mock),
                                       _ => { });
            Assert.AreEqual(1, mock.BeforeInitializationCalled);
            Assert.AreEqual(1, mock.ConfiguredWasCalled);
            Assert.AreEqual(1, mock.InitializedWasCalled);
        }
        protected void VerifyCanCreateUnitOfWorkContextFor(string containerPath, DatabaseEngine databaseEngine, string databaseName)
        {
            int nextContextPosition = Contexts.Count;

            // create the UnitOfWorkContext
            //

            var mappingInfo = MappingInfo.From(typeof(GuidEntityForTesting).Assembly, typeof(FluentProduct).Assembly);

            InitializeNHibernateAndIoC(containerPath,
                                       databaseEngine,
                                       databaseName,
                                       mappingInfo,
                                       _ => { });

            var context = Contexts[nextContextPosition];

            Assert.IsNotNull(context);

            if (containerPath != null)
            {
                Assert.AreEqual(containerPath, context.ContainerConfigPath);
            }
            else
            {
                Assert.IsEmpty(context.ContainerConfigPath);
            }

            Assert.AreEqual(databaseEngine, context.DatabaseEngine);

            if (databaseName.IsWhiteSpace())
            {
                Assert.AreEqual(NHibernateInitializer.DeriveDatabaseNameFrom(databaseEngine, mappingInfo.MappingAssemblies[0]),
                                context.DatabaseName);
            }
            else
            {
                Assert.AreEqual(databaseName, context.DatabaseName);
            }

            Assert.AreEqual(CurrentContext, context, "Context just build has been assigned to CurrentContext");
        }
Пример #5
0
 /// <summary>
 /// NHibernate 초기화를 수행하는 Initializer 를 제공합니다.
 /// </summary>
 /// <param name="mappingInfo">매핑 정보</param>
 /// <param name="configAction">환경 설정 추가 작업용 델리게이트</param>
 /// <returns>NHibernateInitializer 인스턴스</returns>
 /// <param name="conventions">Fluent NHibernate의 명명규칙</param>
 public static NHibernateInitializer Initialize(MappingInfo mappingInfo, Action <NHibernate.Cfg.Configuration> configAction,
                                                params IConvention[] conventions)
 {
     return(new NHibernateInitializer(mappingInfo, configAction, conventions));
 }
Пример #6
0
 /// <summary>
 /// NHibernate 를 초기화 한다.
 /// </summary>
 /// <param name="mappingInfo">엔티티 매핑 정보</param>
 /// <param name="configAction">환경설정 추가 작업용 델리게이트</param>
 /// <param name="conventions">Fluent NHibernate의 명명규칙</param>
 public static void InitializeNHibernate(MappingInfo mappingInfo,
                                         Action <NHibernate.Cfg.Configuration> configAction,
                                         params IConvention[] conventions)
 {
     NHibernateInitializer.Initialize(mappingInfo, configAction, conventions);
 }
 public static NHibernateInitializer Initialize(MappingInfo mappingInfo, Action <NHibernate.Cfg.Configuration> configAction)
 {
     IoC.Reset();
     return(new NHibernateInitializer(mappingInfo, configAction));
 }
 /// <summary>
 /// NHibernate 를 초기화 한다.
 /// </summary>
 /// <param name="mappingInfo">엔티티 매핑 정보</param>
 /// <param name="configAction">환경설정 추가 작업용 델리게이트</param>
 public static void InitializeNHibernate(MappingInfo mappingInfo, Action <NHibernate.Cfg.Configuration> configAction)
 {
     NHibernateInitializer.Initialize(mappingInfo, configAction);
 }
 /// <summary>
 /// NHibernate 용 Domain을 테스트하기 위해, 환경을 초기화합니다.
 /// </summary>
 /// <param name="containerConfigPath">Castle Windsor configuration file path</param>
 /// <param name="mappingInfo">Domain Model의 Mapping information</param>
 /// <param name="configAction">부가적인 Configuration 관련 작업 (Listener 추가 등)</param>
 public static void InitializeNHibernateAndIoC(string containerConfigPath, MappingInfo mappingInfo,
                                               Action <NHibernate.Cfg.Configuration> configAction)
 {
     NHibernateInitializer.Initialize(mappingInfo, configAction).AndIoC(containerConfigPath);
 }