Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,142 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Application.Common.Mapping.UsersManagement.Users;
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.UsersManagement.Users;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users;
/// <summary>
/// Contains unit tests for the <see cref="UserEntityMapping"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserEntityMappingTests
{
private readonly UserEntityFixture _userEntityFixture = new();
[Fact]
public void ToResponse_WhenMappingValidUserEntity_ShouldMapCorrectly()
{
// Arrange
UserEntity entity = _userEntityFixture.Create();
// Act
UserResponse result = entity.ToResponse();
// Assert
Assert.NotNull(result);
Assert.Equal(entity.Id, result.Id);
Assert.Equal(entity.Username, result.Username);
Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc);
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
}
[Theory]
[InlineData("user1")]
[InlineData("test.user")]
[InlineData("john_doe")]
[InlineData("jane.doe@example.com")]
public void ToResponse_WhenMappingDifferentUsernames_ShouldMapCorrectly(string username)
{
// Arrange
UserEntity entity = _userEntityFixture.Create();
entity.Username = username;
// Act
UserResponse result = entity.ToResponse();
// Assert
Assert.NotNull(result);
Assert.Equal(username, result.Username);
}
[Fact]
public void ToResponse_WhenMappingWithUpdatedDateTime_ShouldMapCorrectly()
{
// Arrange
UserEntity entity = _userEntityFixture.Create();
entity.UpdatedOnUtc = DateTime.UtcNow.AddDays(-1);
// Act
UserResponse result = entity.ToResponse();
// Assert
Assert.NotNull(result);
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
}
[Fact]
public void ToResponse_WhenMappingWithLibraries_ShouldNotAffectMapping()
{
// Arrange
UserEntity entity = _userEntityFixture.Create(2);
// Act
UserResponse result = entity.ToResponse();
// Assert
Assert.NotNull(result);
Assert.Equal(entity.Id, result.Id);
Assert.Equal(entity.Username, result.Username);
Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc);
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
}
[Fact]
public void ToResponses_WhenMappingMultipleEntities_ShouldMapCorrectly()
{
// Arrange
List<UserEntity> entities = _userEntityFixture.CreateMany(3);
// Act
IEnumerable<UserResponse> results = entities.ToResponses();
// Assert
Assert.NotNull(results);
Assert.Equal(3, results.Count());
List<UserResponse> resultsList = [..results];
List<UserEntity> entitiesList = [.. entities];
for (int i = 0; i < resultsList.Count; i++)
{
Assert.Equal(entitiesList[i].Id, resultsList[i].Id);
Assert.Equal(entitiesList[i].Username, resultsList[i].Username);
}
}
[Fact]
public void ToResponses_WhenMappingEmptyCollection_ShouldReturnEmptyCollection()
{
// Arrange
List<UserEntity> entities = [];
// Act
IEnumerable<UserResponse> results = entities.ToResponses();
// Assert
Assert.NotNull(results);
Assert.Empty(results);
}
[Fact]
public void ToResponse_WhenMappingWithoutUpdatedDateTime_ShouldMapCorrectly()
{
// Arrange
UserEntity entity = _userEntityFixture.Create();
entity.UpdatedOnUtc = null;
// Act
UserResponse result = entity.ToResponse();
// Assert
Assert.NotNull(result);
Assert.Null(result.UpdatedOnUtc);
}
}
@@ -0,0 +1,102 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Application.Common.Mapping.UsersManagement.Users;
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users;
/// <summary>
/// Contains unit tests for the <see cref="UserMapping"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserMappingTests
{
private readonly UserFixture _userFixture = new();
private readonly UserEntityFixture _userEntityFixture = new();
private readonly LibraryEntityFixture _libraryEntityFixture = new();
[Fact]
public void ToRepositoryEntity_WhenMappingValidUser_ShouldOnlyUpdateUsername()
{
// Arrange
User domainEntity = _userFixture.Create(username: "newusername");
UserEntity repositoryEntity = _userEntityFixture.Create(username: "oldusername", password: "hashedpassword");
// Act
UserEntity result = domainEntity.ToRepositoryEntity(repositoryEntity);
// Assert
Assert.NotNull(result);
Assert.Same(repositoryEntity, result); // Should modify the same instance.
Assert.Equal(domainEntity.Username, result.Username); // Only username should be updated.
// Verify other properties remain unchanged.
Assert.Equal(repositoryEntity.Id, result.Id);
Assert.Equal(repositoryEntity.Password, result.Password);
Assert.Equal(repositoryEntity.TotpSecret, result.TotpSecret);
Assert.Same(repositoryEntity.Libraries, result.Libraries);
Assert.Same(repositoryEntity.UserPermissions, result.UserPermissions);
Assert.Same(repositoryEntity.UserRole, result.UserRole);
Assert.Equal(repositoryEntity.CreatedOnUtc, result.CreatedOnUtc);
Assert.Equal(repositoryEntity.CreatedBy, result.CreatedBy);
Assert.Equal(repositoryEntity.UpdatedOnUtc, result.UpdatedOnUtc);
Assert.Equal(repositoryEntity.UpdatedBy, result.UpdatedBy);
}
[Theory]
[InlineData("user1")]
[InlineData("test.user")]
[InlineData("john_doe")]
[InlineData("jane.doe@example.com")]
public void ToRepositoryEntity_WhenMappingDifferentUsernames_ShouldUpdateCorrectly(string newUsername)
{
// Arrange
User domainEntity = _userFixture.Create(username: newUsername);
UserEntity repositoryEntity = _userEntityFixture.Create(username: "oldusername", password: "hashedpassword");
// Act
UserEntity result = domainEntity.ToRepositoryEntity(repositoryEntity);
// Assert
Assert.NotNull(result);
Assert.Equal(newUsername, result.Username);
}
[Fact]
public void ToRepositoryEntity_WhenRepositoryEntityHasLibraries_ShouldPreserveLibraries()
{
// Arrange
User domainEntity = _userFixture.Create(username: "newusername");
List<LibraryEntity> libraries =
[
_libraryEntityFixture.Create(title: "Library 1", libraryType: LibraryType.Book, contentLocations: []),
_libraryEntityFixture.Create(title: "Library 2", libraryType: LibraryType.Movie, contentLocations: [])
];
UserEntity repositoryEntity = _userEntityFixture.Create(
username: "oldusername",
password: "hashedpassword",
libraries: libraries);
// Act
UserEntity result = domainEntity.ToRepositoryEntity(repositoryEntity);
// Assert
Assert.NotNull(result);
Assert.Same(libraries, result.Libraries);
Assert.Equal(2, result.Libraries.Count);
}
}