Ejemplo n.º 1
0
        public void ResumeAfterEndShouldStartAnotherUnitOfWork()
        {
            NhConversation c = NewPausedConversation();

            c.Resume();
            ISession previousUoW = c.GetSession(sessions);

            c.End();

            c.Resume();
            ISession currentUoW = c.GetSession(sessions);

            AssertIsOpen(currentUoW);
            Assert.That(currentUoW, Is.Not.SameAs(previousUoW));
        }
Ejemplo n.º 2
0
        public void ResumeShouldReconnectUnitOfWork()
        {
            NhConversation c = NewPausedConversation();

            c.Resume();
            ISession s = c.GetSession(sessions);

            AssertIsOpen(s);
            Assert.That(s.IsConnected);
        }
Ejemplo n.º 3
0
        public void ResumeAfterStartShouldNotStatAnotherUnitOfWork()
        {
            NhConversation c          = NewStartedConversation();
            ISession       startedUoW = c.GetSession(sessions);

            c.Resume();
            ISession currentUoW = c.GetSession(sessions);

            Assert.That(currentUoW, Is.SameAs(startedUoW));
        }
Ejemplo n.º 4
0
        public void ManualUnbindSessionDoNotCreateProblemsInARunningConversation()
        {
            NhConversation c = NewStartedConversation();

            ISession s = c.GetSession(sessions);

            c.Unbind(s);
            Assert.That(c.GetSession(sessions), Is.Null, "A session still bind after manual Unbind.");
            c.Resume();
            Assert.That(c.GetSession(sessions).IsOpen);
            c.End();
        }
Ejemplo n.º 5
0
        public void EndShouldFlushResumedUnitOfWork()
        {
            NhConversation c = NewPausedConversation();

            c.Resume();
            ISession s            = c.GetSession(sessions);
            var      persistedObj = new Silly3();

            s.Save(persistedObj);

            c.End();
            AssertExistsInDb(persistedObj);
        }
Ejemplo n.º 6
0
        public void ConversationUsage()
        {
            CommitInNewSession(session =>
            {
                var o = new Other3 {
                    Name = "some other silly"
                };
                var e = new Silly3 {
                    Name = "somebody", Other = o
                };
                session.Save(e);
            });

            using (NhConversation c = NewConversation())
            {
                c.Start();
                ISession       s  = c.GetSession(sessions);
                IList <Silly3> sl = s.CreateQuery("from Silly3").List <Silly3>();
                c.Pause();
                Assert.That(sl.Count == 1);
                Assert.That(!NHibernateUtil.IsInitialized(sl[0].Other));
                // working with entities, even using lazy loading
                Assert.That(!s.Transaction.IsActive);
                Assert.That("some other silly", Is.EqualTo(sl[0].Other.Name));
                Assert.That(NHibernateUtil.IsInitialized(sl[0].Other));
                sl[0].Other.Name = "nobody";
                c.Resume();
                s = c.GetSession(sessions);
                s.SaveOrUpdate(sl[0]);
                // the dispose auto-end the conversation
            }

            using (NhConversation c = NewConversation())
            {
                c.Start();
                ISession s = c.GetSession(sessions);
                s.Delete("from Silly3");
                c.End();
            }
        }