Skip to content

UserServiceTests

Namespace: UnitTests.Services

Unit tests for the UserService class, verifying user management operations including retrieval, updates, and deletion.

public class UserServiceTests

Inheritance ObjectUserServiceTests

Constructors

UserServiceTests()

public UserServiceTests()

Methods

ChangePassword_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Changes a user's password and verifies that an exception is thrown when invalid data is provided.

public Task ChangePassword_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Returns

Task

ChangePassword_WithValidData_ShouldChangePasswordSuccessfully()

Changes a user's password and verifies that the password is changed successfully.

public Task ChangePassword_WithValidData_ShouldChangePasswordSuccessfully()

Returns

Task

ChangeUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Changes a user's information and verifies that an exception is logged and rethrown.

public Task ChangeUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Returns

Task

ChangeUser_WithInvalidData_ShouldThrowException()

Changes a user's information and verifies that an exception is thrown when invalid data is provided.

public Task ChangeUser_WithInvalidData_ShouldThrowException()

Returns

Task

ChangeUser_WithValidUser_ShouldUpdateUserSuccessfully()

Changes a user's information and verifies that the user is updated successfully.

public Task ChangeUser_WithValidUser_ShouldUpdateUserSuccessfully()

Returns

Task

DeleteUser_WhenDeletionFails_ShouldReturnFalse()

Deletes a user and verifies that the deletion fails, returning false.

public Task DeleteUser_WhenDeletionFails_ShouldReturnFalse()

Returns

Task

DeleteUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Deletes a user and verifies that an exception is logged and rethrown.

public Task DeleteUser_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Returns

Task

DeleteUser_WithValidUser_ShouldDeleteUserSuccessfully()

Deletes a user and verifies that the deletion is successful, returning true.

public Task DeleteUser_WithValidUser_ShouldDeleteUserSuccessfully()

Returns

Task

GetUserById_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Gets a user by ID and verifies that an exception is logged and rethrown when an error occurs.

public Task GetUserById_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Returns

Task

GetUserById_WithNonExistentId_ShouldReturnNull()

Gets a user by ID and verifies that null is returned when the user does not exist.

public Task GetUserById_WithNonExistentId_ShouldReturnNull()

Returns

Task

GetUserById_WithValidId_ShouldReturnUser()

Gets a user by ID and verifies that the user is returned successfully.

public Task GetUserById_WithValidId_ShouldReturnUser()

Returns

Task

GetUserInformations_ShouldReturnAllUsers()

Tests that GetUserInformations returns all users from the system.

public void GetUserInformations_ShouldReturnAllUsers()

GetUserInformations_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Gets user information and verifies that the user list is returned successfully.

public Task GetUserInformations_WhenExceptionThrown_ShouldLogErrorAndRethrow()

Returns

Task

GetUserInformations_WhenNoUsers_ShouldReturnEmptyList()

Gets user information and verifies that an empty list is returned when no users exist.

public void GetUserInformations_WhenNoUsers_ShouldReturnEmptyList()

Setup()

Sets up test fixtures and initializes mocks before each test execution.

public void Setup()