-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: disallow registering user when phone is already used
- Loading branch information
Showing
2 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ public void Setup() | |
{ | ||
Email = "[email protected]", | ||
Username = "jsnow", | ||
Password = _hasher.HashPassword(null!, "password") | ||
Password = _hasher.HashPassword(null!, "password"), | ||
Phone = "+123 456789" | ||
}; | ||
|
||
_mockContext.Setup(c => c.Users) | ||
|
@@ -96,6 +97,19 @@ public void Register_WhenUserWithUsernameAlreadyExists_ShouldThrowBadRequestExce | |
Assert.ThrowsException<BadRequestException>(() => _service.Register(request)); | ||
} | ||
|
||
[TestMethod] | ||
public void Register_WhenUserWithPhoneAlreadyExists_ShouldThrowBadRequestException() | ||
{ | ||
var request = new RegisterRequest | ||
{ | ||
Email = "[email protected]", | ||
Username = "jstark", | ||
Phone = "+123 456789" | ||
}; | ||
|
||
Assert.ThrowsException<BadRequestException>(() => _service.Register(request)); | ||
} | ||
|
||
[TestMethod] | ||
public void Register_WhenUserDoesNotExist_ShouldReturnRegisteredUser() | ||
{ | ||
|
@@ -106,7 +120,7 @@ public void Register_WhenUserDoesNotExist_ShouldReturnRegisteredUser() | |
Email = "[email protected]", | ||
Username = "jstark", | ||
Password = "S3cureP@ssword!", | ||
Phone = "+123 456789", | ||
Phone = "+123 456781", | ||
Address = new AddressDto | ||
{ | ||
Street = "The Wall", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters