public void Transfer() { var twoAccounts = Context(delegate { var from = new Account("A"); var to = new Account("B"); from.Deposit(100); return new { from, to }; }); Given(twoAccounts) .When(c => c.from.Transfer(25, c.to)) .Then(c => c.from.Balance == 75) .And(c => c.to.Balance == 25); }
public void Transfer(int amount, Account account) { Balance -= amount; account.Deposit(amount); }