diff --git a/src/Lumina.sln b/src/Lumina.sln index 6b83d501..fe32066e 100644 --- a/src/Lumina.sln +++ b/src/Lumina.sln @@ -257,6 +257,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "theming", "theming", "{2872 ..\docs\technical\theming\Theming.md = ..\docs\technical\theming\Theming.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Epub", "..\plugins\Lumina.Plugins.Epub\Lumina.Plugins.Epub.csproj", "{EBE84E94-60C3-4D04-8802-F81ACA74DE21}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Pdf", "..\plugins\Lumina.Plugins.Pdf\Lumina.Plugins.Pdf.csproj", "{46E92994-64C6-44CE-8039-D930775C532A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Epub.UnitTests", "..\tests\UnitTests\Lumina.Plugins.Epub.UnitTests\Lumina.Plugins.Epub.UnitTests.csproj", "{A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Pdf.UnitTests", "..\tests\UnitTests\Lumina.Plugins.Pdf.UnitTests\Lumina.Plugins.Pdf.UnitTests.csproj", "{B97069B6-71A8-4D42-87E7-178396E4749F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Epub.Fixtures", "..\tests\Common\Lumina.Plugins.Epub.Fixtures\Lumina.Plugins.Epub.Fixtures.csproj", "{334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lumina.Plugins.Pdf.Fixtures", "..\tests\Common\Lumina.Plugins.Pdf.Fixtures\Lumina.Plugins.Pdf.Fixtures.csproj", "{15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -719,6 +731,78 @@ Global {65AA7896-2DE2-4F07-A1B2-C1E1774521C2}.Release|x64.Build.0 = Release|Any CPU {65AA7896-2DE2-4F07-A1B2-C1E1774521C2}.Release|x86.ActiveCfg = Release|Any CPU {65AA7896-2DE2-4F07-A1B2-C1E1774521C2}.Release|x86.Build.0 = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|x64.ActiveCfg = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|x64.Build.0 = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|x86.ActiveCfg = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Debug|x86.Build.0 = Debug|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|Any CPU.Build.0 = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|x64.ActiveCfg = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|x64.Build.0 = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|x86.ActiveCfg = Release|Any CPU + {EBE84E94-60C3-4D04-8802-F81ACA74DE21}.Release|x86.Build.0 = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|x64.ActiveCfg = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|x64.Build.0 = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|x86.ActiveCfg = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Debug|x86.Build.0 = Debug|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|Any CPU.Build.0 = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|x64.ActiveCfg = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|x64.Build.0 = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|x86.ActiveCfg = Release|Any CPU + {46E92994-64C6-44CE-8039-D930775C532A}.Release|x86.Build.0 = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|x64.ActiveCfg = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|x64.Build.0 = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|x86.ActiveCfg = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Debug|x86.Build.0 = Debug|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|Any CPU.Build.0 = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|x64.ActiveCfg = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|x64.Build.0 = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|x86.ActiveCfg = Release|Any CPU + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662}.Release|x86.Build.0 = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|x64.ActiveCfg = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|x64.Build.0 = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|x86.ActiveCfg = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Debug|x86.Build.0 = Debug|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|Any CPU.Build.0 = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|x64.ActiveCfg = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|x64.Build.0 = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|x86.ActiveCfg = Release|Any CPU + {B97069B6-71A8-4D42-87E7-178396E4749F}.Release|x86.Build.0 = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|x64.ActiveCfg = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|x64.Build.0 = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|x86.ActiveCfg = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Debug|x86.Build.0 = Debug|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|Any CPU.Build.0 = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|x64.ActiveCfg = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|x64.Build.0 = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|x86.ActiveCfg = Release|Any CPU + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F}.Release|x86.Build.0 = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|x64.Build.0 = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|x86.ActiveCfg = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Debug|x86.Build.0 = Debug|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|Any CPU.Build.0 = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|x64.ActiveCfg = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|x64.Build.0 = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|x86.ActiveCfg = Release|Any CPU + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -787,6 +871,12 @@ Global {B6F9E5D2-3C4D-5E6F-9A7B-8C9D0E1F2A31} = {7E8A2D6B-3F4C-4E5F-9A6B-1C2D3E4F5A6B} {65AA7896-2DE2-4F07-A1B2-C1E1774521C2} = {7E8A2D6B-3F4C-4E5F-9A6B-1C2D3E4F5A6B} {2872042D-061F-4C76-8017-0A518A7E28A7} = {0C0E5A56-AD29-4D0B-AB87-E865F8B933E2} + {EBE84E94-60C3-4D04-8802-F81ACA74DE21} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {46E92994-64C6-44CE-8039-D930775C532A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {A4BD890A-5959-4A9E-9FCA-CDCCE27B8662} = {53B1231B-37F5-44BA-80D5-DBA979775F5C} + {B97069B6-71A8-4D42-87E7-178396E4749F} = {53B1231B-37F5-44BA-80D5-DBA979775F5C} + {334D9DE2-AE31-4C2C-9B8B-F3E1A335C11F} = {7E8A2D6B-3F4C-4E5F-9A6B-1C2D3E4F5A6B} + {15BB9243-9CF1-4B7C-B150-678F7F6BA3C2} = {7E8A2D6B-3F4C-4E5F-9A6B-1C2D3E4F5A6B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4A55A28E-C657-4A0B-95EA-2931AE66004E} diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Plugins/LibraryBookReaderConfigurationEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Plugins/LibraryBookReaderConfigurationEntityFixture.cs new file mode 100644 index 00000000..1549f920 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Plugins/LibraryBookReaderConfigurationEntityFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class LibraryBookReaderConfigurationEntityFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the configuration. + /// Optional. The Id of the media library the configuration belongs to. + /// Optional. The Id of the plugin providing the book reader. + /// Optional. Whether the book reader is enabled for the media library. + /// The created . + public LibraryBookReaderConfigurationEntity Create( + Guid? id = null, + Guid? libraryId = null, + Guid? pluginId = null, + bool? isEnabled = null) + { + return new Faker() + .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(); + } + + /// + /// Creates a list of instances with randomized test data. + /// + /// Number of instances to create. + /// List of configured instances. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs index d5074175..721527a2 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs @@ -25,6 +25,8 @@ public class UserSettingsEntityFixture /// Optional. Whether the "The" prefix is ignored by the alpha picker, or not. /// Optional. Whether the theme data served to this user is cached, or not. /// Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. + /// Optional. Whether PDF books are rendered as page images for the user, or not. + /// Optional. Whether the styles of the book content are preserved when it is rendered for the user, or not. /// The created user settings entity. 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() .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(); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs similarity index 99% rename from tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs rename to tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs index 1fddb040..a327cea3 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs @@ -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; /// /// Fixture class for the class. diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs similarity index 96% rename from tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs rename to tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs index 9cfd04eb..1c105e6c 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs @@ -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; /// /// Fixture class for the class. diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs similarity index 97% rename from tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs rename to tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs index a93511b1..5949d253 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs @@ -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; /// /// Fixture class for the class. diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingAvailability/GetReadingAvailabilityQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingAvailability/GetReadingAvailabilityQueryFixture.cs new file mode 100644 index 00000000..6b06e6c5 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingAvailability/GetReadingAvailabilityQueryFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class GetReadingAvailabilityQueryFixture +{ + /// + /// Creates a random valid query to check the reading availability of a book. + /// + /// Optional. The Id of the book whose reading availability is checked. + /// The created . + public GetReadingAvailabilityQuery Create( + Guid? bookId = null) + { + return new GetReadingAvailabilityQuery(bookId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingManifest/GetReadingManifestQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingManifest/GetReadingManifestQueryFixture.cs new file mode 100644 index 00000000..ba58a8d5 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingManifest/GetReadingManifestQueryFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class GetReadingManifestQueryFixture +{ + /// + /// Creates a random valid query to get the reading manifest of a book. + /// + /// Optional. The Id of the book whose reading manifest is retrieved. + /// The created . + public GetReadingManifestQuery Create( + Guid? bookId = null) + { + return new GetReadingManifestQuery(bookId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingResource/GetReadingResourceQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingResource/GetReadingResourceQueryFixture.cs new file mode 100644 index 00000000..1c486bc9 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingResource/GetReadingResourceQueryFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class GetReadingResourceQueryFixture +{ + /// + /// Creates a random valid query to get a resource of a book. + /// + /// Optional. The Id of the book whose resource is retrieved. + /// Optional. The opaque resource key of the resource. + /// The created . + public GetReadingResourceQuery Create( + Guid? bookId = null, + string? resourceKey = null) + { + return new GetReadingResourceQuery(bookId ?? Guid.NewGuid(), resourceKey ?? $"resource-{Guid.NewGuid():N}"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingSection/GetReadingSectionQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingSection/GetReadingSectionQueryFixture.cs new file mode 100644 index 00000000..8d69929a --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/Queries/GetReadingSection/GetReadingSectionQueryFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class GetReadingSectionQueryFixture +{ + /// + /// Creates a random valid query to get the content of a reading section of a book. + /// + /// Optional. The Id of the book whose reading section is retrieved. + /// Optional. The opaque location reference of the reading section. + /// The created . + public GetReadingSectionQuery Create( + Guid? bookId = null, + string? locationRef = null) + { + return new GetReadingSectionQuery(bookId ?? Guid.NewGuid(), locationRef ?? $"section-{Guid.NewGuid():N}"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Commands/SetLibraryBookReaderEnabled/SetLibraryBookReaderEnabledCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Commands/SetLibraryBookReaderEnabled/SetLibraryBookReaderEnabledCommandFixture.cs new file mode 100644 index 00000000..ef39d0f1 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Commands/SetLibraryBookReaderEnabled/SetLibraryBookReaderEnabledCommandFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class SetLibraryBookReaderEnabledCommandFixture +{ + /// + /// Creates a random valid command to enable or disable a book reader for a media library. + /// + /// Optional. The Id of the media library whose book reader is enabled or disabled. + /// Optional. The unique identifier of the plugin providing the book reader. + /// Optional. Whether the book reader should be enabled for the media library. + /// The created . + public SetLibraryBookReaderEnabledCommand Create( + Guid? libraryId = null, + Guid? pluginId = null, + bool? isEnabled = null) + { + return new SetLibraryBookReaderEnabledCommand(libraryId ?? Guid.NewGuid(), pluginId ?? Guid.NewGuid(), isEnabled ?? true); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetLibraryBookReaders/GetLibraryBookReadersQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetLibraryBookReaders/GetLibraryBookReadersQueryFixture.cs new file mode 100644 index 00000000..0bf5f6e4 --- /dev/null +++ b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetLibraryBookReaders/GetLibraryBookReadersQueryFixture.cs @@ -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; + +/// +/// Fixture class for the class. +/// +[ExcludeFromCodeCoverage] +public class GetLibraryBookReadersQueryFixture +{ + /// + /// Creates a random valid query to get the book readers configured for a media library. + /// + /// Optional. The Id of the media library whose book readers are retrieved. + /// The created . + public GetLibraryBookReadersQuery Create( + Guid? libraryId = null) + { + return new GetLibraryBookReadersQuery(libraryId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs index 26814704..83ebbd9a 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs @@ -21,21 +21,28 @@ public class UpdateUserSettingsCommandFixture /// Optional. The number of library items displayed per page when pagination is enabled. /// Optional. Whether the "The" prefix is ignored by the alpha picker, or not. /// Optional. Whether the theme data served to this user is cached, or not. + /// Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Optional. Whether PDF books are rendered as page images for the user. + /// Optional. Whether the styles of the book content are preserved when it is rendered for the user. /// The created command. 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() - .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(); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingDocumentDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingDocumentDtoFixture.cs new file mode 100644 index 00000000..2aff92af --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingDocumentDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingDocumentDtoFixture +{ + private readonly ReadingTocEntryDtoFixture _readingTocEntryDtoFixture = new(); + private readonly ReadingSpineItemDtoFixture _readingSpineItemDtoFixture = new(); + private readonly ReadingResourceInfoDtoFixture _readingResourceInfoDtoFixture = new(); + + /// + /// Creates a random valid . + /// + /// Optional. The title of the book. + /// Optional. The author of the book, if known. + /// Optional. The resource key of the cover image of the book, if applicable. + /// Optional. The hierarchical table of contents of the book. + /// Optional. The ordered spine of the reading sections of the book. + /// Optional. The resources of the book, keyed by their resource key. + /// Optional. Whether the book has extractable text content. + /// The created . + public ReadingDocumentDto Create( + string? title = null, + string? author = null, + string? coverResourceKey = null, + IReadOnlyList? tableOfContents = null, + IReadOnlyList? spine = null, + IReadOnlyDictionary? 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 + { + [$"resource-{Guid.NewGuid():N}"] = _readingResourceInfoDtoFixture.Create() + }, + hasTextContent ?? true + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceDataDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceDataDtoFixture.cs new file mode 100644 index 00000000..b7bafe43 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceDataDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingResourceDataDtoFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The binary data of the resource. + /// Optional. The MIME type of the resource. + /// The created . + public ReadingResourceDataDto Create( + byte[]? data = null, + string? mimeType = null) + { + return new ReadingResourceDataDto(data ?? Guid.NewGuid().ToByteArray(), mimeType ?? "image/png"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceInfoDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceInfoDtoFixture.cs new file mode 100644 index 00000000..58bca2e8 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingResourceInfoDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingResourceInfoDtoFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The path of the resource file, relative to the extraction directory of the book. + /// Optional. The MIME type of the resource. + /// The created . + public ReadingResourceInfoDto Create( + string? relativeFilePath = null, + string? mimeType = null) + { + return new ReadingResourceInfoDto(relativeFilePath ?? $"resources/resource-{Guid.NewGuid():N}.png", mimeType ?? "image/png"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSectionDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSectionDtoFixture.cs new file mode 100644 index 00000000..33cf8098 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSectionDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingSectionDtoFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The opaque location reference of the reading section. + /// Optional. The title of the reading section, if known. + /// Optional. The sanitized HTML content of the reading section. + /// The created . + public ReadingSectionDto Create( + string? locationRef = null, + string? title = null, + string? contentHtml = null) + { + return new ReadingSectionDto(locationRef ?? $"section-{Guid.NewGuid():N}", title, contentHtml ?? "

