Now, we know what RegistrationManagement does and we have the User entity ready, so let's create the RegistrationManagementTests unit test. We will focus on the following:
- Make sure registering a user with an existing username fails
- Make sure registering a user with an existing email address fails
- Make sure registering a user with valid data succeeds and the password is encrypted
- Make sure all users' email addresses are saved as lowercase in the repository
The following are the test methods we will create to cover the cases listed previously:
- register_existedUsername_shouldFail()
- register_existedEmailAddress_shouldFail()
- register_uppercaseEmailAddress_shouldSucceedAndBecomeLowercase()
- register_newUser_shouldSucceed() ...