Пример #1
0
        public void Destructor()
        {
            NhConversation c = NewStartedConversation();
            ISession       s = c.GetSession(sessions);

            c.Dispose();
            Assert.That(s, Is.Not.Null);
            Assert.That(s.IsOpen, Is.False);
            Assert.Throws <ConversationException>(() => s = c.GetSession(sessions));
        }
Пример #2
0
        public void SessionCloseOutsideTheConversation()
        {
            NhConversation c       = NewStartedConversation();
            ISession       session = c.GetSession(sessions);

            session.Close();
            Assert.That(c.GetSession(sessions), Is.SameAs(session));
            Assert.DoesNotThrow(c.Pause);
            Assert.That(Spying.Logger <NhConversation>().Execute(c.Resume).WholeMessage,
                        Text.DoesNotContain("Already session bound on call to Bind()"),
                        "No warning is needed for a closed session.");
            Assert.That(c.GetSession(sessions), Is.Not.SameAs(session));
            c.Dispose();
        }
Пример #3
0
        public void SessionDisposeOutsideTheConversation()
        {
            NhConversation c = NewStartedConversation();

            using (c.GetSession(sessions))
            {
                // Do nothing only simulate a possible usage
                // of sessions.GetCurrentSession() outside conversation management
            }
            // Need some new events in NH about session.Close (Event/Listener)
            // Assert.That(c.GetSession(sessions), Is.Null, "should auto unbind the session.");
            Assert.DoesNotThrow(c.Pause);
            Assert.That(Spying.Logger <NhConversation>().Execute(c.Resume).WholeMessage,
                        Text.DoesNotContain("Already session bound on call to Bind()"),
                        "No warning is needed for a closed session.");
            Assert.That(c.GetSession(sessions), Is.Not.Null);
            c.Dispose();
        }
		public void ScopesAreInvalidatedOnConversationDisposal()
		{
			var sf = MockRepository.GenerateStub<ISessionFactory>();
			var cc = MockRepository.GenerateStub<INhConversationContext>();
			var c = new NhConversation(sf, cc);
			INhScope s = (INhScope)c.Scope();
			Assert.That(s.IsValid);
			c.Dispose();
			Assert.That(s.IsValid, Is.False);
			s.Dispose(); // Must not throw
		}