Adds tests for the book reading feature

This commit is contained in:
BinaryAlley committed 2026-09-02 04:45:51 -07:00
1 parent f7ccdf3d1c
commit 3a3c0c047c
192 files changed
+14104 -342

No files matched your search

@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
/// <summary>
/// Fixture class for the <see cref="LibraryBookReaderConfigurationEntity"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryBookReaderConfigurationEntityFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryBookReaderConfigurationEntity"/>.
/// </summary>
/// <param name="id">Optional. The Id of the configuration.</param>
/// <param name="libraryId">Optional. The Id of the media library the configuration belongs to.</param>
/// <param name="pluginId">Optional. The Id of the plugin providing the book reader.</param>
/// <param name="isEnabled">Optional. Whether the book reader is enabled for the media library.</param>
/// <returns>The created <see cref="LibraryBookReaderConfigurationEntity"/>.</returns>
public LibraryBookReaderConfigurationEntity Create(
Guid? id = null,
Guid? libraryId = null,
Guid? pluginId = null,
bool? isEnabled = null)
{
return new Faker<LibraryBookReaderConfigurationEntity>()
.RuleFor(configuration => configuration.Id, _ => id ?? Guid.NewGuid())
.RuleFor(configuration => configuration.LibraryId, _ => libraryId ?? Guid.NewGuid())
.RuleFor(configuration => configuration.PluginId, _ => pluginId ?? Guid.NewGuid())
.RuleFor(configuration => configuration.IsEnabled, _ => isEnabled ?? true)
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
.Generate();
}
/// <summary>
/// Creates a list of <see cref="LibraryBookReaderConfigurationEntity"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryBookReaderConfigurationEntity"/> instances.</returns>
public List<LibraryBookReaderConfigurationEntity> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -25,6 +25,8 @@ public class UserSettingsEntityFixture
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <returns>The created user settings entity.</returns>
public UserSettingsEntity Create(
Guid? id = null,
@@ -33,7 +35,9 @@ public class UserSettingsEntityFixture
int? itemsPerPage = null,
bool? shouldIgnoreThePrefixForAlphaPicker = null,
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null)
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
{
return new Faker<UserSettingsEntity>()
.CustomInstantiator(f => new UserSettingsEntity
@@ -44,7 +48,9 @@ public class UserSettingsEntityFixture
ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100),
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(),
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool()
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(),
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(),
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool()
})
.Generate();
}