private void DoTestRollbackOnException(Exception exception, bool shouldRollback, bool rollbackException)
        {
            ITransactionAttribute txatt = new ConfigurableTransactionAttribute(shouldRollback);


            MethodInfo mi = typeof(ITestObject).GetMethod("Exceptional");

            MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();

            tas.AddTransactionalMethod(mi, txatt);
            ITransactionStatus status = TransactionStatusForNewTransaction();

            IPlatformTransactionManager ptm =
                (IPlatformTransactionManager)mocks.DynamicMock(typeof(IPlatformTransactionManager));


            Expect.On(ptm).Call(ptm.GetTransaction(txatt)).Return(status);


            if (shouldRollback)
            {
                ptm.Rollback(status);
            }
            else
            {
                ptm.Commit(status);
            }
            TransactionSystemException tex = new TransactionSystemException("system exception");

            if (rollbackException)
            {
                LastCall.On(ptm).Throw(tex).Repeat.Once();
            }
            else
            {
                LastCall.On(ptm).Repeat.Once();
            }
            mocks.ReplayAll();

            TestObject  to  = new TestObject();
            ITestObject ito = (ITestObject)Advised(to, ptm, tas);

            try
            {
                ito.Exceptional(exception);
                Assert.Fail("Should have thrown exception");
            } catch (Exception e)
            {
                if (rollbackException)
                {
                    Assert.AreEqual(tex, e);
                }
                else
                {
                    Assert.AreEqual(exception, e);
                }
            }

            mocks.VerifyAll();
        }
        private void DoTestRollbackOnException(Exception exception, bool shouldRollback, bool rollbackException)
        {
            ITransactionAttribute txatt = new ConfigurableTransactionAttribute(shouldRollback);


            MethodInfo mi = typeof(ITestObject).GetMethod("Exceptional");

            MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();

            tas.AddTransactionalMethod(mi, txatt);
            ITransactionStatus status = A.Fake <ITransactionStatus>();

            IPlatformTransactionManager ptm = A.Fake <IPlatformTransactionManager>();

            A.CallTo(() => ptm.GetTransaction(txatt)).Returns(status);


            TransactionSystemException tex = new TransactionSystemException("system exception");

            if (rollbackException)
            {
                A.CallTo(() => ptm.Rollback(A <ITransactionStatus> ._)).Throws(tex);
            }

            TestObject  to  = new TestObject();
            ITestObject ito = (ITestObject)Advised(to, ptm, tas);

            try
            {
                ito.Exceptional(exception);
                Assert.Fail("Should have thrown exception");
            }
            catch (Exception e)
            {
                if (rollbackException && shouldRollback)
                {
                    Assert.AreEqual(tex, e);
                }
                else
                {
                    Assert.AreEqual(exception, e);
                }
            }

            if (shouldRollback)
            {
                A.CallTo(() => ptm.Rollback(status)).MustHaveHappenedOnceExactly();
            }
            else
            {
                A.CallTo(() => ptm.Commit(status)).MustHaveHappenedOnceExactly();
            }
        }
        private void DoTestRollbackOnException(Exception exception, bool shouldRollback, bool rollbackException)
        {
            ITransactionAttribute txatt = new ConfigurableTransactionAttribute(shouldRollback);


            MethodInfo mi = typeof (ITestObject).GetMethod("Exceptional");

            MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
            tas.AddTransactionalMethod(mi, txatt);
            ITransactionStatus status = TransactionStatusForNewTransaction();

            IPlatformTransactionManager ptm =
                (IPlatformTransactionManager) mocks.DynamicMock(typeof (IPlatformTransactionManager));

            
            Expect.On(ptm).Call(ptm.GetTransaction(txatt)).Return(status);
            

            if (shouldRollback)
            {
                ptm.Rollback(status);
            }
            else
            {
                ptm.Commit(status);
            }
            TransactionSystemException tex = new TransactionSystemException("system exception");
            if (rollbackException)
            {
                LastCall.On(ptm).Throw(tex).Repeat.Once();
            }
            else
            {
                LastCall.On(ptm).Repeat.Once();
            }
            mocks.ReplayAll();

            TestObject to = new TestObject();
            ITestObject ito = (ITestObject) Advised(to, ptm, tas);

            try
            {
                ito.Exceptional(exception);
                Assert.Fail("Should have thrown exception");
            } catch (Exception e)
            {
                if (rollbackException)
                {
                    Assert.AreEqual(tex, e);
                }
                else
                {
                    Assert.AreEqual(exception, e);
                }
            }

            mocks.VerifyAll();

        }