Adds tests for the book reading feature

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

No files matched your search

@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Contains unit tests for the <see cref="ReadingAvailabilityResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingAvailabilityResponseTests
{
private readonly ReadingAvailabilityResponseFixture _readingAvailabilityResponseFixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void Create_WhenCalled_ShouldReturnValidReadingAvailabilityResponse()
{
// Act
ReadingAvailabilityResponse sut = _readingAvailabilityResponseFixture.Create();
// Assert
Assert.NotNull(sut);
Assert.NotEqual(System.Guid.Empty, sut.BookId);
Assert.NotEqual(System.Guid.Empty, sut.LibraryId);
Assert.True(sut.IsAvailable);
}
[Fact]
public void RoundTrip_WhenSerializingReadingAvailabilityResponse_ShouldPreserveValues()
{
// Arrange
ReadingAvailabilityResponse expected = _readingAvailabilityResponseFixture.Create(isAvailable: true, errorCode: null);
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
ReadingAvailabilityResponse? actual = JsonSerializer.Deserialize<ReadingAvailabilityResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equal(expected, actual);
}
[Fact]
public void RoundTrip_WhenSerializingReadingAvailabilityResponseWithErrorCode_ShouldPreserveErrorCode()
{
// Arrange
ReadingAvailabilityResponse expected = _readingAvailabilityResponseFixture.Create(isAvailable: false, errorCode: "ReaderDisabled");
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
ReadingAvailabilityResponse? actual = JsonSerializer.Deserialize<ReadingAvailabilityResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equal(expected, actual);
Assert.False(actual.IsAvailable);
Assert.Equal("ReaderDisabled", actual.ErrorCode);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Contains unit tests for the <see cref="ReadingManifestResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingManifestResponseTests
{
private readonly ReadingManifestResponseFixture _fixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void RoundTrip_WhenSerializingReadingManifestResponse_ShouldPreserveValues()
{
// Arrange
ReadingManifestResponse expected = _fixture.Create();
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
ReadingManifestResponse? actual = JsonSerializer.Deserialize<ReadingManifestResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equivalent(expected, actual);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Contains unit tests for the <see cref="ReadingSpineItemResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingSpineItemResponseTests
{
private readonly ReadingSpineItemResponseFixture _fixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void RoundTrip_WhenSerializingReadingSpineItemResponse_ShouldPreserveValues()
{
// Arrange
ReadingSpineItemResponse expected = _fixture.Create();
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
ReadingSpineItemResponse? actual = JsonSerializer.Deserialize<ReadingSpineItemResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equal(expected, actual);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Contains unit tests for the <see cref="ReadingTocEntryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingTocEntryResponseTests
{
private readonly ReadingTocEntryResponseFixture _fixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void RoundTrip_WhenSerializingReadingTocEntryResponse_ShouldPreserveValues()
{
// Arrange
ReadingTocEntryResponse expected = _fixture.Create();
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
ReadingTocEntryResponse? actual = JsonSerializer.Deserialize<ReadingTocEntryResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equivalent(expected, actual);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Fixtures.Core.Responses.Plugins;
using Lumina.Contracts.Responses.Plugins;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Responses.Plugins;
/// <summary>
/// Contains unit tests for the <see cref="LibraryBookReaderResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryBookReaderResponseTests
{
private readonly LibraryBookReaderResponseFixture _fixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void RoundTrip_WhenSerializingLibraryBookReaderResponse_ShouldPreserveValues()
{
// Arrange
LibraryBookReaderResponse expected = _fixture.Create();
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
LibraryBookReaderResponse? actual = JsonSerializer.Deserialize<LibraryBookReaderResponse>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equivalent(expected, actual);
}
}
@@ -54,11 +54,13 @@ public class UserSettingsResponseTests
itemsPerPage: 25,
shouldIgnoreThePrefixForAlphaPicker: false,
isThemeCachingEnabled: false,
shouldAggregateMetadataWhenMissing: false
shouldAggregateMetadataWhenMissing: false,
shouldRenderPdfAsImages: true,
shouldPreserveBookStyles: true
);
// Act
(Guid sutUserId, bool isPaginationEnabled, int itemsPerPage, bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing) = sut;
(Guid sutUserId, bool isPaginationEnabled, int itemsPerPage, bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing, bool shouldRenderPdfAsImages, bool shouldPreserveBookStyles) = sut;
// Assert
Assert.Equal(sut.UserId, sutUserId);
@@ -67,5 +69,7 @@ public class UserSettingsResponseTests
Assert.Equal(sut.ShouldIgnoreThePrefixForAlphaPicker, shouldIgnoreThePrefixForAlphaPicker);
Assert.Equal(sut.IsThemeCachingEnabled, isThemeCachingEnabled);
Assert.Equal(sut.ShouldAggregateMetadataWhenMissing, shouldAggregateMetadataWhenMissing);
Assert.Equal(sut.ShouldRenderPdfAsImages, shouldRenderPdfAsImages);
Assert.Equal(sut.ShouldPreserveBookStyles, shouldPreserveBookStyles);
}
}