Fixing coverage

This commit is contained in:
2025-03-23 19:50:32 +01:00
parent 61f7504e66
commit e5a3e6fdcf
4 changed files with 12 additions and 78 deletions

View File

@@ -105,39 +105,35 @@ public class UserService_Tests
var user = await userService.CreateUserAsync(data, role);
Assert.IsInstanceOfType(user, typeof(User));
Assert.IsNotNull(user);
Assert.IsTrue(expectedUser.FirstName == user.FirstName);
Assert.IsTrue(expectedUser.LastName == user.LastName);
Assert.IsTrue(expectedUser.Email == user.Email);
Assert.IsTrue(expectedUser.Role?.Name == user.Role?.Name);
User realUser = user!;
Role realRole = user!.Role!;
// CheckIfEmailIsValid_CurrentUser
var valid = await userService.CheckIfEmailIsValid(realUser.Email, realUser.Guid);
var valid = await userService.CheckIfEmailIsValid(user.Email, user.Guid);
Assert.IsTrue(valid);
// CheckIfEmailIsValid_EmailAlreadyExists
valid = await userService.CheckIfEmailIsValid(realUser.Email);
valid = await userService.CheckIfEmailIsValid(user.Email);
Assert.IsFalse(valid);
//GetUserByIdAsync
var getUserById = await userService.GetUserByIdAsync(realUser.Id);
var getUserById = await userService.GetUserByIdAsync(user.Id);
Assert.IsNotNull(getUserById);
Assert.IsTrue(getUserById.Id == realUser?.Id);
Assert.IsTrue(getUserById.Id == user?.Id);
//GetUserByGuidAsync
var getUserByGuid = await userService.GetUserByGuidAsync(realUser.Guid);
var getUserByGuid = await userService.GetUserByGuidAsync(user.Guid);
Assert.IsNotNull(getUserByGuid);
Assert.IsTrue(getUserByGuid.Guid == realUser?.Guid);
Assert.IsTrue(getUserByGuid.Guid == user?.Guid);
//DeleteUserAsync
var deleted = await userService.DeleteUserAsync(realUser);
var deleted = await userService.DeleteUserAsync(user);
Assert.IsTrue(deleted);
//DeleteRoleAsync
deleted = await roleService.DeleteRoleAsync(realRole);
deleted = await roleService.DeleteRoleAsync(user.Role!);
Assert.IsTrue(deleted);
}
catch (Exception ex)