public void BeginConversation_WhenThereAreMultipleFactories_ThrowsInvalidOperationException()
 {
     configuration.Properties["session_factory_name"] = "TestFactory2";
     var factory = configuration.BuildSessionFactory();
     validsessionFactoryManager.AddFactory(factory);
     var sut = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.Throws<InvalidOperationException>(() => sut.BeginConversation());
 }
        public void DeactivateConversation_GivenAConversation_SetsItAsNotActive()
        {
            var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
            var conversation1 = conversationManager.BeginConversation();
            conversationManager.DeactivateConversation(conversation1);

            Assert.IsFalse(conversation1.IsActive);
        }
        public void BeginConversation_SetsLastCreatedConversationAsActive()
        {
            var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
            var conversation1 = conversationManager.BeginConversation();
            Assert.IsTrue(conversation1.IsActive);

            var conversation2 = conversationManager.BeginConversation();
            Assert.IsTrue(conversation2.IsActive);
            Assert.IsFalse(conversation1.IsActive);
        }
 public void GetActiveConversation_WhenTheresNoActiveConversation_ReturnsNull()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.IsNull(conversationManager.GetActiveConversation());
 }
 public void GetActiveConversation_ReturnsTheCurrentConversation()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     var conversation = conversationManager.BeginConversation();
     Assert.IsTrue(conversation.IsActive);
     Assert.AreSame(conversation, conversationManager.GetActiveConversation());
 }
 public void DeactivateConversation_GivenANullConversation_ThrowsArgumentNullException()
 {
     var sut = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.Throws<ArgumentNullException>(() => sut.DeactivateConversation(null));
 }
 public void BeginConversation_IsAbleToBeginAConversation()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     var conversation = conversationManager.BeginConversation();
     Assert.IsNotNull(conversation);
 }
 public void BeginConversation_GivenSessionFactoryName_BeginsAConversationForTheSessionFactory()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     var conversation = conversationManager.BeginConversation("TestFactory");
     Assert.IsNotNull(conversation);
 }
 public void BeginConversation_GivenANonExistentSessionFactoryName_ThrowsInvalidOperationException()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.Throws<InvalidOperationException>(() => conversationManager.BeginConversation("UNEXISTENT"));
 }
 public void SetAsActiveConversation_GivenANullConversation_ThrowsArgumentNullException()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.Throws<ArgumentNullException>(() =>conversationManager.SetAsActiveConversation(null));
 }
 public void NHibernateConversationManager_CreatedWithValidFactoryManager_IsCreated()
 {
     var conversationManager = new NHibernateConversationManager(validsessionFactoryManager);
     Assert.IsNotNull(conversationManager);
 }
 public void SetUp()
 {
     var configurationProperties = new Dictionary<string, string>
                          {
                              { "connection.driver_class", "NHibernate.Driver.SQLite20Driver" },
                              { "dialect", "NHibernate.Dialect.SQLiteDialect" },
                              { "connection.connection_string", "Data Source=:memory:;Version=3;New=True;" },
                              { "connection.provider", "NHibernate.Connection.DriverConnectionProvider" },
                              { "session_factory_name", "TestFactory" },
                              { "proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" },
                              { "current_session_context_class", "Aspid.NHibernate.Context.ConversationSessionContext, Aspid.NHibernate" },
                          };
     var configuration = new Configuration { Properties = configurationProperties };
     var sessionFactoryManager = new SessionFactoryManager(configuration);
     conversationManager = new NHibernateConversationManager(sessionFactoryManager);
 }