Questions About the Example
One of our favorite reviewers wasn't so sure we had tested everything. He asked:
Can the Account Go Negative? How Negative?
Yes, clearly it can, because the balance method just adds up the transactions, without regard to their sign. Does that need a unit test? Not in my opinion, because it can't possibly break.
Does it need an acceptance test? Almost certainly.
Can an Account Have Fractions Less than One Penny?
The code doesn't say. What will determine the answer will be the class of the object that comes back from sending value to a Transaction. That might be something as simple as an Integer or a Float, but it is more likely some kind of monetary type. In any case, the answer isn't here in Account, but in that class. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access