public void CanRetryDeleteUsingNewSession() { //setup - trigger a failure when deleting... Guid customerOneId = DbFixture.InsertCustomer(); var c = Nh.CurrentSession.Get <Customer>(customerOneId); Nh.CurrentSession.Delete(c); //cause transaction to fail Nh.CurrentSession.Save(Om.CreateInvalidCustomer()); CommitSessionExpectingException(); //run test... using (ISession newSession = Nh.CreateSession()) { newSession.Delete(c); newSession.Flush(); } Assert.That(DbFixture.CustomerExists(c), Is.False); }
public void TransactionNotMarkedAsCommittedIfCommitFails() { Customer c = Om.CreateInvalidCustomer(); Nh.CurrentSession.SaveOrUpdate(c); ITransaction tx = Nh.CurrentSession.BeginTransaction(); NUnitTestsBase.ExecuteAndExpect <Exception>(tx.Commit); Assert.That(Nh.CurrentSession.Transaction.WasCommitted, Is.False); }
public void CanRetrySaveUsingAnotherSession() { //setup - trigger an exception when saving... Customer c = Om.CreateInvalidCustomer(); Nh.CurrentSession.Save(c); CommitSessionExpectingException(); //run test... ResetVersionPropertyTo(c, -1); c.ShortCode = "ABCDE"; //correct problem that was causing save to fail PersistUsingNewSession(c); Assert.That(c.ConcurrencyId, Is.EqualTo(1), "customer has been saved"); }