- Node.js
- npm
- Visual Studio Code
- Mocha
- Sinon
Note: If modules installed globally, use npm link module-name in project directory
- Create a Calculator class with an Add method.
- The method can take 0, 1 or 2 numbers, and will return their sum.
- For example: “” or “1” or “1,2”.
- For an empty string it will return Zero.
- Allow the Add method to handle an unknown amount of numbers.
- Create a String Calculator class with an Add method that takes in Strings.
- Inject the String Calculator into the Calculator using a constructor.
- Have the Calculator class delegate to the String Calculator class.
- Create a Numeric Calculator class with an Add method.
- Inject the Numeric Calculator into the Calculator using a setter method.
- If the Add method is called with string parameters, delegate to the String Calculator; if the Add method is called with numeric parameters, delegate to the Numeric Calculator.
Exercises based on TDD Kata by Roy Osherove