Content

"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSpineItemDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSpineItemDtoFixture.cs new file mode 100644 index 00000000..45160a08 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingSpineItemDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingSpineItemDtoFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The opaque location reference of the reading section. + /// Optional. The title of the reading section, if known. + /// Optional. The path of the section content file, relative to the extraction directory of the book. + /// The created . + 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"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingTocEntryDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingTocEntryDtoFixture.cs new file mode 100644 index 00000000..483ba008 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/Reading/ReadingTocEntryDtoFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingTocEntryDtoFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The label of the table of contents entry. + /// Optional. The opaque location reference of the reading section the entry points to. + /// Optional. The child entries of the table of contents entry. + /// The created . + public ReadingTocEntryDto Create( + string? label = null, + string? locationRef = null, + IReadOnlyList? children = null) + { + return new ReadingTocEntryDto( + label ?? $"Chapter {Guid.NewGuid():N}", + locationRef ?? $"section-{Guid.NewGuid():N}", + children ?? [] + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingAvailabilityRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingAvailabilityRequestFixture.cs new file mode 100644 index 00000000..5fcc33f8 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingAvailabilityRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class GetReadingAvailabilityRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the book whose reading availability is checked. + /// The created . + public GetReadingAvailabilityRequest Create( + Guid? bookId = null) + { + return new GetReadingAvailabilityRequest(bookId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingManifestRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingManifestRequestFixture.cs new file mode 100644 index 00000000..b93b4097 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingManifestRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class GetReadingManifestRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the book whose reading manifest is retrieved. + /// The created . + public GetReadingManifestRequest Create( + Guid? bookId = null) + { + return new GetReadingManifestRequest(bookId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingResourceRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingResourceRequestFixture.cs new file mode 100644 index 00000000..d38695f1 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingResourceRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class GetReadingResourceRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the book whose resource is retrieved. + /// Optional. The opaque resource key of the resource. + /// The created . + public GetReadingResourceRequest Create( + Guid? bookId = null, + string? resourceKey = null) + { + return new GetReadingResourceRequest(bookId ?? Guid.NewGuid(), resourceKey ?? $"resource-{Guid.NewGuid():N}"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingSectionRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingSectionRequestFixture.cs new file mode 100644 index 00000000..a60b9dc0 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/GetReadingSectionRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class GetReadingSectionRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the book whose reading section is retrieved. + /// Optional. The opaque location reference of the reading section. + /// The created . + public GetReadingSectionRequest Create( + Guid? bookId = null, + string? locationRef = null) + { + return new GetReadingSectionRequest(bookId ?? Guid.NewGuid(), locationRef ?? $"section-{Guid.NewGuid():N}"); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/GetLibraryBookReadersRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/GetLibraryBookReadersRequestFixture.cs new file mode 100644 index 00000000..13204203 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/GetLibraryBookReadersRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class GetLibraryBookReadersRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the media library whose book readers are retrieved. + /// The created . + public GetLibraryBookReadersRequest Create( + Guid? libraryId = null) + { + return new GetLibraryBookReadersRequest(libraryId ?? Guid.NewGuid()); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/SetLibraryBookReaderEnabledRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/SetLibraryBookReaderEnabledRequestFixture.cs new file mode 100644 index 00000000..68cdb841 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Plugins/SetLibraryBookReaderEnabledRequestFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class SetLibraryBookReaderEnabledRequestFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the media library whose book reader is enabled or disabled. + /// Optional. The unique identifier of the plugin providing the book reader. + /// Optional. Whether the book reader should be enabled for the media library. + /// The created . + public SetLibraryBookReaderEnabledRequest Create( + Guid? libraryId = null, + Guid? pluginId = null, + bool? isEnabled = null) + { + return new SetLibraryBookReaderEnabledRequest(libraryId ?? Guid.NewGuid(), pluginId ?? Guid.NewGuid(), isEnabled ?? true); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs index f2f99c6f..37f2fc05 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs @@ -24,20 +24,26 @@ public class UpdateUserSettingsRequestFixture /// Whether the "The" prefix is ignored by the alpha picker. /// Whether the theme data served to this user is cached. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Whether PDF books are rendered as page images for the user. + /// Whether the styles of the book content are preserved when it is rendered for the user. /// The created . 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()); } /// diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingAvailabilityResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingAvailabilityResponseFixture.cs new file mode 100644 index 00000000..4bff3e33 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingAvailabilityResponseFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingAvailabilityResponseFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The Id of the book whose reading availability is reported. + /// Optional. The Id of the media library the book belongs to. + /// Optional. Whether the book can be opened for reading. + /// Optional. The code of the error preventing the book from being read, when it cannot be read. + /// The created . + 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 + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingManifestResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingManifestResponseFixture.cs new file mode 100644 index 00000000..898b1c14 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingManifestResponseFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingManifestResponseFixture +{ + private readonly ReadingTocEntryResponseFixture _readingTocEntryResponseFixture = new(); + private readonly ReadingSpineItemResponseFixture _readingSpineItemResponseFixture = new(); + + /// + /// Creates a random valid . + /// + /// Optional. The title of the book. + /// Optional. The author of the book, if known. + /// Optional. The resource key of the cover image of the book, if applicable. + /// Optional. The hierarchical table of contents of the book. + /// Optional. The ordered spine of the reading sections of the book. + /// Optional. The resource keys of the resources of the book. + /// Optional. Whether the book has extractable text content. + /// The created . + public ReadingManifestResponse Create( + string? title = null, + string? author = null, + string? coverResourceKey = null, + IReadOnlyList? tableOfContents = null, + IReadOnlyList? spine = null, + IReadOnlyList? 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 + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingSpineItemResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingSpineItemResponseFixture.cs new file mode 100644 index 00000000..822fbe95 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingSpineItemResponseFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingSpineItemResponseFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The opaque location reference of the reading section. + /// Optional. The title of the reading section, if known. + /// The created . + public ReadingSpineItemResponse Create( + string? locationRef = null, + string? title = null) + { + return new ReadingSpineItemResponse(locationRef ?? $"section-{Guid.NewGuid():N}", title); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingTocEntryResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingTocEntryResponseFixture.cs new file mode 100644 index 00000000..c59b9308 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Reading/ReadingTocEntryResponseFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class ReadingTocEntryResponseFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The label of the table of contents entry. + /// Optional. The opaque location reference of the reading section the entry points to. + /// Optional. The child entries of the table of contents entry. + /// The created . + public ReadingTocEntryResponse Create( + string? label = null, + string? locationRef = null, + IReadOnlyList? children = null) + { + return new ReadingTocEntryResponse( + label ?? $"Chapter {Guid.NewGuid():N}", + locationRef ?? $"section-{Guid.NewGuid():N}", + children ?? [] + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Plugins/LibraryBookReaderResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Plugins/LibraryBookReaderResponseFixture.cs new file mode 100644 index 00000000..62200277 --- /dev/null +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Plugins/LibraryBookReaderResponseFixture.cs @@ -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; + +/// +/// Fixture class for the record. +/// +[ExcludeFromCodeCoverage] +public class LibraryBookReaderResponseFixture +{ + /// + /// Creates a random valid . + /// + /// Optional. The unique identifier of the plugin providing the book reader. + /// Optional. The display name of the book reader. + /// Optional. The file extensions supported by the book reader. + /// Optional. Whether the book reader is enabled for the media library. + /// The created . + public LibraryBookReaderResponse Create( + Guid? pluginId = null, + string? name = null, + IReadOnlyList? supportedExtensions = null, + bool? isEnabled = null) + { + return new LibraryBookReaderResponse( + pluginId ?? Guid.NewGuid(), + name ?? $"Reader {Guid.NewGuid():N}", + supportedExtensions ?? [".epub", ".pdf"], + isEnabled ?? true + ); + } + + /// + /// Creates a list of . + /// + /// The number of elements to create. + /// The created list. + public List CreateMany(int count = 3) + { + return [.. Enumerable.Range(0, count).Select(_ => Create())]; + } +} diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs index 7ebc342b..cd4d3fbd 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs @@ -26,6 +26,8 @@ public class UserSettingsResponseFixture /// Optional. Whether the "The" prefix is ignored by the alpha picker. /// Optional. Whether the theme data served to this user is cached. /// Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Optional. Whether PDF books are rendered as page images for the user. + /// Optional. Whether the styles of the book content are preserved when it is rendered for the user. /// The created . 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()); } /// diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs index 6f15968e..f41719d0 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs @@ -25,6 +25,8 @@ public class UserSettingsFixture /// Whether the "The" prefix of library item titles is ignored by the alpha picker. /// Whether the theme data served to this user is cached. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Whether PDF books are rendered as page images for the user. + /// Whether the styles of the book content are preserved when it is rendered for the user. /// The created . 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 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; } diff --git a/tests/Common/Lumina.Plugins.Epub.Fixtures/Core/Epub/TestEpubFileFactory.cs b/tests/Common/Lumina.Plugins.Epub.Fixtures/Core/Epub/TestEpubFileFactory.cs new file mode 100644 index 00000000..870a7dc1 --- /dev/null +++ b/tests/Common/Lumina.Plugins.Epub.Fixtures/Core/Epub/TestEpubFileFactory.cs @@ -0,0 +1,1007 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.IO.Compression; +using System.Text; +#endregion + +namespace Lumina.Plugins.Epub.Fixtures.Core.Epub; + +/// +/// Builds minimal, structurally valid EPUB files used as test input for the EPUB parsing tests. +/// The files are produced into a temporary directory at test runtime, because an EPUB is a binary ZIP archive. +/// +[ExcludeFromCodeCoverage] +public static class TestEpubFileFactory +{ + private const string CONTAINER_XML = """ + + + + + + + """; + + private const string CONTENT_OPF = """ + + + + Minimal EPUB Book + Test Author + en + + + + + + + + + + + + + + """; + + private const string NAV_XHTML = """ + + + + + + + """; + + private const string CHAPTER1_XHTML = """ + + + Chapter One + +

