mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21:11:10 +00:00
Adds tests for the book reading feature
This commit is contained in:
1 parent
f7ccdf3d1c
commit
3a3c0c047c
192 files changed
+14104
-342
No files matched your search
+53
@@ -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())];
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -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();
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
@@ -14,7 +14,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddBookCommand"/> class.
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBooksQuery"/> class.
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooksLite;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBooksLiteQuery"/> class.
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingAvailabilityQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingAvailabilityQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to check the reading availability of a book.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading availability is checked.</param>
|
||||
/// <returns>The created <see cref="GetReadingAvailabilityQuery"/>.</returns>
|
||||
public GetReadingAvailabilityQuery Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetReadingAvailabilityQuery(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingAvailabilityQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingAvailabilityQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingManifestQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingManifestQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the reading manifest of a book.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading manifest is retrieved.</param>
|
||||
/// <returns>The created <see cref="GetReadingManifestQuery"/>.</returns>
|
||||
public GetReadingManifestQuery Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetReadingManifestQuery(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingManifestQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingManifestQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingResourceQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingResourceQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get a resource of a book.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose resource is retrieved.</param>
|
||||
/// <param name="resourceKey">Optional. The opaque resource key of the resource.</param>
|
||||
/// <returns>The created <see cref="GetReadingResourceQuery"/>.</returns>
|
||||
public GetReadingResourceQuery Create(
|
||||
Guid? bookId = null,
|
||||
string? resourceKey = null)
|
||||
{
|
||||
return new GetReadingResourceQuery(bookId ?? Guid.NewGuid(), resourceKey ?? $"resource-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingResourceQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingResourceQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingSectionQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingSectionQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the content of a reading section of a book.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading section is retrieved.</param>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <returns>The created <see cref="GetReadingSectionQuery"/>.</returns>
|
||||
public GetReadingSectionQuery Create(
|
||||
Guid? bookId = null,
|
||||
string? locationRef = null)
|
||||
{
|
||||
return new GetReadingSectionQuery(bookId ?? Guid.NewGuid(), locationRef ?? $"section-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingSectionQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingSectionQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryBookReaderEnabled;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.SetLibraryBookReaderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetLibraryBookReaderEnabledCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryBookReaderEnabledCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to enable or disable a book reader for a media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book reader is enabled or disabled.</param>
|
||||
/// <param name="pluginId">Optional. The unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the book reader should be enabled for the media library.</param>
|
||||
/// <returns>The created <see cref="SetLibraryBookReaderEnabledCommand"/>.</returns>
|
||||
public SetLibraryBookReaderEnabledCommand Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new SetLibraryBookReaderEnabledCommand(libraryId ?? Guid.NewGuid(), pluginId ?? Guid.NewGuid(), isEnabled ?? true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetLibraryBookReaderEnabledCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetLibraryBookReaderEnabledCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryBookReaders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Plugins.Queries.GetLibraryBookReaders;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetLibraryBookReadersQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryBookReadersQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the book readers configured for a media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book readers are retrieved.</param>
|
||||
/// <returns>The created <see cref="GetLibraryBookReadersQuery"/>.</returns>
|
||||
public GetLibraryBookReadersQuery Create(
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new GetLibraryBookReadersQuery(libraryId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetLibraryBookReadersQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetLibraryBookReadersQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -21,21 +21,28 @@ public class UpdateUserSettingsCommandFixture
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <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.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateUserSettingsCommand Create(
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
bool? shouldAggregateMetadataWhenMissing = null,
|
||||
bool? shouldRenderPdfAsImages = null,
|
||||
bool? shouldPreserveBookStyles = null)
|
||||
{
|
||||
return new Faker<UpdateUserSettingsCommand>()
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default))
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default))
|
||||
.RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
|
||||
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
||||
.RuleFor(x => x.IsThemeCachingEnabled, f => isThemeCachingEnabled ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ShouldAggregateMetadataWhenMissing, f => shouldAggregateMetadataWhenMissing ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ShouldRenderPdfAsImages, f => shouldRenderPdfAsImages ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingDocumentDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingDocumentDtoFixture
|
||||
{
|
||||
private readonly ReadingTocEntryDtoFixture _readingTocEntryDtoFixture = new();
|
||||
private readonly ReadingSpineItemDtoFixture _readingSpineItemDtoFixture = new();
|
||||
private readonly ReadingResourceInfoDtoFixture _readingResourceInfoDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingDocumentDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="author">Optional. The author of the book, if known.</param>
|
||||
/// <param name="coverResourceKey">Optional. The resource key of the cover image of the book, if applicable.</param>
|
||||
/// <param name="tableOfContents">Optional. The hierarchical table of contents of the book.</param>
|
||||
/// <param name="spine">Optional. The ordered spine of the reading sections of the book.</param>
|
||||
/// <param name="resources">Optional. The resources of the book, keyed by their resource key.</param>
|
||||
/// <param name="hasTextContent">Optional. Whether the book has extractable text content.</param>
|
||||
/// <returns>The created <see cref="ReadingDocumentDto"/>.</returns>
|
||||
public ReadingDocumentDto Create(
|
||||
string? title = null,
|
||||
string? author = null,
|
||||
string? coverResourceKey = null,
|
||||
IReadOnlyList<ReadingTocEntryDto>? tableOfContents = null,
|
||||
IReadOnlyList<ReadingSpineItemDto>? spine = null,
|
||||
IReadOnlyDictionary<string, ReadingResourceInfoDto>? resources = null,
|
||||
bool? hasTextContent = null)
|
||||
{
|
||||
return new ReadingDocumentDto(
|
||||
title ?? $"Book {Guid.NewGuid():N}",
|
||||
author,
|
||||
coverResourceKey,
|
||||
tableOfContents ?? [.. _readingTocEntryDtoFixture.CreateMany(2)],
|
||||
spine ?? [.. _readingSpineItemDtoFixture.CreateMany(2)],
|
||||
resources ?? new Dictionary<string, ReadingResourceInfoDto>
|
||||
{
|
||||
[$"resource-{Guid.NewGuid():N}"] = _readingResourceInfoDtoFixture.Create()
|
||||
},
|
||||
hasTextContent ?? true
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingDocumentDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingDocumentDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingResourceDataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingResourceDataDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingResourceDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The binary data of the resource.</param>
|
||||
/// <param name="mimeType">Optional. The MIME type of the resource.</param>
|
||||
/// <returns>The created <see cref="ReadingResourceDataDto"/>.</returns>
|
||||
public ReadingResourceDataDto Create(
|
||||
byte[]? data = null,
|
||||
string? mimeType = null)
|
||||
{
|
||||
return new ReadingResourceDataDto(data ?? Guid.NewGuid().ToByteArray(), mimeType ?? "image/png");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingResourceDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingResourceDataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingResourceInfoDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingResourceInfoDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingResourceInfoDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="relativeFilePath">Optional. The path of the resource file, relative to the extraction directory of the book.</param>
|
||||
/// <param name="mimeType">Optional. The MIME type of the resource.</param>
|
||||
/// <returns>The created <see cref="ReadingResourceInfoDto"/>.</returns>
|
||||
public ReadingResourceInfoDto Create(
|
||||
string? relativeFilePath = null,
|
||||
string? mimeType = null)
|
||||
{
|
||||
return new ReadingResourceInfoDto(relativeFilePath ?? $"resources/resource-{Guid.NewGuid():N}.png", mimeType ?? "image/png");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingResourceInfoDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingResourceInfoDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingSectionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSectionDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingSectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional. The title of the reading section, if known.</param>
|
||||
/// <param name="contentHtml">Optional. The sanitized HTML content of the reading section.</param>
|
||||
/// <returns>The created <see cref="ReadingSectionDto"/>.</returns>
|
||||
public ReadingSectionDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null,
|
||||
string? contentHtml = null)
|
||||
{
|
||||
return new ReadingSectionDto(locationRef ?? $"section-{Guid.NewGuid():N}", title, contentHtml ?? "<section><p>Content</p></section>");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingSectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingSectionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingSpineItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSpineItemDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingSpineItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional. The title of the reading section, if known.</param>
|
||||
/// <param name="relativeSectionFilePath">Optional. The path of the section content file, relative to the extraction directory of the book.</param>
|
||||
/// <returns>The created <see cref="ReadingSpineItemDto"/>.</returns>
|
||||
public ReadingSpineItemDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null,
|
||||
string? relativeSectionFilePath = null)
|
||||
{
|
||||
return new ReadingSpineItemDto(locationRef ?? $"section-{Guid.NewGuid():N}", title, relativeSectionFilePath ?? $"sections/{Guid.NewGuid():N}.html");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingSpineItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingSpineItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingTocEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingTocEntryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingTocEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="label">Optional. The label of the table of contents entry.</param>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section the entry points to.</param>
|
||||
/// <param name="children">Optional. The child entries of the table of contents entry.</param>
|
||||
/// <returns>The created <see cref="ReadingTocEntryDto"/>.</returns>
|
||||
public ReadingTocEntryDto Create(
|
||||
string? label = null,
|
||||
string? locationRef = null,
|
||||
IReadOnlyList<ReadingTocEntryDto>? children = null)
|
||||
{
|
||||
return new ReadingTocEntryDto(
|
||||
label ?? $"Chapter {Guid.NewGuid():N}",
|
||||
locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
children ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingTocEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingTocEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingAvailabilityRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingAvailabilityRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading availability is checked.</param>
|
||||
/// <returns>The created <see cref="GetReadingAvailabilityRequest"/>.</returns>
|
||||
public GetReadingAvailabilityRequest Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetReadingAvailabilityRequest(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingAvailabilityRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingManifestRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingManifestRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading manifest is retrieved.</param>
|
||||
/// <returns>The created <see cref="GetReadingManifestRequest"/>.</returns>
|
||||
public GetReadingManifestRequest Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetReadingManifestRequest(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingManifestRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingResourceRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingResourceRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose resource is retrieved.</param>
|
||||
/// <param name="resourceKey">Optional. The opaque resource key of the resource.</param>
|
||||
/// <returns>The created <see cref="GetReadingResourceRequest"/>.</returns>
|
||||
public GetReadingResourceRequest Create(
|
||||
Guid? bookId = null,
|
||||
string? resourceKey = null)
|
||||
{
|
||||
return new GetReadingResourceRequest(bookId ?? Guid.NewGuid(), resourceKey ?? $"resource-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingResourceRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetReadingSectionRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetReadingSectionRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading section is retrieved.</param>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <returns>The created <see cref="GetReadingSectionRequest"/>.</returns>
|
||||
public GetReadingSectionRequest Create(
|
||||
Guid? bookId = null,
|
||||
string? locationRef = null)
|
||||
{
|
||||
return new GetReadingSectionRequest(bookId ?? Guid.NewGuid(), locationRef ?? $"section-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetReadingSectionRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetLibraryBookReadersRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryBookReadersRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetLibraryBookReadersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book readers are retrieved.</param>
|
||||
/// <returns>The created <see cref="GetLibraryBookReadersRequest"/>.</returns>
|
||||
public GetLibraryBookReadersRequest Create(
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new GetLibraryBookReadersRequest(libraryId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetLibraryBookReadersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetLibraryBookReadersRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetLibraryBookReaderEnabledRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryBookReaderEnabledRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SetLibraryBookReaderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book reader is enabled or disabled.</param>
|
||||
/// <param name="pluginId">Optional. The unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the book reader should be enabled for the media library.</param>
|
||||
/// <returns>The created <see cref="SetLibraryBookReaderEnabledRequest"/>.</returns>
|
||||
public SetLibraryBookReaderEnabledRequest Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new SetLibraryBookReaderEnabledRequest(libraryId ?? Guid.NewGuid(), pluginId ?? Guid.NewGuid(), isEnabled ?? true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetLibraryBookReaderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetLibraryBookReaderEnabledRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -24,20 +24,26 @@ public class UpdateUserSettingsRequestFixture
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
|
||||
public UpdateUserSettingsRequest Create(
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
bool? shouldAggregateMetadataWhenMissing = null,
|
||||
bool? shouldRenderPdfAsImages = null,
|
||||
bool? shouldPreserveBookStyles = null)
|
||||
{
|
||||
return new UpdateUserSettingsRequest(
|
||||
isPaginationEnabled ?? _faker.Random.Bool(),
|
||||
itemsPerPage ?? _faker.Random.Int(1, 100),
|
||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool());
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
||||
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
||||
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingAvailabilityResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingAvailabilityResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingAvailabilityResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading availability is reported.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
|
||||
/// <param name="isAvailable">Optional. Whether the book can be opened for reading.</param>
|
||||
/// <param name="errorCode">Optional. The code of the error preventing the book from being read, when it cannot be read.</param>
|
||||
/// <returns>The created <see cref="ReadingAvailabilityResponse"/>.</returns>
|
||||
public ReadingAvailabilityResponse Create(
|
||||
Guid? bookId = null,
|
||||
Guid? libraryId = null,
|
||||
bool? isAvailable = null,
|
||||
string? errorCode = null)
|
||||
{
|
||||
return new ReadingAvailabilityResponse(
|
||||
bookId ?? Guid.NewGuid(),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
isAvailable ?? true,
|
||||
errorCode
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingAvailabilityResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingAvailabilityResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingManifestResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingManifestResponseFixture
|
||||
{
|
||||
private readonly ReadingTocEntryResponseFixture _readingTocEntryResponseFixture = new();
|
||||
private readonly ReadingSpineItemResponseFixture _readingSpineItemResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingManifestResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="author">Optional. The author of the book, if known.</param>
|
||||
/// <param name="coverResourceKey">Optional. The resource key of the cover image of the book, if applicable.</param>
|
||||
/// <param name="tableOfContents">Optional. The hierarchical table of contents of the book.</param>
|
||||
/// <param name="spine">Optional. The ordered spine of the reading sections of the book.</param>
|
||||
/// <param name="resourceKeys">Optional. The resource keys of the resources of the book.</param>
|
||||
/// <param name="hasTextContent">Optional. Whether the book has extractable text content.</param>
|
||||
/// <returns>The created <see cref="ReadingManifestResponse"/>.</returns>
|
||||
public ReadingManifestResponse Create(
|
||||
string? title = null,
|
||||
string? author = null,
|
||||
string? coverResourceKey = null,
|
||||
IReadOnlyList<ReadingTocEntryResponse>? tableOfContents = null,
|
||||
IReadOnlyList<ReadingSpineItemResponse>? spine = null,
|
||||
IReadOnlyList<string>? resourceKeys = null,
|
||||
bool? hasTextContent = null)
|
||||
{
|
||||
return new ReadingManifestResponse(
|
||||
title ?? $"Book {Guid.NewGuid():N}",
|
||||
author,
|
||||
coverResourceKey,
|
||||
tableOfContents ?? [.. _readingTocEntryResponseFixture.CreateMany(2)],
|
||||
spine ?? [.. _readingSpineItemResponseFixture.CreateMany(2)],
|
||||
resourceKeys ?? [.. Enumerable.Range(0, 2).Select(_ => $"resource-{Guid.NewGuid():N}")],
|
||||
hasTextContent ?? true
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingManifestResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingManifestResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingSpineItemResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSpineItemResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingSpineItemResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional. The title of the reading section, if known.</param>
|
||||
/// <returns>The created <see cref="ReadingSpineItemResponse"/>.</returns>
|
||||
public ReadingSpineItemResponse Create(
|
||||
string? locationRef = null,
|
||||
string? title = null)
|
||||
{
|
||||
return new ReadingSpineItemResponse(locationRef ?? $"section-{Guid.NewGuid():N}", title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingSpineItemResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingSpineItemResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingTocEntryResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingTocEntryResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadingTocEntryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="label">Optional. The label of the table of contents entry.</param>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section the entry points to.</param>
|
||||
/// <param name="children">Optional. The child entries of the table of contents entry.</param>
|
||||
/// <returns>The created <see cref="ReadingTocEntryResponse"/>.</returns>
|
||||
public ReadingTocEntryResponse Create(
|
||||
string? label = null,
|
||||
string? locationRef = null,
|
||||
IReadOnlyList<ReadingTocEntryResponse>? children = null)
|
||||
{
|
||||
return new ReadingTocEntryResponse(
|
||||
label ?? $"Chapter {Guid.NewGuid():N}",
|
||||
locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
children ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadingTocEntryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadingTocEntryResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryBookReaderResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryBookReaderResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryBookReaderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="name">Optional. The display name of the book reader.</param>
|
||||
/// <param name="supportedExtensions">Optional. The file extensions supported by the book reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the book reader is enabled for the media library.</param>
|
||||
/// <returns>The created <see cref="LibraryBookReaderResponse"/>.</returns>
|
||||
public LibraryBookReaderResponse Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
IReadOnlyList<string>? supportedExtensions = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new LibraryBookReaderResponse(
|
||||
pluginId ?? Guid.NewGuid(),
|
||||
name ?? $"Reader {Guid.NewGuid():N}",
|
||||
supportedExtensions ?? [".epub", ".pdf"],
|
||||
isEnabled ?? true
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryBookReaderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryBookReaderResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -26,6 +26,8 @@ public class UserSettingsResponseFixture
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
|
||||
public UserSettingsResponse Create(
|
||||
Guid? userId = null,
|
||||
@@ -33,7 +35,9 @@ public class UserSettingsResponseFixture
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
bool? shouldAggregateMetadataWhenMissing = null,
|
||||
bool? shouldRenderPdfAsImages = null,
|
||||
bool? shouldPreserveBookStyles = null)
|
||||
{
|
||||
return new UserSettingsResponse(
|
||||
userId ?? Guid.NewGuid(),
|
||||
@@ -41,7 +45,9 @@ public class UserSettingsResponseFixture
|
||||
itemsPerPage ?? _faker.Random.Int(1, 100),
|
||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool());
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
||||
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
||||
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+8
-2
@@ -25,6 +25,8 @@ public class UserSettingsFixture
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||
/// <returns>The created <see cref="UserSettings"/>.</returns>
|
||||
public UserSettings Create(
|
||||
Guid? userId = null,
|
||||
@@ -32,7 +34,9 @@ public class UserSettingsFixture
|
||||
int itemsPerPage = 48,
|
||||
bool shouldIgnoreThePrefixForAlphaPicker = false,
|
||||
bool isThemeCachingEnabled = true,
|
||||
bool shouldAggregateMetadataWhenMissing = false)
|
||||
bool shouldAggregateMetadataWhenMissing = false,
|
||||
bool shouldRenderPdfAsImages = false,
|
||||
bool shouldPreserveBookStyles = true)
|
||||
{
|
||||
Result<UserSettings> settings = UserSettings.Create(
|
||||
userId is null ? UserId.CreateUnique() : UserId.Create(userId.Value),
|
||||
@@ -40,7 +44,9 @@ public class UserSettingsFixture
|
||||
itemsPerPage,
|
||||
shouldIgnoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled,
|
||||
shouldAggregateMetadataWhenMissing);
|
||||
shouldAggregateMetadataWhenMissing,
|
||||
shouldRenderPdfAsImages,
|
||||
shouldPreserveBookStyles);
|
||||
return settings.Value;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>false</IsTestProject>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" />
|
||||
<PackageReference Include="AutoFixture.AutoNSubstitute" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" />
|
||||
<PackageReference Include="Bogus" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.Epub\Lumina.Plugins.Epub.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Lumina.Plugins.Epub.Fixtures")]
|
||||
[assembly: AssemblyProduct("Lumina.Plugins.Epub.Fixtures")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("A3C1E9B4-5D7F-4E2A-9B6C-8D1F0E3A2B41")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Lumina.Plugins.Epub.UnitTests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
@@ -0,0 +1,243 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Pdf.Fixtures.Core.Pdf;
|
||||
|
||||
/// <summary>
|
||||
/// Builds a minimal, structurally valid PDF file used as test input for the PDF parsing and rendering tests. The file is produced into a temporary directory
|
||||
/// at test runtime, because a PDF is a binary format that needs byte-accurate cross-reference offsets.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class TestPdfFileFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a minimal single-page PDF with a text layer containing "Hello PDF Page 1".
|
||||
/// </summary>
|
||||
/// <param name="pdfPath">The path where the PDF is written.</param>
|
||||
public static void CreateMinimalPdf(string pdfPath)
|
||||
{
|
||||
File.WriteAllBytes(pdfPath, BuildMinimalPdf());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a two-page PDF with a document outline (bookmarks): a top-level "Chapter One" bookmark that owns a nested
|
||||
/// "Part One" bookmark, a top-level "Chapter Two" bookmark, and a top-level "External Link" bookmark that points at a
|
||||
/// URI instead of a page, which PdfPig reports as a non-document bookmark.
|
||||
/// </summary>
|
||||
/// <param name="pdfPath">The path where the PDF is written.</param>
|
||||
public static void CreatePdfWithOutline(string pdfPath)
|
||||
{
|
||||
List<string> objects =
|
||||
[
|
||||
"<< /Type /Catalog /Pages 2 0 R /Outlines 8 0 R >>",
|
||||
"<< /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >>",
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 5 0 R /Resources << /Font << /F1 7 0 R >> >> >>",
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 6 0 R /Resources << /Font << /F1 7 0 R >> >> >>",
|
||||
"<< /Length 62 >>\nstream\nBT /F1 24 Tf 72 720 Td (Hello PDF Page 1) Tj ET\nendstream",
|
||||
"<< /Length 62 >>\nstream\nBT /F1 24 Tf 72 720 Td (Hello PDF Page 2) Tj ET\nendstream",
|
||||
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
|
||||
"<< /Type /Outlines /First 9 0 R /Last 12 0 R /Count 3 >>",
|
||||
"<< /Title (Chapter One) /Parent 8 0 R /Dest [3 0 R /Fit] /First 11 0 R /Last 11 0 R /Count 1 /Next 10 0 R >>",
|
||||
"<< /Title (Chapter Two) /Parent 8 0 R /Dest [4 0 R /Fit] /Next 12 0 R >>",
|
||||
"<< /Title (Part One) /Parent 9 0 R /Dest [3 0 R /Fit] >>",
|
||||
"<< /Title (External Link) /Parent 8 0 R /A << /S /URI /URI (https://example.com) >> >>"
|
||||
];
|
||||
|
||||
List<byte> pdfBytes = [];
|
||||
AddAscii(pdfBytes, "%PDF-1.4\n");
|
||||
List<int> objectOffsets = [];
|
||||
for (int index = 0; index < objects.Count; index++)
|
||||
{
|
||||
objectOffsets.Add(pdfBytes.Count);
|
||||
AddAscii(pdfBytes, $"{index + 1} 0 obj\n");
|
||||
AddAscii(pdfBytes, objects[index]);
|
||||
AddAscii(pdfBytes, "\nendobj\n");
|
||||
}
|
||||
|
||||
int xrefOffset = pdfBytes.Count;
|
||||
AddAscii(pdfBytes, $"xref\n0 {objects.Count + 1}\n");
|
||||
AddAscii(pdfBytes, "0000000000 65535 f \n");
|
||||
foreach (int objectOffset in objectOffsets)
|
||||
AddAscii(pdfBytes, $"{objectOffset:0000000000} 00000 n \n");
|
||||
|
||||
AddAscii(pdfBytes, $"trailer\n<< /Size {objects.Count + 1} /Root 1 0 R >>\nstartxref\n{xrefOffset}\n%%EOF\n");
|
||||
File.WriteAllBytes(pdfPath, [.. pdfBytes]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a single-page PDF whose text layer spans multiple lines, including a blank line, so the paragraph builder
|
||||
/// skips the empty line.
|
||||
/// </summary>
|
||||
/// <param name="pdfPath">The path where the PDF is written.</param>
|
||||
public static void CreatePdfWithBlankLine(string pdfPath)
|
||||
{
|
||||
// The PDF literal string embeds a real newline followed by an empty line and then the last line, so the text layer
|
||||
// of the page contains a blank line that the paragraph builder skips.
|
||||
const string TEXT = "(First line\\n\\nThird line) Tj";
|
||||
List<string> objects =
|
||||
[
|
||||
"<< /Type /Catalog /Pages 2 0 R >>",
|
||||
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>",
|
||||
"<< /Length 58 >>\nstream\nBT /F1 24 Tf 72 720 Td " + TEXT + " ET\nendstream",
|
||||
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"
|
||||
];
|
||||
|
||||
List<byte> pdfBytes = [];
|
||||
AddAscii(pdfBytes, "%PDF-1.4\n");
|
||||
List<int> objectOffsets = [];
|
||||
for (int index = 0; index < objects.Count; index++)
|
||||
{
|
||||
objectOffsets.Add(pdfBytes.Count);
|
||||
AddAscii(pdfBytes, $"{index + 1} 0 obj\n");
|
||||
AddAscii(pdfBytes, objects[index]);
|
||||
AddAscii(pdfBytes, "\nendobj\n");
|
||||
}
|
||||
|
||||
int xrefOffset = pdfBytes.Count;
|
||||
AddAscii(pdfBytes, $"xref\n0 {objects.Count + 1}\n");
|
||||
AddAscii(pdfBytes, "0000000000 65535 f \n");
|
||||
foreach (int objectOffset in objectOffsets)
|
||||
AddAscii(pdfBytes, $"{objectOffset:0000000000} 00000 n \n");
|
||||
|
||||
AddAscii(pdfBytes, $"trailer\n<< /Size {objects.Count + 1} /Root 1 0 R >>\nstartxref\n{xrefOffset}\n%%EOF\n");
|
||||
File.WriteAllBytes(pdfPath, [.. pdfBytes]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a single-page PDF whose catalog references a malformed outline dictionary, so reading its bookmarks throws.
|
||||
/// </summary>
|
||||
/// <param name="pdfPath">The path where the PDF is written.</param>
|
||||
public static void CreatePdfWithMalformedOutline(string pdfPath)
|
||||
{
|
||||
List<string> objects =
|
||||
[
|
||||
"<< /Type /Catalog /Pages 2 0 R /Outlines 8 0 R >>",
|
||||
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>",
|
||||
"<< /Length 57 >>\nstream\nBT /F1 24 Tf 72 720 Td (Hello PDF Page 1) Tj ET\nendstream",
|
||||
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
|
||||
// The outline root claims a first child that does not exist.
|
||||
"<< /Type /Outlines /First 99 0 R /Last 99 0 R /Count 1 >>"
|
||||
];
|
||||
|
||||
List<byte> pdfBytes = [];
|
||||
AddAscii(pdfBytes, "%PDF-1.4\n");
|
||||
List<int> objectOffsets = [];
|
||||
for (int index = 0; index < objects.Count; index++)
|
||||
{
|
||||
objectOffsets.Add(pdfBytes.Count);
|
||||
AddAscii(pdfBytes, $"{index + 1} 0 obj\n");
|
||||
AddAscii(pdfBytes, objects[index]);
|
||||
AddAscii(pdfBytes, "\nendobj\n");
|
||||
}
|
||||
|
||||
int xrefOffset = pdfBytes.Count;
|
||||
AddAscii(pdfBytes, $"xref\n0 {objects.Count + 1}\n");
|
||||
AddAscii(pdfBytes, "0000000000 65535 f \n");
|
||||
foreach (int objectOffset in objectOffsets)
|
||||
AddAscii(pdfBytes, $"{objectOffset:0000000000} 00000 n \n");
|
||||
|
||||
AddAscii(pdfBytes, $"trailer\n<< /Size {objects.Count + 1} /Root 1 0 R >>\nstartxref\n{xrefOffset}\n%%EOF\n");
|
||||
File.WriteAllBytes(pdfPath, [.. pdfBytes]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PDF with more pages than the parser's page cap, so the page enumeration stops at the cap.
|
||||
/// </summary>
|
||||
/// <param name="pdfPath">The path where the PDF is written.</param>
|
||||
public static void CreatePdfWithMorePagesThanAllowed(string pdfPath)
|
||||
{
|
||||
const int PAGE_COUNT = 10_001;
|
||||
List<string> pageObjects = [];
|
||||
for (int index = 0; index < PAGE_COUNT; index++)
|
||||
{
|
||||
int objectNumber = 3 + index;
|
||||
// Every page after the first shares the font, but each page needs its own empty content stream to stay valid.
|
||||
pageObjects.Add($"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] >>");
|
||||
}
|
||||
|
||||
string kids = string.Join(' ', Enumerable.Range(0, PAGE_COUNT).Select(index => $"{3 + index} 0 R"));
|
||||
|
||||
List<string> objects =
|
||||
[
|
||||
"<< /Type /Catalog /Pages 2 0 R >>",
|
||||
$"<< /Type /Pages /Kids [{kids}] /Count {PAGE_COUNT} >>",
|
||||
.. pageObjects
|
||||
];
|
||||
|
||||
List<byte> pdfBytes = [];
|
||||
AddAscii(pdfBytes, "%PDF-1.4\n");
|
||||
List<int> objectOffsets = [];
|
||||
for (int index = 0; index < objects.Count; index++)
|
||||
{
|
||||
objectOffsets.Add(pdfBytes.Count);
|
||||
AddAscii(pdfBytes, $"{index + 1} 0 obj\n");
|
||||
AddAscii(pdfBytes, objects[index]);
|
||||
AddAscii(pdfBytes, "\nendobj\n");
|
||||
}
|
||||
|
||||
int xrefOffset = pdfBytes.Count;
|
||||
AddAscii(pdfBytes, $"xref\n0 {objects.Count + 1}\n");
|
||||
AddAscii(pdfBytes, "0000000000 65535 f \n");
|
||||
foreach (int objectOffset in objectOffsets)
|
||||
AddAscii(pdfBytes, $"{objectOffset:0000000000} 00000 n \n");
|
||||
|
||||
AddAscii(pdfBytes, $"trailer\n<< /Size {objects.Count + 1} /Root 1 0 R >>\nstartxref\n{xrefOffset}\n%%EOF\n");
|
||||
File.WriteAllBytes(pdfPath, [.. pdfBytes]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the bytes of a minimal single-page PDF with an accurate cross-reference table.
|
||||
/// </summary>
|
||||
/// <returns>The bytes of the PDF.</returns>
|
||||
private static byte[] BuildMinimalPdf()
|
||||
{
|
||||
const string TEXT = "(Hello PDF Page 1)";
|
||||
List<string> objects =
|
||||
[
|
||||
"<< /Type /Catalog /Pages 2 0 R >>",
|
||||
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>",
|
||||
"<< /Length 57 >>\nstream\nBT /F1 24 Tf 72 720 Td " + TEXT + " Tj ET\nendstream",
|
||||
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"
|
||||
];
|
||||
|
||||
List<byte> pdfBytes = [];
|
||||
AddAscii(pdfBytes, "%PDF-1.4\n");
|
||||
List<int> objectOffsets = [];
|
||||
for (int index = 0; index < objects.Count; index++)
|
||||
{
|
||||
objectOffsets.Add(pdfBytes.Count);
|
||||
AddAscii(pdfBytes, $"{index + 1} 0 obj\n");
|
||||
AddAscii(pdfBytes, objects[index]);
|
||||
AddAscii(pdfBytes, "\nendobj\n");
|
||||
}
|
||||
|
||||
int xrefOffset = pdfBytes.Count;
|
||||
AddAscii(pdfBytes, $"xref\n0 {objects.Count + 1}\n");
|
||||
AddAscii(pdfBytes, "0000000000 65535 f \n");
|
||||
foreach (int objectOffset in objectOffsets)
|
||||
AddAscii(pdfBytes, $"{objectOffset:0000000000} 00000 n \n");
|
||||
|
||||
AddAscii(pdfBytes, $"trailer\n<< /Size {objects.Count + 1} /Root 1 0 R >>\nstartxref\n{xrefOffset}\n%%EOF\n");
|
||||
return [.. pdfBytes];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends ASCII text to the byte list.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The byte list to append to.</param>
|
||||
/// <param name="text">The ASCII text to append.</param>
|
||||
private static void AddAscii(List<byte> bytes, string text)
|
||||
{
|
||||
foreach (byte character in Encoding.ASCII.GetBytes(text))
|
||||
bytes.Add(character);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>false</IsTestProject>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" />
|
||||
<PackageReference Include="AutoFixture.AutoNSubstitute" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" />
|
||||
<PackageReference Include="Bogus" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.Pdf\Lumina.Plugins.Pdf.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Lumina.Plugins.Pdf.Fixtures")]
|
||||
[assembly: AssemblyProduct("Lumina.Plugins.Pdf.Fixtures")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("7E2A4C8D-9B1F-4E6A-8D3C-2F5A0B9E7C41")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Lumina.Plugins.Pdf.UnitTests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="LibraryBookReaderDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryBookReaderDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryBookReaderDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="name">Optional display name of the book reader.</param>
|
||||
/// <param name="supportedExtensions">Optional file extensions supported by the book reader.</param>
|
||||
/// <param name="isEnabled">Optional value indicating whether the book reader is enabled for the media library.</param>
|
||||
/// <returns>A configured <see cref="LibraryBookReaderDto"/> instance.</returns>
|
||||
public LibraryBookReaderDto Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
List<string>? supportedExtensions = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new LibraryBookReaderDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Name = name ?? $"Reader {Guid.NewGuid():N}",
|
||||
SupportedExtensions = supportedExtensions ?? [".epub", ".pdf"],
|
||||
IsEnabled = isEnabled ?? true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryBookReaderDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryBookReaderDto"/> instances.</returns>
|
||||
public List<LibraryBookReaderDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ReadingAvailabilityDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingAvailabilityDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingAvailabilityDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional identifier of the book whose reading availability is reported.</param>
|
||||
/// <param name="libraryId">Optional identifier of the media library the book belongs to.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the book can be opened for reading.</param>
|
||||
/// <param name="errorCode">Optional code of the error preventing the book from being read, when it cannot be read.</param>
|
||||
/// <returns>A configured <see cref="ReadingAvailabilityDto"/> instance.</returns>
|
||||
public ReadingAvailabilityDto Create(
|
||||
Guid? bookId = null,
|
||||
Guid? libraryId = null,
|
||||
bool? isAvailable = null,
|
||||
string? errorCode = null)
|
||||
{
|
||||
return new ReadingAvailabilityDto
|
||||
{
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
IsAvailable = isAvailable ?? true,
|
||||
ErrorCode = errorCode
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingAvailabilityDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingAvailabilityDto"/> instances.</returns>
|
||||
public List<ReadingAvailabilityDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ReadingManifestDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingManifestDtoFixture
|
||||
{
|
||||
private readonly ReadingTocEntryDtoFixture _readingTocEntryDtoFixture = new();
|
||||
private readonly ReadingSpineItemDtoFixture _readingSpineItemDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingManifestDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional title of the book.</param>
|
||||
/// <param name="author">Optional author of the book.</param>
|
||||
/// <param name="coverResourceKey">Optional resource key of the cover image of the book.</param>
|
||||
/// <param name="tableOfContents">Optional hierarchical table of contents of the book.</param>
|
||||
/// <param name="spine">Optional ordered spine of the reading sections of the book.</param>
|
||||
/// <param name="resourceKeys">Optional resource keys of the resources of the book.</param>
|
||||
/// <param name="hasTextContent">Optional value indicating whether the book has extractable text content.</param>
|
||||
/// <returns>A configured <see cref="ReadingManifestDto"/> instance.</returns>
|
||||
public ReadingManifestDto Create(
|
||||
string? title = null,
|
||||
string? author = null,
|
||||
string? coverResourceKey = null,
|
||||
List<ReadingTocEntryDto>? tableOfContents = null,
|
||||
List<ReadingSpineItemDto>? spine = null,
|
||||
List<string>? resourceKeys = null,
|
||||
bool? hasTextContent = null)
|
||||
{
|
||||
return new ReadingManifestDto
|
||||
{
|
||||
Title = title ?? $"Book {Guid.NewGuid():N}",
|
||||
Author = author,
|
||||
CoverResourceKey = coverResourceKey,
|
||||
TableOfContents = tableOfContents ?? [.. _readingTocEntryDtoFixture.CreateMany(2)],
|
||||
Spine = spine ?? [.. _readingSpineItemDtoFixture.CreateMany(2)],
|
||||
ResourceKeys = resourceKeys ?? [.. Enumerable.Range(0, 2).Select(_ => $"resource-{Guid.NewGuid():N}")],
|
||||
HasTextContent = hasTextContent ?? true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingManifestDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingManifestDto"/> instances.</returns>
|
||||
public List<ReadingManifestDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ReadingSectionDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSectionDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingSectionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional title of the reading section.</param>
|
||||
/// <param name="contentHtml">Optional sanitized HTML content of the reading section.</param>
|
||||
/// <returns>A configured <see cref="ReadingSectionDto"/> instance.</returns>
|
||||
public ReadingSectionDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null,
|
||||
string? contentHtml = null)
|
||||
{
|
||||
return new ReadingSectionDto
|
||||
{
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Title = title,
|
||||
ContentHtml = contentHtml ?? "<section><p>Content</p></section>"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingSectionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingSectionDto"/> instances.</returns>
|
||||
public List<ReadingSectionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ReadingSpineItemDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSpineItemDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingSpineItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional title of the reading section.</param>
|
||||
/// <returns>A configured <see cref="ReadingSpineItemDto"/> instance.</returns>
|
||||
public ReadingSpineItemDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null)
|
||||
{
|
||||
return new ReadingSpineItemDto
|
||||
{
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Title = title
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingSpineItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingSpineItemDto"/> instances.</returns>
|
||||
public List<ReadingSpineItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ReadingTocEntryDto"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingTocEntryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingTocEntryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="label">Optional label of the table of contents entry.</param>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section the entry points to.</param>
|
||||
/// <param name="children">Optional child entries of the table of contents entry.</param>
|
||||
/// <returns>A configured <see cref="ReadingTocEntryDto"/> instance.</returns>
|
||||
public ReadingTocEntryDto Create(
|
||||
string? label = null,
|
||||
string? locationRef = null,
|
||||
List<ReadingTocEntryDto>? children = null)
|
||||
{
|
||||
return new ReadingTocEntryDto
|
||||
{
|
||||
Label = label ?? $"Chapter {Guid.NewGuid():N}",
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Children = children ?? []
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingTocEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingTocEntryDto"/> instances.</returns>
|
||||
public List<ReadingTocEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -26,6 +26,8 @@ public class UserSettingsDtoFixture
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||
/// <returns>A configured <see cref="UserSettingsDto"/> instance.</returns>
|
||||
public UserSettingsDto Create(
|
||||
Guid? userId = null,
|
||||
@@ -33,7 +35,9 @@ public class UserSettingsDtoFixture
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
bool? shouldAggregateMetadataWhenMissing = null,
|
||||
bool? shouldRenderPdfAsImages = null,
|
||||
bool? shouldPreserveBookStyles = null)
|
||||
{
|
||||
return new UserSettingsDto
|
||||
{
|
||||
@@ -42,7 +46,9 @@ public class UserSettingsDtoFixture
|
||||
ItemsPerPage = itemsPerPage ?? _faker.Random.Int(1, 200),
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool()
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
||||
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? _faker.Random.Bool()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBookReadersRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookReadersRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetBookReadersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book readers are retrieved.</param>
|
||||
/// <returns>The created <see cref="GetBookReadersRequest"/>.</returns>
|
||||
public GetBookReadersRequest Create(
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new GetBookReadersRequest(libraryId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetBookReadersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetBookReadersRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBookReadingAvailabilityRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookReadingAvailabilityRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetBookReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading availability is checked.</param>
|
||||
/// <returns>The created <see cref="GetBookReadingAvailabilityRequest"/>.</returns>
|
||||
public GetBookReadingAvailabilityRequest Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetBookReadingAvailabilityRequest(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetBookReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetBookReadingAvailabilityRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBookReadingManifestRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookReadingManifestRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetBookReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading manifest is retrieved.</param>
|
||||
/// <returns>The created <see cref="GetBookReadingManifestRequest"/>.</returns>
|
||||
public GetBookReadingManifestRequest Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new GetBookReadingManifestRequest(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetBookReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetBookReadingManifestRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBookReadingResourceRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookReadingResourceRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetBookReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose resource is retrieved.</param>
|
||||
/// <param name="resourceKey">Optional. The opaque resource key of the resource.</param>
|
||||
/// <returns>The created <see cref="GetBookReadingResourceRequest"/>.</returns>
|
||||
public GetBookReadingResourceRequest Create(
|
||||
Guid? bookId = null,
|
||||
string? resourceKey = null)
|
||||
{
|
||||
return new GetBookReadingResourceRequest(bookId ?? Guid.NewGuid(), resourceKey ?? $"resource-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetBookReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetBookReadingResourceRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetBookReadingSectionRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookReadingSectionRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetBookReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book whose reading section is retrieved.</param>
|
||||
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
|
||||
/// <returns>The created <see cref="GetBookReadingSectionRequest"/>.</returns>
|
||||
public GetBookReadingSectionRequest Create(
|
||||
Guid? bookId = null,
|
||||
string? locationRef = null)
|
||||
{
|
||||
return new GetBookReadingSectionRequest(bookId ?? Guid.NewGuid(), locationRef ?? $"section-{Guid.NewGuid():N}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetBookReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetBookReadingSectionRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadBookViewRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadBookViewRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReadBookViewRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional. The Id of the book to read.</param>
|
||||
/// <returns>The created <see cref="ReadBookViewRequest"/>.</returns>
|
||||
public ReadBookViewRequest Create(
|
||||
Guid? bookId = null)
|
||||
{
|
||||
return new ReadBookViewRequest(bookId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReadBookViewRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReadBookViewRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetBookReaderEnabledRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetBookReaderEnabledRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SetBookReaderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose book reader is enabled or disabled.</param>
|
||||
/// <param name="pluginId">Optional. The unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the book reader should be enabled for the media library.</param>
|
||||
/// <returns>The created <see cref="SetBookReaderEnabledRequest"/>.</returns>
|
||||
public SetBookReaderEnabledRequest Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new SetBookReaderEnabledRequest
|
||||
{
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
IsEnabled = isEnabled ?? true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetBookReaderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetBookReaderEnabledRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user