private NhConversation NewPausedConversation() { NhConversation c = NewConversation(); c.Start(); c.Pause(); AssertIsPaused(c.GetSession(sessions)); return(c); }
public void PauseShouldDisconnectButNotCloseUnitOfWork() { NhConversation c = NewStartedConversation(); c.Pause(); ISession s = c.GetSession(sessions); AssertIsPaused(s); }
public void PauseShouldNotFlushUnitOfWork() { NhConversation c = NewStartedConversation(); var persistedObj = new Silly3(); c.GetSession(sessions).Save(persistedObj); c.Pause(); AssertDoesNotExistInDb(persistedObj); }
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(); } }