public void MovingFundsUsingTransactions_AAA() { //Arrange MockRepository mocks = new MockRepository(); IDatabaseManager databaseManager = mocks.StrictMock<IDatabaseManager>(); IBankAccount accountOne = mocks.StrictMock<IBankAccount>(), accountTwo = mocks.StrictMock<IBankAccount>(); using (mocks.Ordered()) { databaseManager.Expect(d => d.BeginTransaction()).Return(databaseManager); using (mocks.Unordered()) { accountOne.Expect(a => a.Withdraw(1000)); accountTwo.Expect(a => a.Deposit(1000)); } databaseManager.Dispose(); } //Act mocks.ReplayAll(); Bank bank = new Bank(databaseManager); bank.TransferFunds(accountOne, accountTwo, 1000); //Assert databaseManager.VerifyAllExpectations(); accountOne.VerifyAllExpectations(); accountTwo.VerifyAllExpectations(); }
public void MovingFundsUsingTransactions() { MockRepository mocks = new MockRepository(); IDatabaseManager databaseManager = mocks.StrictMock<IDatabaseManager>(); IBankAccount accountOne = mocks.StrictMock<IBankAccount>(), accountTwo = mocks.StrictMock<IBankAccount>(); using (mocks.Ordered()) { Expect.Call(databaseManager.BeginTransaction()).Return(databaseManager); using (mocks.Unordered()) { Expect.Call(accountOne.Withdraw(1000)); Expect.Call(accountTwo.Deposit(1000)); } databaseManager.Dispose(); } mocks.ReplayAll(); Bank bank = new Bank(databaseManager); bank.TransferFunds(accountOne, accountTwo, 1000); mocks.VerifyAll(); }