Example #1
0
		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);
			}
		}
Example #2
0
        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);
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
		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();
			}
		}