コード例 #1
0
        public void SetSessionForKey_Sets_Session()
        {
            //Arrange
            var storage = new ThreadAndWebSessionStorage(null);

            //Act
            storage.SetSessionForKey("blah", MockRepository.GenerateStub<ISession>());

            //Assert
            var session = storage.GetSessionForKey("blah");
            Assert.IsNotNull(session);
        }
コード例 #2
0
        public void GetSessionForKey_Returns_Correct_Session()
        {
            //Arrange
            var storage = new ThreadAndWebSessionStorage(null);
            storage.SetSessionForKey("blah", null);
            storage.SetSessionForKey("blahs", MockRepository.GenerateStub<ISession>());
            storage.SetSessionForKey("blahed", null);

            //Act
            var session = storage.GetSessionForKey("blahs");

            Assert.IsNotNull(session);
        }
コード例 #3
0
        public void GetAllSessions_Returns_All_Sessions()
        {
            //Arrange
            var storage = new ThreadAndWebSessionStorage(null);
            storage.SetSessionForKey("blah", MockRepository.GenerateStub<ISession>());
            storage.SetSessionForKey("blahs", MockRepository.GenerateStub<ISession>());

            //Act
            var sessions = storage.GetAllSessions();

            //Assert
            Assert.AreEqual(2, sessions.Count());
        }
コード例 #4
0
 public override void Init()
 {
     base.Init();
     _threadAndWebSessionStorage = new ThreadAndWebSessionStorage(this);
 }
コード例 #5
0
 private void InitializeNHibernateSessions()
 {
     MigrateDatabase();
     _threadAndWebSessionStorage = new ThreadAndWebSessionStorage(this);
     var config = new NHibernateConfiguration(_connectionString);
     NHibernateSession.Init(_threadAndWebSessionStorage, new[] { Server.MapPath("~/bin/TemplateProject.Infrastructure.dll") },
         new AutoPersistenceModelGenerator().Generate(), null, null, null, config);
 }