AuthenticationServiceTests¶
Namespace: UnitTests.Services
Unit tests for the AuthenticationService class, verifying user authentication, registration, and token management functionality.
Inheritance Object → AuthenticationServiceTests
Constructors¶
AuthenticationServiceTests()¶
Methods¶
ChangePassword_WithValidData_ShouldChangePasswordSuccessfully()¶
Changes the password of a user with valid current password and new password, verifying that it changes successfully.
Returns¶
ChangeUser_WithValidUser_ShouldUpdateUserSuccessfully()¶
Changes the password of a user with invalid current password and verifies that it throws an exception.
Returns¶
DeleteUser_WithValidUser_ShouldDeleteUserSuccessfully()¶
Deletes a user with a valid user object and verifies that the user is deleted successfully.
Returns¶
GetUserById_WithValidId_ShouldReturnUser()¶
Gets a user by ID with a valid user ID and verifies that the user is returned correctly.
Returns¶
GetUserInformations_ShouldReturnAllUsers()¶
Gets all user information and verifies that the service can be called without errors.
Login_WithEmptyUsername_ShouldThrowAuthenticationException()¶
Logs in a user with an empty username, expecting an AuthenticationException to be thrown.
Returns¶
Login_WithInvalidCredentials_ShouldThrowAuthenticationException()¶
Logs in a user with invalid credentials, expecting an AuthenticationException to be thrown.
Returns¶
Login_WithNonExistentUser_ShouldThrowAuthenticationException()¶
Logs in a user with a non-existent username, expecting an AuthenticationException to be thrown.
Returns¶
Login_WithValidCredentials_ShouldReturnJwtToken()¶
Logs in a user with valid credentials and verifies that it returns a JWT token.
Returns¶
RefreshToken_WithExpiredRefreshToken_ShouldThrowAuthenticationException()¶
Refreshes a token with an expired refresh token, expecting an AuthenticationException.
Returns¶
RefreshToken_WithInvalidRefreshToken_ShouldThrowAuthenticationException()¶
Refreshes a token with an expired JWT token and verifies that it throws an AuthenticationException.
Returns¶
RefreshToken_WithValidToken_ShouldReturnNewJwtToken()¶
Refreshes a token with a valid JWT token and refresh token, verifying that it returns a new JWT token.
Returns¶
Register_WhenUserCreationFails_ShouldThrowException()¶
Registers a user when user creation fails, expecting an exception.
Returns¶
Register_WithEmptyPassword_ShouldThrowAuthenticationException()¶
Registers a user with an empty password, expecting an AuthenticationException.
Returns¶
Register_WithEmptyUsername_ShouldThrowAuthenticationException()¶
Registers a user with an empty username or password, expecting an AuthenticationException.
Returns¶
Register_WithExistingUsername_ShouldThrowException()¶
Registers a user with an existing username, expecting an exception.
Returns¶
Register_WithValidInput_ShouldCreateUserSuccessfully()¶
Tests that registration with valid input creates a user successfully.
Returns¶
Setup()¶
Sets up test fixtures and initializes mocks before each test execution.