Chapter One

+

First paragraph of chapter one.

+ Cover + Next + + + """; + + private const string CHAPTER2_XHTML = """ + + + Chapter Two + +

Chapter Two

+

Second paragraph of chapter two.

+ + + """; + + private const string BROKEN_SECTION_XHTML = """ +

Not well formed

+ """; + + // A valid 1x1 PNG image, used as the cover resource of the test EPUB. + private static readonly byte[] s_coverPng = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="); + + /// + /// Creates a minimal valid EPUB with two sections, a navigation document, and a cover image. + /// + /// The path where the EPUB is written. + public static void CreateMinimalEpub(string epubPath) + { + CreateEpub(epubPath, CONTENT_OPF, CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB whose package document declares no spine, so it has no reading sections. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithoutSpine(string epubPath) + { + string opf = """ + + + + Empty Spine + + + + + + + """; + CreateEpub(epubPath, opf, CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB with no container document at all, so no OPF file can be found. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithoutContainer(string epubPath) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "OEBPS/content.opf", CONTENT_OPF); + } + + /// + /// Creates an EPUB whose manifest href attempts to escape the archive. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithTraversalHref(string epubPath) + { + string opf = """ + + + + Traversal Href + + + + + + + + + + + """; + CreateEpub(epubPath, opf, CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB whose second section is not well formed XML. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithBrokenSection(string epubPath) + { + string opf = """ + + + + Broken Section + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", BROKEN_SECTION_XHTML); + } + + /// + /// Creates an EPUB with the provided package and first section content. + /// + /// The path where the EPUB is written. + /// The content of the package document. + /// The content of the first section. + private static void CreateEpub(string epubPath, string opfContent, string chapter1Content) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opfContent); + AddEntry(zipArchive, "OEBPS/nav.xhtml", NAV_XHTML); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", chapter1Content); + AddEntry(zipArchive, "OEBPS/chapter2.xhtml", CHAPTER2_XHTML); + AddEntry(zipArchive, "OEBPS/images/cover.png", s_coverPng); + } + + /// + /// Creates an EPUB 2 whose table of contents comes from an NCX document, whose cover is declared with a meta + /// element instead of the cover-image property, and whose spine declares no EPUB 3 navigation document. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithNcxToc(string epubPath) + { + string opf = """ + + + + EPUB 2 Book + NCX Author + en + + + + + + + + + + + + + + """; + string ncx = """ + + + + + NCX Chapter One + + + NCX Part One + + + + + NCX Chapter Two + + + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/toc.ncx", ncx); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + AddEntry(zipArchive, "OEBPS/chapter2.xhtml", CHAPTER2_XHTML); + AddEntry(zipArchive, "OEBPS/images/cover.png", s_coverPng); + } + + /// + /// Creates an EPUB whose manifest carries items of many media types (font, audio, video, CSS, script) so that the + /// media-type classification of the resources is exercised. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithVariedMediaTypes(string epubPath) + { + string opf = """ + + + + Varied Media + + + + + + + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + AddEntry(zipArchive, "OEBPS/fonts/book.woff2", [1, 2, 3, 4]); + AddEntry(zipArchive, "OEBPS/fonts/book.otf", [1, 2, 3, 4]); + AddEntry(zipArchive, "OEBPS/fonts/book.ttf", [1, 2, 3, 4]); + AddEntry(zipArchive, "OEBPS/audio/intro.mp3", [1, 2, 3, 4]); + AddEntry(zipArchive, "OEBPS/video/clip.mp4", [1, 2, 3, 4]); + AddEntry(zipArchive, "OEBPS/styles/book.css", "body { color: black; }"); + AddEntry(zipArchive, "OEBPS/scripts/main.js", "var x = 1;"); + } + + /// + /// Creates an EPUB whose container document is not well formed XML, so no OPF file can be found. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithMalformedContainer(string epubPath) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", ""); + } + + /// + /// Creates an EPUB whose navigation document contains a nav element with a non-toc type, so the table of contents is empty. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithNonTocNav(string epubPath) + { + string opf = """ + + + + Non Toc Nav + + + + + + + + + + """; + string nav = """ + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/nav.xhtml", nav); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB whose package declares no title and no author, so the file name is used as the title. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithoutTitle(string epubPath) + { + string opf = """ + + + + en + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB whose package document contains broken manifest items (one without an id, one without an href), + /// items without a properties attribute, and a spine referencing an unknown manifest Id, all of which the parser + /// must tolerate while keeping the valid sections readable. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithBrokenManifest(string epubPath) + { + string opf = """ + + + + Broken Manifest + + + + + + + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + AddEntry(zipArchive, "OEBPS/chapter2.xhtml", CHAPTER2_XHTML); + AddEntry(zipArchive, "OEBPS/plain.xhtml", CHAPTER2_XHTML); + } + + /// + /// Creates an EPUB whose archive declares more entries than the parser allows, so the archive validation rejects it. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithTooManyEntries(string epubPath) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + // 20,001 entries exceeds the parser's 20,000 entry cap. + for (int index = 0; index < 20_001; index++) + AddEntry(zipArchive, $"OEBPS/empty-{index}.txt", "x"); + } + + /// + /// Creates an EPUB whose entries declare a total expanded size larger than the parser allows, so the archive validation rejects it. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithTooLargeExpandedSize(string epubPath) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + // A single entry declaring more than the 256 MB expanded cap, written as repeated zeros so it stays fast. + AddEntry(zipArchive, "OEBPS/huge.txt", new byte[300 * 1024 * 1024]); + } + + /// + /// Creates an EPUB whose container document carries a rootfile element without a full-path attribute, so no OPF file can be found. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithRootfileWithoutPath(string epubPath) + { + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", """ + + + + + + + """); + } + + /// + /// Creates an EPUB whose package document declares a manifest item whose file is not present in the archive, and whose + /// spine references a section whose file is not present in the archive. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithMissingArchiveFiles(string epubPath) + { + string opf = """ + + + + Missing Files + + + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + } + + /// + /// Creates an EPUB whose manifest declares two items with the same href, so they map to the same resource key. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithDuplicateResource(string epubPath) + { + string opf = """ + + + + Duplicate Resource + + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/chapter1.xhtml", CHAPTER1_XHTML); + AddEntry(zipArchive, "OEBPS/images/cover.png", s_coverPng); + } + + /// + /// Creates an EPUB whose navigation document is not well formed XML, so its table of contents cannot be read. + /// + /// The path where the EPUB is written. + public static void CreateEpubWithMalformedNavigationDocument(string epubPath) + { + string opf = """ + + + + Malformed Nav + + + + + + + + + + """; + using FileStream fileStream = File.Create(epubPath); + using ZipArchive zipArchive = new(fileStream, ZipArchiveMode.Create); + AddEntry(zipArchive, "mimetype", "application/epub+zip"); + AddEntry(zipArchive, "META-INF/container.xml", CONTAINER_XML); + AddEntry(zipArchive, "OEBPS/content.opf", opf); + AddEntry(zipArchive, "OEBPS/nav.xhtml", "