Roles #21

Merged
csimonapastore merged 36 commits from roles into main 2025-03-26 23:52:19 +01:00
2 changed files with 7 additions and 4 deletions
Showing only changes of commit 030882f3e1 - Show all commits

View File

@@ -1,6 +1,7 @@
using BasicDotnetTemplate.MainProject.Services; using BasicDotnetTemplate.MainProject.Services;
using BasicDotnetTemplate.MainProject.Models.Api.Data.User; using BasicDotnetTemplate.MainProject.Models.Api.Data.User;
using BasicDotnetTemplate.MainProject.Models.Database.SqlServer; using BasicDotnetTemplate.MainProject.Models.Database.SqlServer;
using Microsoft.EntityFrameworkCore;
namespace BasicDotnetTemplate.MainProject.Tests; namespace BasicDotnetTemplate.MainProject.Tests;
@@ -37,7 +38,7 @@ public class UserService_Tests
var userService = TestUtils.CreateUserService(); var userService = TestUtils.CreateUserService();
var user = ModelsInit.CreateUser(); var user = ModelsInit.CreateUser();
var role = ModelsInit.CreateRole(); var role = ModelsInit.CreateRole();
CreateUserRequestData data = new CreateUserRequestData() CreateUserRequestData data = new()
{ {
FirstName = user.FirstName, FirstName = user.FirstName,
LastName = user.LastName, LastName = user.LastName,
@@ -50,12 +51,12 @@ public class UserService_Tests
Assert.IsNotNull(createdUser); Assert.IsNotNull(createdUser);
// Act // Act
var retrievedUser = await userService.GetUserByIdAsync(createdUser.Id); var retrievedUser = await userService.GetUserByIdAsync(createdUser!.Id);
Assert.IsNotNull(retrievedUser); Assert.IsNotNull(retrievedUser);
// Assert // Assert
Assert.AreEqual(createdUser.Id, retrievedUser.Id); Assert.AreEqual(createdUser!.Id, retrievedUser!.Id);
Assert.AreEqual(createdUser.Guid, retrievedUser.Guid); Assert.AreEqual(createdUser!.Guid, retrievedUser!.Guid);
} }
} }

View File

@@ -124,7 +124,9 @@ public class UserService : BaseService, IUserService
} }
catch (Exception exception) catch (Exception exception)
{ {
await transaction.RollbackAsync();
Logger.Error(exception, $"[UserService][CreateUserAsync]"); Logger.Error(exception, $"[UserService][CreateUserAsync]");
throw;
} }