-
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: rewrite validators to use fluent validation
- Loading branch information
Showing
29 changed files
with
1,176 additions
and
1,357 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
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
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 |
---|---|---|
|
@@ -16,21 +16,21 @@ public class AuthServiceTests | |
private Mock<ReasnContext> _mockContext = null!; | ||
private PasswordHasher<User> _hasher = null!; | ||
private AuthService _service = null!; | ||
|
||
[TestInitialize] | ||
public void Setup() | ||
{ | ||
_mockContext = new Mock<ReasnContext>(); | ||
_hasher = new PasswordHasher<User>(); | ||
_service = new AuthService(_mockContext.Object); | ||
|
||
var user = new User | ||
{ | ||
Email = "[email protected]", | ||
Username = "jsnow", | ||
Password = _hasher.HashPassword(null!, "password") | ||
}; | ||
|
||
_mockContext.Setup(c => c.Users) | ||
.ReturnsDbSet(new List<User> { user }); | ||
} | ||
|
@@ -43,9 +43,9 @@ public void Login_WhenUserExistsAndPasswordIsCorrect_ShouldReturnUser() | |
Email = "[email protected]", | ||
Password = "password" | ||
}; | ||
|
||
var result = _service.Login(request); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsInstanceOfType(result, typeof(User)); | ||
} | ||
|
@@ -80,10 +80,10 @@ public void Register_WhenUserWithEmailAlreadyExists_ShouldThrowBadRequestExcepti | |
{ | ||
Email = "[email protected]" | ||
}; | ||
|
||
Assert.ThrowsException<BadRequestException>(() => _service.Register(request)); | ||
} | ||
|
||
[TestMethod] | ||
public void Register_WhenUserWithUsernameAlreadyExists_ShouldThrowBadRequestException() | ||
{ | ||
|
@@ -92,7 +92,7 @@ public void Register_WhenUserWithUsernameAlreadyExists_ShouldThrowBadRequestExce | |
Email = "[email protected]", | ||
Username = "jsnow" | ||
}; | ||
|
||
Assert.ThrowsException<BadRequestException>(() => _service.Register(request)); | ||
} | ||
|
||
|
@@ -116,9 +116,9 @@ public void Register_WhenUserDoesNotExist_ShouldReturnRegisteredUser() | |
}, | ||
Role = "User" | ||
}; | ||
|
||
var result = _service.Register(request); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsInstanceOfType(result, typeof(User)); | ||
} | ||
|
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
Oops, something went wrong.