UserServiceTests¶
Namespace: UnitTests.Services
Unit tests for the UserService class, verifying user management operations including retrieval, updates, and deletion.
Inheritance Object → UserServiceTests
Constructors¶
UserServiceTests()¶
Methods¶
ChangePassword_WhenExceptionThrown_ShouldLogErrorAndRethrow()¶
Changes a user's password and verifies that an exception is thrown when invalid data is provided.
Returns¶
ChangePassword_WithValidData_ShouldChangePasswordSuccessfully()¶
Changes a user's password and verifies that the password is changed successfully.
Returns¶
ChangeUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()¶
Changes a user's information and verifies that an exception is logged and rethrown.
Returns¶
ChangeUser_WithInvalidData_ShouldThrowException()¶
Changes a user's information and verifies that an exception is thrown when invalid data is provided.
Returns¶
ChangeUser_WithValidUser_ShouldUpdateUserSuccessfully()¶
Changes a user's information and verifies that the user is updated successfully.
Returns¶
DeleteUser_WhenDeletionFails_ShouldReturnFalse()¶
Deletes a user and verifies that the deletion fails, returning false.
Returns¶
DeleteUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()¶
Deletes a user and verifies that an exception is logged and rethrown.
Returns¶
DeleteUser_WithValidUser_ShouldDeleteUserSuccessfully()¶
Deletes a user and verifies that the deletion is successful, returning true.
Returns¶
GetUserById_WhenExceptionThrown_ShouldLogErrorAndRethrow()¶
Gets a user by ID and verifies that an exception is logged and rethrown when an error occurs.
Returns¶
GetUserById_WithNonExistentId_ShouldReturnNull()¶
Gets a user by ID and verifies that null is returned when the user does not exist.
Returns¶
GetUserById_WithValidId_ShouldReturnUser()¶
Gets a user by ID and verifies that the user is returned successfully.
Returns¶
GetUserInformations_ShouldReturnAllUsers()¶
Tests that GetUserInformations returns all users from the system.
GetUserInformations_WhenExceptionThrown_ShouldLogErrorAndRethrow()¶
Gets user information and verifies that the user list is returned successfully.
Returns¶
GetUserInformations_WhenNoUsers_ShouldReturnEmptyList()¶
Gets user information and verifies that an empty list is returned when no users exist.
Setup()¶
Sets up test fixtures and initializes mocks before each test execution.