コード例 #1
0
        /// <summary>
        /// Create new session in testing context
        /// </summary>
        /// <returns></returns>
        public virtual ISession CreateSession()
        {
            var interceptor = NHIoC.ResolveInterceptor();

            return(interceptor != null
                       ? TestContext.SessionFactory.OpenSession(interceptor)
                       : TestContext.SessionFactory.OpenSession());
        }
コード例 #2
0
            /// <summary>
            /// Create new session in testing context
            /// </summary>
            /// <returns></returns>
            public override ISession CreateSession()
            {
                //need to get our own connection, because NH will try to close it as soon as possible, and we will lose the changes.
                var connection
                    = ((ISessionFactoryImplementor)TestContext.SessionFactory).ConnectionProvider.GetConnection();

                // IInterceptor interceptor = UnitOfWorkTestContext.ResolveInterceptor();
                var interceptor = NHIoC.ResolveInterceptor();

                if (interceptor != null)
                {
                    TestContext.SessionFactory.OpenSession(connection, interceptor);
                }

                return(TestContext.SessionFactory.OpenSession(connection));
            }