Exercise: Testing legacy projects
The problem
We have been asked to refactor the UserService
class of LegacyApp
library that can be found under the RefactoringTest
folder.
In order to make sure that the existing logic of the library does not change during our refactoring we need to cover it with unit tests.
However, since this library is already used by means we CANNOT make any breaking changes.
Breaking changes include is anything that would stop any code at LegacyApp.Consumer
from compiling.
You CANNOT change the LegacyApp.Consumer
code at all.
You also CANNOT change the UserDataAccess
class and its AddUser
method. They both have to remain static.
You should also assume that anything inside the UserCreditService.cs
file is code generated and shall not be changed.
The test cases needed are:
AddUser_ShouldNotCreateUser_WhenFirstNameIsEmpty
AddUser_ShouldNotCreateUser_WhenLastNameIsEmpty
AddUser_ShouldNotCreateUser_WhenEmailIsInvalid
AddUser_ShouldNotCreateUser_WhenUserIsUnder21
AddUser_ShouldNotCreateUser_WhenUserHasCreditLimitAndLimitIsLessThan500
AddUser_ShouldCreateUser_WhenUserDetailsAreValid