Adds authorization module tests

This commit is contained in:
BinaryAlley committed 2025-01-01 22:56:07 +02:00
1 parent 718e1c49cf
commit 0114ff13e8
125 files changed
+10411 -203

No files matched your search

@@ -13,7 +13,7 @@ namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
/// Repository entity for a media library.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class LibraryEntity : IStorageEntity
public class LibraryEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of the media library.
@@ -48,10 +48,20 @@ public class LibraryEntity : IStorageEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime Created { get; set; }
public required DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public required Guid? UpdatedBy { get; set; }
}
@@ -12,7 +12,7 @@ namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenCont
/// Repository entity for a book.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class BookEntity : IStorageEntity
public class BookEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of the media item.
@@ -198,10 +198,20 @@ public class BookEntity : IStorageEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime Created { get; set; }
public required DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public required Guid? UpdatedBy { get; set; }
}
@@ -24,8 +24,8 @@ public static class LibraryEntityMapping
repositoryEntity.Title,
repositoryEntity.LibraryType,
repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
repositoryEntity.Created,
repositoryEntity.Updated
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
}
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Linq;
#endregion
@@ -25,8 +26,10 @@ public static class LibraryMapping
LibraryType = domainEntity.LibraryType,
UserId = domainEntity.UserId.Value,
ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
Created = domainEntity.Created,
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.Empty,
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
UpdatedBy = Guid.Empty
};
}
}
@@ -124,8 +124,8 @@ public static class BookEntityMapping
Optional<string>.FromNullable(repositoryEntity.GoogleBooksId),
Optional<string>.FromNullable(repositoryEntity.BarnesAndNobleId),
Optional<string>.FromNullable(repositoryEntity.AppleBooksId),
repositoryEntity.Created,
Optional<DateTime>.FromNullable(repositoryEntity.Updated),
repositoryEntity.CreatedOnUtc,
Optional<DateTime>.FromNullable(repositoryEntity.UpdatedOnUtc),
isbnsResult.Select(isbn => isbn.Value).ToList(),
[],
bookRatingsResult.Select(bookRating => bookRating.Value).ToList());
@@ -207,8 +207,8 @@ public static class BookEntityMapping
[.. repositoryEntity.ISBNs.ToResponses()],
null,
[.. repositoryEntity.Ratings.ToResponses()],
repositoryEntity.Created,
repositoryEntity.Updated
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
}
@@ -3,6 +3,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentL
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using System;
using System.Linq;
#endregion
@@ -56,8 +57,10 @@ public static class BookMapping
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
Created = domainEntity.Created,
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
UpdatedBy = domainEntity.UpdatedOnUtc.HasValue ? Guid.NewGuid() : null,
};
}
}
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using System;
using System.Linq;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion