Hardens test assertions and adds missing test coverage.

This commit is contained in:
BinaryAlley committed 2026-08-18 08:28:16 -07:00
1 parent 6b86fd5805
commit 1189bbaf36
489 files changed
+39982 -512

No files matched your search

@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryAuthorResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryAuthorResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryAuthorResponse"/>.
/// </summary>
/// <param name="key">Optional. The key of the author.</param>
/// <param name="name">Optional. The name of the author.</param>
/// <param name="personalName">Optional. The personal name of the author.</param>
/// <returns>The created author response.</returns>
public OpenLibraryAuthorResponse Create(
string? key = null,
string? name = null,
string? personalName = null)
{
return new OpenLibraryAuthorResponse
{
Key = key ?? $"/authors/OL{_faker.Random.Number(1000, 9999)}A",
Name = name ?? _faker.Name.FullName(),
PersonalName = personalName
};
}
}
@@ -0,0 +1,95 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryEditionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryEditionResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryEditionResponse"/>.
/// </summary>
/// <param name="key">Optional. The key of the edition.</param>
/// <param name="title">Optional. The title of the edition.</param>
/// <param name="subtitle">Optional. The subtitle of the edition.</param>
/// <param name="notes">Optional. The notes of the edition.</param>
/// <param name="publishDate">Optional. The publication date of the edition.</param>
/// <param name="publishers">Optional. The publishers of the edition.</param>
/// <param name="publishPlaces">Optional. The publication places of the edition.</param>
/// <param name="numberOfPages">Optional. The number of pages of the edition.</param>
/// <param name="physicalFormat">Optional. The physical format of the edition.</param>
/// <param name="editionName">Optional. The name of the edition.</param>
/// <param name="series">Optional. The series of the edition.</param>
/// <param name="volume">Optional. The volume of the edition within its series.</param>
/// <param name="isbn10">Optional. The ISBN-10 identifiers of the edition.</param>
/// <param name="isbn13">Optional. The ISBN-13 identifiers of the edition.</param>
/// <param name="lccn">Optional. The LCCN identifiers of the edition.</param>
/// <param name="oclcNumbers">Optional. The OCLC numbers of the edition.</param>
/// <param name="identifiers">Optional. The external identifiers of the edition.</param>
/// <param name="sourceRecords">Optional. The source records of the edition.</param>
/// <param name="languages">Optional. The languages of the edition.</param>
/// <param name="authors">Optional. The authors of the edition.</param>
/// <param name="works">Optional. The works the edition belongs to.</param>
/// <param name="contributions">Optional. The contributions of the edition.</param>
/// <returns>The created edition response.</returns>
public OpenLibraryEditionResponse Create(
string? key = null,
string? title = null,
string? subtitle = null,
JsonElement? notes = null,
string? publishDate = null,
List<string>? publishers = null,
List<string>? publishPlaces = null,
int? numberOfPages = null,
string? physicalFormat = null,
string? editionName = null,
List<string>? series = null,
string? volume = null,
List<string>? isbn10 = null,
List<string>? isbn13 = null,
List<string>? lccn = null,
List<string>? oclcNumbers = null,
JsonElement? identifiers = null,
List<string>? sourceRecords = null,
List<OpenLibraryKeyReferenceResponse>? languages = null,
List<OpenLibraryKeyReferenceResponse>? authors = null,
List<OpenLibraryKeyReferenceResponse>? works = null,
List<string>? contributions = null)
{
return new OpenLibraryEditionResponse
{
Key = key ?? $"/books/OL{_faker.Random.Number(1000, 9999)}M",
Title = title ?? _faker.Commerce.ProductName(),
Subtitle = subtitle,
Notes = notes ?? default,
PublishDate = publishDate,
Publishers = publishers ?? [],
PublishPlaces = publishPlaces ?? [],
NumberOfPages = numberOfPages,
PhysicalFormat = physicalFormat,
EditionName = editionName,
Series = series ?? [],
Volume = volume,
Isbn10 = isbn10 ?? [],
Isbn13 = isbn13 ?? [],
Lccn = lccn ?? [],
OclcNumbers = oclcNumbers ?? [],
Identifiers = identifiers ?? default,
SourceRecords = sourceRecords ?? [],
Languages = languages ?? [],
Authors = authors ?? [],
Works = works ?? [],
Contributions = contributions ?? []
};
}
}
@@ -0,0 +1,29 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryKeyReferenceResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryKeyReferenceResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryKeyReferenceResponse"/>.
/// </summary>
/// <param name="key">Optional. The key of the referenced resource.</param>
/// <returns>The created reference response.</returns>
public OpenLibraryKeyReferenceResponse Create(string? key = null)
{
return new OpenLibraryKeyReferenceResponse
{
Key = key ?? $"/works/OL{_faker.Random.Number(1000, 9999)}W"
};
}
}
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryRatingSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryRatingSummaryResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="OpenLibraryRatingSummaryResponse"/>.
/// </summary>
/// <param name="average">Optional. The average rating of the work.</param>
/// <param name="count">Optional. The number of ratings of the work.</param>
/// <returns>The created rating summary response.</returns>
public OpenLibraryRatingSummaryResponse Create(decimal? average = null, int? count = null)
{
return new OpenLibraryRatingSummaryResponse
{
Average = average ?? 4.5m,
Count = count ?? 100
};
}
}
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryRatingsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryRatingsResponseFixture
{
private readonly OpenLibraryRatingSummaryResponseFixture _ratingSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryRatingsResponse"/>.
/// </summary>
/// <param name="summary">Optional. The summary of the ratings of the work.</param>
/// <returns>The created ratings response.</returns>
public OpenLibraryRatingsResponse Create(OpenLibraryRatingSummaryResponse? summary = null)
{
return new OpenLibraryRatingsResponse
{
Summary = summary ?? _ratingSummaryResponseFixture.Create()
};
}
}
@@ -0,0 +1,88 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibrarySearchDocumentResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibrarySearchDocumentResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibrarySearchDocumentResponse"/>.
/// </summary>
/// <param name="key">Optional. The key of the search document.</param>
/// <param name="title">Optional. The title of the search document.</param>
/// <param name="authorNames">Optional. The author names of the search document.</param>
/// <param name="authorKeys">Optional. The author keys of the search document.</param>
/// <param name="firstPublishYear">Optional. The first publication year of the search document.</param>
/// <param name="editionKeys">Optional. The edition keys of the search document.</param>
/// <param name="isbns">Optional. The ISBNs of the search document.</param>
/// <param name="languages">Optional. The languages of the search document.</param>
/// <param name="publishers">Optional. The publishers of the search document.</param>
/// <param name="subjects">Optional. The subjects of the search document.</param>
/// <param name="publishPlaces">Optional. The publication places of the search document.</param>
/// <param name="numberOfPagesMedian">Optional. The median number of pages of the search document.</param>
/// <param name="ratingsAverage">Optional. The average rating of the search document.</param>
/// <param name="ratingsCount">Optional. The number of ratings of the search document.</param>
/// <param name="amazonIds">Optional. The Amazon identifiers of the search document.</param>
/// <param name="goodreadsIds">Optional. The Goodreads identifiers of the search document.</param>
/// <param name="googleIds">Optional. The Google identifiers of the search document.</param>
/// <param name="libraryThingIds">Optional. The LibraryThing identifiers of the search document.</param>
/// <param name="lccn">Optional. The LCCN identifiers of the search document.</param>
/// <param name="oclc">Optional. The OCLC identifiers of the search document.</param>
/// <returns>The created search document response.</returns>
public OpenLibrarySearchDocumentResponse Create(
string? key = null,
string? title = null,
List<string>? authorNames = null,
List<string>? authorKeys = null,
int? firstPublishYear = null,
List<string>? editionKeys = null,
List<string>? isbns = null,
List<string>? languages = null,
List<string>? publishers = null,
List<string>? subjects = null,
List<string>? publishPlaces = null,
int? numberOfPagesMedian = null,
decimal? ratingsAverage = null,
int? ratingsCount = null,
List<string>? amazonIds = null,
List<string>? goodreadsIds = null,
List<string>? googleIds = null,
List<string>? libraryThingIds = null,
List<string>? lccn = null,
List<string>? oclc = null)
{
return new OpenLibrarySearchDocumentResponse
{
Key = key ?? $"/works/OL{_faker.Random.Number(1000, 9999)}W",
Title = title ?? _faker.Commerce.ProductName(),
AuthorNames = authorNames ?? [],
AuthorKeys = authorKeys ?? [],
FirstPublishYear = firstPublishYear,
EditionKeys = editionKeys ?? [],
Isbns = isbns ?? [],
Languages = languages ?? [],
Publishers = publishers ?? [],
Subjects = subjects ?? [],
PublishPlaces = publishPlaces ?? [],
NumberOfPagesMedian = numberOfPagesMedian,
RatingsAverage = ratingsAverage,
RatingsCount = ratingsCount,
AmazonIds = amazonIds ?? [],
GoodreadsIds = goodreadsIds ?? [],
GoogleIds = googleIds ?? [],
LibraryThingIds = libraryThingIds ?? [],
Lccn = lccn ?? [],
Oclc = oclc ?? []
};
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryWorkAuthorResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryWorkAuthorResponseFixture
{
private readonly Faker _faker = new();
private readonly OpenLibraryKeyReferenceResponseFixture _keyReferenceResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryWorkAuthorResponse"/>.
/// </summary>
/// <param name="author">Optional. The author reference of the work.</param>
/// <param name="key">Optional. The direct key of the author reference.</param>
/// <returns>The created work author response.</returns>
public OpenLibraryWorkAuthorResponse Create(
OpenLibraryKeyReferenceResponse? author = null,
string? key = null)
{
return new OpenLibraryWorkAuthorResponse
{
Author = author ?? _keyReferenceResponseFixture.Create(key: $"/authors/OL{_faker.Random.Number(1000, 9999)}A"),
Key = key
};
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.Contracts.Responses;
/// <summary>
/// Fixture class for the <see cref="OpenLibraryWorkResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibraryWorkResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibraryWorkResponse"/>.
/// </summary>
/// <param name="key">Optional. The key of the work.</param>
/// <param name="title">Optional. The title of the work.</param>
/// <param name="originalTitle">Optional. The original title of the work.</param>
/// <param name="description">Optional. The description of the work.</param>
/// <param name="firstPublishDate">Optional. The first publication date of the work.</param>
/// <param name="subjects">Optional. The subjects of the work.</param>
/// <param name="genres">Optional. The genres of the work.</param>
/// <param name="authors">Optional. The authors of the work.</param>
/// <param name="originalLanguages">Optional. The original languages of the work.</param>
/// <returns>The created work response.</returns>
public OpenLibraryWorkResponse Create(
string? key = null,
string? title = null,
string? originalTitle = null,
JsonElement? description = null,
string? firstPublishDate = null,
List<string>? subjects = null,
List<string>? genres = null,
List<OpenLibraryWorkAuthorResponse>? authors = null,
List<OpenLibraryKeyReferenceResponse>? originalLanguages = null)
{
return new OpenLibraryWorkResponse
{
Key = key ?? $"/works/OL{_faker.Random.Number(1000, 9999)}W",
Title = title ?? _faker.Commerce.ProductName(),
OriginalTitle = originalTitle,
Description = description ?? default,
FirstPublishDate = firstPublishDate,
Subjects = subjects ?? [],
Genres = genres ?? [],
Authors = authors ?? [],
OriginalLanguages = originalLanguages ?? []
};
}
}