Simple example to demonstrate the utility of unit tests and mocking.
This is a simple example that illustrates the virtues of writing code in a unit-test-driven manner.
The domain is "how to decide the score-call in tennis based on the number of rallies won by the server and receiver".
- When the game starts, the score call is "Love All"
- When server wins first rally, score call is "Fifteen Love"
- When receiver wins first rally, score call is "Love Fifteen"
- When server wins second rally and receiver has not won any rallies, score call is "Thirty Love".
- When both server and receiver have won three rallies, score call is "Deuce"
- When server wins four rallies and receiver has won two rallies, score call is "Game Server"
- Once game is over, no more rallies can be scored.