public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransaction() { #pragma warning disable 618 Assert.IsFalse(sessions.Settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled); #pragma warning restore 618 var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = sessions.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); s.Save(c); Assert.Throws<BadException>(t.Commit); } using (ISession s = sessions.OpenSession()) { var objectInDb = s.Get<C>(1); Assert.IsNull(objectInDb); } }
public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransaction() { #pragma warning disable 618 Assert.IsFalse(sessions.Settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled); #pragma warning restore 618 var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = sessions.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); s.Save(c); Assert.Throws <BadException>(t.Commit); } using (ISession s = sessions.OpenSession()) { var objectInDb = s.Get <C>(1); Assert.IsNull(objectInDb); } }
public void ExceptionsInSynchronizationBeforeTransactionCompletionAreIgnored() { Assert.IsTrue(sessions.Settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled); var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = sessions.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); s.Save(c); Assert.DoesNotThrow(t.Commit); } using (ISession s = sessions.OpenSession()) { var objectInDb = s.Get <C>(1); Assert.IsNotNull(objectInDb); s.Delete(objectInDb); s.Flush(); } }
public async Task ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransactionAsync() { var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); await(s.SaveAsync(c)); Assert.ThrowsAsync <BadException>(() => t.CommitAsync()); } using (ISession s = Sfi.OpenSession()) { var objectInDb = await(s.GetAsync <C>(1)); Assert.IsNull(objectInDb); } }
public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransaction() { var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = sessions.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); s.Save(c); Assert.Throws <BadException>(t.Commit); } using (ISession s = sessions.OpenSession()) { var objectInDb = s.Get <C>(1); Assert.IsNull(objectInDb); } }
public void ExceptionsInSynchronizationBeforeTransactionCompletionAreIgnored() { Assert.IsTrue(sessions.Settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled); var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); using (ISession s = sessions.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); s.Save(c); Assert.DoesNotThrow(t.Commit); } using (ISession s = sessions.OpenSession()) { var objectInDb = s.Get<C>(1); Assert.IsNotNull(objectInDb); s.Delete(objectInDb); s.Flush(); } }