Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

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="publishCountry">Optional. The MARC 21 country code of the publication place 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,
string? publishCountry = 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 ?? [],
PublishCountry = publishCountry,
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 _openLibraryRatingSummaryResponseFixture = 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 ?? _openLibraryRatingSummaryResponseFixture.Create()
};
}
}
@@ -0,0 +1,85 @@
#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="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,
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 ?? [],
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 _openLibraryKeyReferenceResponseFixture = 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 ?? _openLibraryKeyReferenceResponseFixture.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 ?? []
};
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Models.DTO.Settings;
/// <summary>
/// Fixture class for the <see cref="OpenLibrarySettingsDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OpenLibrarySettingsDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="OpenLibrarySettingsDto"/>.
/// </summary>
/// <param name="userAgent">Optional. The user agent sent with every request.</param>
/// <param name="contactEmail">Optional. The contact email sent with every request.</param>
/// <param name="searchResultLimit">Optional. The maximum number of search results.</param>
/// <param name="workEditionLimit">Optional. The maximum number of editions fetched per work.</param>
/// <param name="minimumRequestInterval">Optional. The minimum interval between consecutive requests.</param>
/// <param name="includeUserAgent">Whether the user agent should be included, or left at its default value.</param>
/// <param name="includeSearchResultLimit">Whether the search result limit should be included, or left at its default value.</param>
/// <param name="includeWorkEditionLimit">Whether the work edition limit should be included, or left at its default value.</param>
/// <param name="includeMinimumRequestInterval">Whether the minimum request interval should be included, or left at its default value.</param>
/// <returns>The created <see cref="OpenLibrarySettingsDto"/>.</returns>
public OpenLibrarySettingsDto Create(
string? userAgent = null,
string? contactEmail = null,
int? searchResultLimit = null,
int? workEditionLimit = null,
TimeSpan? minimumRequestInterval = null,
bool includeUserAgent = true,
bool includeSearchResultLimit = true,
bool includeWorkEditionLimit = true,
bool includeMinimumRequestInterval = true)
{
OpenLibrarySettingsDto settings = new()
{
ContactEmail = contactEmail
};
if (includeUserAgent)
settings.UserAgent = userAgent ?? _faker.Internet.UserAgent();
if (includeSearchResultLimit)
settings.SearchResultLimit = searchResultLimit ?? _faker.Random.Number(1, 50);
if (includeWorkEditionLimit)
settings.WorkEditionLimit = workEditionLimit ?? _faker.Random.Number(1, 200);
if (includeMinimumRequestInterval)
settings.MinimumRequestInterval = minimumRequestInterval ?? TimeSpan.FromMilliseconds(_faker.Random.Number(100, 2000));
return settings;
}
}
@@ -0,0 +1,81 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.OpenLibrary.Fixtures.Common.Setup;
/// <summary>
/// <see cref="HttpMessageHandler"/> test double that routes requests to the configured responses based on their absolute path.
/// </summary>
[ExcludeFromCodeCoverage]
internal class StubOpenLibraryHttpMessageHandler : HttpMessageHandler
{
private readonly List<(Func<HttpRequestMessage, bool> Matches, Func<HttpRequestMessage, HttpResponseMessage> ResponseFactory)> _routes = [];
/// <summary>
/// Gets the list of requests that were sent through this handler.
/// </summary>
public List<HttpRequestMessage> Requests { get; } = [];
/// <summary>
/// Routes requests with the given absolute path to the provided JSON response.
/// </summary>
/// <param name="absolutePath">The absolute path of the request URL to match.</param>
/// <param name="json">The JSON payload of the response.</param>
/// <returns>This handler, for chaining.</returns>
public StubOpenLibraryHttpMessageHandler MapPath(string absolutePath, string json)
{
return AddRoute(
request => string.Equals(request.RequestUri?.AbsolutePath, absolutePath, StringComparison.Ordinal),
_ => CreateJsonResponse(HttpStatusCode.OK, json));
}
/// <summary>
/// Routes requests matching the given predicate to the response produced by the provided factory.
/// </summary>
/// <param name="matches">The predicate that determines whether the request matches the route.</param>
/// <param name="responseFactory">The factory that produces the response for a matching request.</param>
/// <returns>This handler, for chaining.</returns>
public StubOpenLibraryHttpMessageHandler AddRoute(Func<HttpRequestMessage, bool> matches, Func<HttpRequestMessage, HttpResponseMessage> responseFactory)
{
_routes.Add((matches, responseFactory));
return this;
}
/// <summary>
/// Creates a JSON response with the given status code and payload.
/// </summary>
/// <param name="statusCode">The status code of the response.</param>
/// <param name="json">The JSON payload of the response.</param>
/// <returns>The created JSON response.</returns>
public static HttpResponseMessage CreateJsonResponse(HttpStatusCode statusCode, string json)
{
return new HttpResponseMessage(statusCode)
{
Content = new StringContent(json, Encoding.UTF8, "application/json")
};
}
/// <summary>
/// Sends the request to the first matching route, or returns a not found response.
/// </summary>
/// <param name="request">The HTTP request message to send.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>The HTTP response message for the request.</returns>
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Requests.Add(request);
foreach ((Func<HttpRequestMessage, bool> matches, Func<HttpRequestMessage, HttpResponseMessage> responseFactory) in _routes)
if (matches(request))
return Task.FromResult(responseFactory(request));
return Task.FromResult(new HttpResponseMessage(HttpStatusCode.NotFound));
}
}
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.OpenLibrary\Lumina.Plugins.OpenLibrary.csproj" />
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lumina.Plugins.OpenLibrary.Fixtures")]
[assembly: AssemblyProduct("Lumina.Plugins.OpenLibrary.Fixtures")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("A1B2C3D4-0002-4A5B-9C0D-222222222222")]
[assembly: InternalsVisibleTo("Lumina.Plugins.OpenLibrary.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]