mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14: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
+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())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user