public void ProgrammaticRollback() { ITransactionAttribute txatt = new DefaultTransactionAttribute(); MethodInfo m = typeof(RollbackTestObject).GetMethod("GetDescription"); MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource(); tas.AddTransactionalMethod(m, txatt); ITransactionStatus status = TransactionStatusForNewTransaction(); IPlatformTransactionManager ptm = PlatformTxManagerForNewTransaction(); Expect.Call(ptm.GetTransaction(txatt)).Return(status).Repeat.Once(); ptm.Commit(status); LastCall.On(ptm).Repeat.Once(); mocks.ReplayAll(); RollbackTestObject to = new RollbackTestObject(); ITestObject ito = (ITestObject)Advised(to, ptm, tas); Assert.AreEqual("test description", ito.GetDescription()); mocks.VerifyAll(); }
public void ProgrammaticRollback() { ITransactionAttribute txatt = new DefaultTransactionAttribute(); MethodInfo m = typeof(RollbackTestObject).GetMethod("GetDescription"); MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource(); tas.AddTransactionalMethod(m, txatt); ITransactionStatus status = A.Fake <ITransactionStatus>(); IPlatformTransactionManager ptm = A.Fake <IPlatformTransactionManager>(); A.CallTo(() => ptm.GetTransaction(txatt)).Returns(status).Once(); RollbackTestObject to = new RollbackTestObject(); ITestObject ito = (ITestObject)Advised(to, ptm, tas); Assert.AreEqual("test description", ito.GetDescription()); A.CallTo(() => ptm.Commit(status)).MustHaveHappenedOnceExactly(); }
public void ProgrammaticRollback() { ITransactionAttribute txatt = new DefaultTransactionAttribute(); MethodInfo m = typeof(RollbackTestObject).GetMethod("GetDescription"); MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource(); tas.AddTransactionalMethod(m, txatt); ITransactionStatus status = TransactionStatusForNewTransaction(); IPlatformTransactionManager ptm = PlatformTxManagerForNewTransaction(); Expect.Call(ptm.GetTransaction(txatt)).Return(status).Repeat.Once(); ptm.Commit(status); LastCall.On(ptm).Repeat.Once(); mocks.ReplayAll(); RollbackTestObject to = new RollbackTestObject(); ITestObject ito = (ITestObject) Advised(to, ptm, tas); Assert.AreEqual("test description", ito.GetDescription()); mocks.VerifyAll(); }