Ejemplo n.º 1
0
        public void ExecuteExceptionRollbackException()
        {
            IPlatformTransactionManager mock = MockRepository.GenerateMock <IPlatformTransactionManager>();

            mock.Stub(x => x.Rollback(Arg <ITransactionStatus> .Is.Anything)).Throw(new Exception("Rollback"));

            TransactionTemplate temp = new TransactionTemplate(mock);

            try
            {
                temp.Execute(new TransactionDelegate(DummyExceptionMethod));
            }
            catch
            {
            }

            mock.AssertWasCalled(x => x.GetTransaction(Arg <ITransactionDefinition> .Is.Anything), constraints => constraints.Repeat.Once());
            mock.AssertWasCalled(x => x.Rollback(Arg <ITransactionStatus> .Is.Anything), constraints => constraints.Repeat.Once());
        }