This is an example project with code that exhibits common issues that make it hard to write tests.
The exercise is to take the current implementation of the Yucky class, refactor it into testable code, and add those tests.
My recommended approach is to look at the code, write down the issues that you have found, and take a try at refactoring. Then, go and read the "You suck at TDD series", come back, and see if you have any new thoughts.
After the fork from Eric Gunnersion's repository I did some refactoring and added tests. In summary my changes are:
- Created pinning tests for both types of EmployeeFilter to keep things safe while I refactored.
- Extracted methods and classes from Yucky.cs to separate the database call logic from the employee object creation logic.
- Created a constructor for the employee class. No more need to directly set properties.
- Added tests for the new employee class.
- Formatted the existing filtering logic so it is easier to read. No logic changes here.
- Changed the filtering from an enum and logic based on conditionals to multiple classes. This is the replace type switch with inheritance refactoring.
- That's all I have for now :) Any and all feedback is welcome.