Example #1
0
        public void not_build_the_database_when_the_connection_cache_is_empty()
        {
            var session = IsolateSetupDatabaseMethod(null);

            _services.InitDatabase();
            Isolate.Verify.WasNotCalled(() => SessionFactoryManager.BuildSchema("TestGenForm", session));
        }
Example #2
0
        public void build_the_database_when_the_SessionCache_is_not_EmptySessionCache()
        {
            var connection = Isolate.Fake.Instance <IDbConnection>();
            var session    = IsolateSetupDatabaseMethod(connection);

            _services.InitDatabase();
            Isolate.Verify.WasCalledWithAnyArguments(() => SessionFactoryManager.BuildSchema("TestGenForm", session));
        }
        public void MyTestInitialize()
        {
            Context = new SessionContext();
            SessionFactoryManager.BuildSchema(SessionFactoryManager.Test, Context.CurrentSession());
            Context.CurrentSession().Transaction.Begin();

            var fact = Context.CurrentSession().SessionFactory;

            ObjectFactory.Configure(x => x.For <ISessionFactory>().Use(fact));
        }
Example #4
0
        private ISession IsolateSetupDatabaseMethod(IDbConnection connection)
        {
            Isolate.WhenCalled(() => _sessionState["connection"]).WillReturn(connection);
            Isolate.WhenCalled(() => _sessionState["environment"]).WillReturn("TestGenForm");

            var session = Isolate.Fake.Instance <ISession>();

            Isolate.WhenCalled(() => SessionFactoryManager.BuildSchema("TestGenForm", session)).IgnoreCall();
            return(session);
        }
        public static void SetupInMemoryDatabase(HttpSessionStateBase sessionState, IDbConnection conn)
        {
            var fact = SessionFactoryManager.GetSessionFactory(GetEnvironment(sessionState));

            sessionState["sessionfactory"] = fact;

            UseSessionFactoryFromApplicationOrSessionState(sessionState);
            var session = ObjectFactory.GetInstance <ISessionFactory>().OpenSession(conn);

            SessionFactoryManager.BuildSchema(GetEnvironment(sessionState), session);
            CurrentSessionContext.Bind(session);

            UserServices.ConfigureSystemUser();
        }
        private static void SetupInMemoryDatabase(ISessionStateCache stateCache, IDbConnection conn)
        {
            var fact = SessionFactoryManager.GetSessionFactory(stateCache.GetEnvironment());

            stateCache.SetSessionFactory(fact);

            UseSessionFactoryFromApplicationOrSessionCache(stateCache);
            var session = ObjectFactory.GetInstance <ISessionFactory>().OpenSession(conn);

            SessionFactoryManager.BuildSchema(stateCache.GetEnvironment(), session);
            CurrentSessionContext.Bind(session);

            UserServices.ConfigureSystemUser();
        }