public void NullResult() { IPlatformTransactionManager mock = MockRepository.GenerateMock <IPlatformTransactionManager>(); TransactionTemplate temp = new TransactionTemplate(mock); temp.AfterPropertiesSet(); Assert.AreEqual(mock, temp.PlatformTransactionManager); Assert.IsNull(temp.Execute(new TransactionDelegate(DummyTransactionMethod))); mock.AssertWasCalled(x => x.GetTransaction(Arg <ITransactionDefinition> .Is.Anything), constraints => constraints.Repeat.Once()); mock.AssertWasCalled(x => x.Commit(Arg <ITransactionStatus> .Is.Anything), constraints => constraints.Repeat.Once()); }
public void ExecuteException() { IPlatformTransactionManager mock = MockRepository.GenerateMock <IPlatformTransactionManager>(); 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()); }