public void StartCalledTwiceWithoutEndShouldNotStartAnotherUnitOfWork() { NhConversation c = NewConversation(); c.Start(); ISession s = c.GetSession(sessions); c.Start(); Assert.That(c.GetSession(sessions), Is.SameAs(s), "ReStart of the same conversation should not change the session."); Assert.That(s.IsOpen); }
private NhConversation NewPausedConversation() { NhConversation c = NewConversation(); c.Start(); c.Pause(); AssertIsPaused(c.GetSession(sessions)); return(c); }
public void StartShouldStartUnitOfWork() { NhConversation c = NewConversation(); c.Start(); ISession s = c.GetSession(sessions); AssertIsOpen(s); }
private NhConversation NewStartedConversation() { NhConversation c = NewConversation(); c.Start(); ISession s = c.GetSession(sessions); Assert.That(s.IsOpen, Is.True, "UoW expected to be started"); return(c); }
public void StartAfterEndShouldStartAnotherUnitOfWork() { NhConversation c = NewStartedConversation(); ISession previousUoW = c.GetSession(sessions); c.End(); c.Start(); ISession currentUoW = c.GetSession(sessions); AssertIsOpen(currentUoW); Assert.That(currentUoW, Is.Not.SameAs(previousUoW)); }
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(); } }