mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Adds book editing tests and parameterizes the shared test fixtures
This commit is contained in:
1 parent
1bfa07ba5d
commit
145185d715
354 files changed
+7118
-1743
No files matched your search
+1
-1
@@ -23,7 +23,7 @@ public class RoleEntityFixture
|
||||
/// <param name="id">Optional. The Id of the role.</param>
|
||||
/// <param name="roleName">Optional. The name of the role.</param>
|
||||
/// <param name="rolePermissions">Optional. The role permission associations of the role.</param>
|
||||
/// <param name="includeRolePermissions">Whether the role should include role permission associations or not.</param>
|
||||
/// <param name="includeRolePermissions">Whether the role permission associations should be included, or forced to an empty collection.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the role.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the role was added.</param>
|
||||
/// <returns>The created <see cref="RoleEntity"/>.</returns>
|
||||
|
||||
+3
-2
@@ -87,9 +87,10 @@ public class LibraryEntityFixture
|
||||
/// Creates a list of <see cref="LibraryEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the created media libraries.</param>
|
||||
/// <returns>List of configured <see cref="LibraryEntity"/> instances.</returns>
|
||||
public List<LibraryEntity> CreateMany(int count = 3)
|
||||
public List<LibraryEntity> CreateMany(int count = 3, Guid? userId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(userId: userId))];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class BookEntityFixture
|
||||
/// <param name="path">Optional. The file system path of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the book.</param>
|
||||
/// <param name="includeMetadata">Whether the book should include its owned metadata collections (Tags, Genres, ISBNs, Ratings) or not.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, ISBNs, Ratings) should be included, or forced to empty collections.</param>
|
||||
/// <returns>The created <see cref="BookEntity"/>.</returns>
|
||||
public BookEntity Create(
|
||||
Guid? id = null,
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class BookRatingEntityFixture
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
|
||||
/// <param name="source">Optional. The rating source.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes.</param>
|
||||
/// <param name="includeValues">Whether the rating properties should be populated. Set to <see langword="false"/> to create an invalid entity.</param>
|
||||
/// <param name="includeValues">Whether the rating properties should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created book rating entity.</returns>
|
||||
public BookRatingEntity Create(
|
||||
decimal? value = null,
|
||||
|
||||
+4
-4
@@ -26,18 +26,18 @@ public class ThemeEntityFixture
|
||||
/// <param name="author">Optional author of the theme.</param>
|
||||
/// <param name="version">Optional version of the theme.</param>
|
||||
/// <param name="previewPath">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
|
||||
/// <param name="includePreviewPath">Whether to set <paramref name="previewPath"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="installSource">Optional source the theme was installed from.</param>
|
||||
/// <param name="isCurrent">Optional value indicating whether the theme is the currently active one.</param>
|
||||
/// <param name="includeIsCurrent">Whether to set <paramref name="isCurrent"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="isDeleted">Optional value indicating whether the theme was soft deleted.</param>
|
||||
/// <param name="installedAtUtc">Optional UTC timestamp when the theme was installed.</param>
|
||||
/// <param name="createdOnUtc">Optional UTC timestamp when the entity was created.</param>
|
||||
/// <param name="createdBy">Optional Id of the user that created the entity.</param>
|
||||
/// <param name="updatedOnUtc">Optional UTC timestamp when the entity was updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether to set <paramref name="updatedOnUtc"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the updated-on timestamp should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="updatedBy">Optional Id of the user that updated the entity.</param>
|
||||
/// <param name="includeUpdatedBy">Whether to set <paramref name="updatedBy"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updated-by user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ThemeEntity"/> instance.</returns>
|
||||
public ThemeEntity Create(
|
||||
Guid? id = null,
|
||||
|
||||
+6
-28
@@ -3,7 +3,7 @@ using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -18,6 +18,8 @@ namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserEntityFixture
|
||||
{
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserEntity"/>.
|
||||
/// </summary>
|
||||
@@ -27,8 +29,8 @@ public class UserEntityFixture
|
||||
/// <param name="id">Optional Id to pin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="userRole">Optional user role association to pin when including it.</param>
|
||||
/// <param name="userPermissions">Optional user permission associations to pin when including them.</param>
|
||||
/// <param name="includeUserRole">Whether the user should include a user role association or not.</param>
|
||||
/// <param name="includeUserPermissions">Whether the user should include user permission associations or not.</param>
|
||||
/// <param name="includeUserRole">Whether the user role association should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUserPermissions">Whether the user permission associations should be included, or forced to an empty collection.</param>
|
||||
/// <param name="libraries">Optional collection of libraries to pin for the user, or <see langword="null"/> to generate them based on <paramref name="libraryCount"/>.</param>
|
||||
/// <returns>The created user entity.</returns>
|
||||
public UserEntity Create(
|
||||
@@ -44,7 +46,7 @@ public class UserEntityFixture
|
||||
{
|
||||
Guid userId = id ?? Guid.NewGuid();
|
||||
ICollection<LibraryEntity> resolvedLibraries = libraries ?? (libraryCount > 0
|
||||
? CreateLibraries(libraryCount, userId)
|
||||
? _libraryEntityFixture.CreateMany(libraryCount, userId)
|
||||
: []);
|
||||
|
||||
return new Faker<UserEntity>()
|
||||
@@ -77,28 +79,4 @@ public class UserEntityFixture
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryCount))];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid collection of user libraries.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of user libraries to create.</param>
|
||||
/// <param name="userId">The unique identifier of the user for whom to create the libraries.</param>
|
||||
/// <returns>A collection of <see cref="LibraryEntity"/>.</returns>
|
||||
private static List<LibraryEntity> CreateLibraries(int count, Guid userId)
|
||||
{
|
||||
return new Faker<LibraryEntity>()
|
||||
.CustomInstantiator(f => new LibraryEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = userId,
|
||||
Title = f.Commerce.ProductName(),
|
||||
LibraryType = f.PickRandom<LibraryType>(),
|
||||
ContentLocations = [],
|
||||
CreatedOnUtc = f.Date.Past(),
|
||||
CreatedBy = userId,
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate(count);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class ThemeManifestDtoFixture
|
||||
/// <param name="author">Optional author of the theme.</param>
|
||||
/// <param name="version">Optional version of the theme.</param>
|
||||
/// <param name="preview">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
|
||||
/// <param name="includePreview">Whether to set <paramref name="preview"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="includePreview">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="templates">Optional template mappings of the theme.</param>
|
||||
/// <returns>A configured <see cref="ThemeManifestDto"/> instance.</returns>
|
||||
public ThemeManifestDto Create(
|
||||
|
||||
Reference in new issue
Block a user