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,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ClearResumePointsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ClearResumePointsRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ClearResumePointsRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the deletion to. Defaults to a random Id.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ClearResumePointsRequest"/>.</returns>
public ClearResumePointsRequest Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new ClearResumePointsRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null);
}
/// <summary>
/// Creates a list of <see cref="ClearResumePointsRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ClearResumePointsRequest"/> instances.</returns>
public List<ClearResumePointsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="CompleteConsumptionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class CompleteConsumptionRequestFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaPositionRequestFixture _mediaPositionRequestFixture = new();
/// <summary>
/// Creates a random valid <see cref="CompleteConsumptionRequest"/>.
/// </summary>
/// <param name="position">Optional. The final position reported for the media item.</param>
/// <param name="includePosition">Whether the position should be included, or forced to <see langword="null"/>.</param>
/// <param name="progressFraction">Optional. The fraction of the media item that the client reached. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session.</param>
/// <param name="includeConsecutivePagesRead">Whether the optional consecutive pages argument should be supplied at all. When <see langword="false"/>, the argument is omitted, so the record default applies.</param>
/// <returns>The created <see cref="CompleteConsumptionRequest"/>.</returns>
public CompleteConsumptionRequest Create(
MediaPositionRequest? position = null,
bool includePosition = true,
double? progressFraction = null,
bool includeProgressFraction = true,
double? consumedDurationInSeconds = null,
bool includeConsumedDurationInSeconds = true,
int? consecutivePagesRead = null,
bool includeConsecutivePagesRead = true)
{
MediaPositionRequest? resolvedPosition = includePosition ? position ?? _mediaPositionRequestFixture.Create() : null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
if (!includeConsecutivePagesRead)
return new CompleteConsumptionRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds);
return new CompleteConsumptionRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds, consecutivePagesRead);
}
/// <summary>
/// Creates a list of <see cref="CompleteConsumptionRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="CompleteConsumptionRequest"/> instances.</returns>
public List<CompleteConsumptionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="DeleteConsumptionItemHistoryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteConsumptionItemHistoryRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="DeleteConsumptionItemHistoryRequest"/>.
/// </summary>
/// <param name="mediaKind">Optional. The name of the kind of the consumed media item. Defaults to the name of a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item. Defaults to a random Id.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteConsumptionItemHistoryRequest"/>.</returns>
public DeleteConsumptionItemHistoryRequest Create(
string? mediaKind = null,
string? mediaItemId = null,
string? libraryId = null,
bool includeMediaKind = true,
bool includeMediaItemId = true,
bool includeLibraryId = true)
{
return new DeleteConsumptionItemHistoryRequest(
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteConsumptionItemHistoryRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteConsumptionItemHistoryRequest"/> instances.</returns>
public List<DeleteConsumptionItemHistoryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetAllUsersConsumptionStatisticsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAllUsersConsumptionStatisticsRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetAllUsersConsumptionStatisticsRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAllUsersConsumptionStatisticsRequest"/>.</returns>
public GetAllUsersConsumptionStatisticsRequest Create(
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetAllUsersConsumptionStatisticsRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetAllUsersConsumptionStatisticsRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAllUsersConsumptionStatisticsRequest"/> instances.</returns>
public List<GetAllUsersConsumptionStatisticsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetConsumptionStatisticsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetConsumptionStatisticsRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetConsumptionStatisticsRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetConsumptionStatisticsRequest"/>.</returns>
public GetConsumptionStatisticsRequest Create(
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetConsumptionStatisticsRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetConsumptionStatisticsRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetConsumptionStatisticsRequest"/> instances.</returns>
public List<GetConsumptionStatisticsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetGenreConsumptionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetGenreConsumptionRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetGenreConsumptionRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment in the future, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetGenreConsumptionRequest"/>.</returns>
public GetGenreConsumptionRequest Create(
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetGenreConsumptionRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetGenreConsumptionRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetGenreConsumptionRequest"/> instances.</returns>
public List<GetGenreConsumptionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetMostConsumedRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetMostConsumedRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetMostConsumedRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="currentPage">Optional. The one based page of media items to return. Defaults to a bounded positive page.</param>
/// <param name="perPage">Optional. The number of media items per page. Defaults to a bounded positive count.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the count per page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetMostConsumedRequest"/>.</returns>
public GetMostConsumedRequest Create(
string? libraryId = null,
string? mediaKind = null,
int? currentPage = null,
int? perPage = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeCurrentPage = true,
bool includePerPage = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetMostConsumedRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeCurrentPage ? currentPage ?? _faker.Random.Int(1, 100) : null,
includePerPage ? perPage ?? _faker.Random.Int(1, 50) : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetMostConsumedRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetMostConsumedRequest"/> instances.</returns>
public List<GetMostConsumedRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetRecentlyConsumedRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRecentlyConsumedRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetRecentlyConsumedRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="currentPage">Optional. The one based page of media items to return. Defaults to a bounded positive page.</param>
/// <param name="perPage">Optional. The number of media items per page. Defaults to a bounded positive count.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the count per page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetRecentlyConsumedRequest"/>.</returns>
public GetRecentlyConsumedRequest Create(
string? libraryId = null,
string? mediaKind = null,
int? currentPage = null,
int? perPage = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeCurrentPage = true,
bool includePerPage = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetRecentlyConsumedRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeCurrentPage ? currentPage ?? _faker.Random.Int(1, 100) : null,
includePerPage ? perPage ?? _faker.Random.Int(1, 50) : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetRecentlyConsumedRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetRecentlyConsumedRequest"/> instances.</returns>
public List<GetRecentlyConsumedRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetTagConsumptionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTagConsumptionRequestFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetTagConsumptionRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetTagConsumptionRequest"/>.</returns>
public GetTagConsumptionRequest Create(
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetTagConsumptionRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetTagConsumptionRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetTagConsumptionRequest"/> instances.</returns>
public List<GetTagConsumptionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="MediaPositionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaPositionRequestFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaPositionRequest"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the position, as the name of a <see cref="MediaPositionKind"/> member. Defaults to a random valid kind.</param>
/// <param name="timeOffsetSeconds">Optional. The position within the media item, in seconds. Defaults to a bounded random offset for a time offset position.</param>
/// <param name="location">Optional. The opaque locator within the media item. Defaults to a random word for a location position.</param>
/// <param name="includeKind">Whether the kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTimeOffsetSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MediaPositionRequest"/>.</returns>
public MediaPositionRequest Create(
string? kind = null,
double? timeOffsetSeconds = null,
string? location = null,
bool includeKind = true,
bool includeTimeOffsetSeconds = true,
bool includeLocation = true)
{
string? resolvedKind = includeKind ? kind ?? _faker.PickRandom<MediaPositionKind>().ToString() : null;
bool isTimeOffset = resolvedKind == nameof(MediaPositionKind.TimeOffset);
double? resolvedTimeOffsetSeconds = includeTimeOffsetSeconds
? timeOffsetSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedLocation = includeLocation
? location ?? (isTimeOffset ? (string?)null : _faker.Lorem.Word())
: null;
return new MediaPositionRequest(resolvedKind, resolvedTimeOffsetSeconds, resolvedLocation);
}
/// <summary>
/// Creates a list of <see cref="MediaPositionRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaPositionRequest"/> instances.</returns>
public List<MediaPositionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ReportConsumptionProgressRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReportConsumptionProgressRequestFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaPositionRequestFixture _mediaPositionRequestFixture = new();
/// <summary>
/// Creates a random valid <see cref="ReportConsumptionProgressRequest"/>.
/// </summary>
/// <param name="position">Optional. The last position reported for the media item.</param>
/// <param name="includePosition">Whether the position should be included, or forced to <see langword="null"/>.</param>
/// <param name="progressFraction">Optional. The fraction of the media item that the client reached. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the current session.</param>
/// <param name="includeConsecutivePagesRead">Whether the consecutive pages argument should be supplied at all. When <see langword="false"/>, the argument is omitted, so the record default applies.</param>
/// <returns>The created <see cref="ReportConsumptionProgressRequest"/>.</returns>
public ReportConsumptionProgressRequest Create(
MediaPositionRequest? position = null,
bool includePosition = true,
double? progressFraction = null,
bool includeProgressFraction = true,
double? consumedDurationInSeconds = null,
bool includeConsumedDurationInSeconds = true,
int? consecutivePagesRead = null,
bool includeConsecutivePagesRead = true)
{
MediaPositionRequest? resolvedPosition = includePosition ? position ?? _mediaPositionRequestFixture.Create() : null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
if (!includeConsecutivePagesRead)
return new ReportConsumptionProgressRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds);
return new ReportConsumptionProgressRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds, consecutivePagesRead ?? 0);
}
/// <summary>
/// Creates a list of <see cref="ReportConsumptionProgressRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ReportConsumptionProgressRequest"/> instances.</returns>
public List<ReportConsumptionProgressRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="StopConsumptionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class StopConsumptionRequestFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaPositionRequestFixture _mediaPositionRequestFixture = new();
/// <summary>
/// Creates a random valid <see cref="StopConsumptionRequest"/>.
/// </summary>
/// <param name="position">Optional. The final position reported for the media item.</param>
/// <param name="includePosition">Whether the position should be included, or forced to <see langword="null"/>.</param>
/// <param name="progressFraction">Optional. The fraction of the media item that the client reached. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session.</param>
/// <param name="includeConsecutivePagesRead">Whether the optional consecutive pages argument should be supplied at all. When <see langword="false"/>, the argument is omitted, so the record default applies.</param>
/// <returns>The created <see cref="StopConsumptionRequest"/>.</returns>
public StopConsumptionRequest Create(
MediaPositionRequest? position = null,
bool includePosition = true,
double? progressFraction = null,
bool includeProgressFraction = true,
double? consumedDurationInSeconds = null,
bool includeConsumedDurationInSeconds = true,
int? consecutivePagesRead = null,
bool includeConsecutivePagesRead = true)
{
MediaPositionRequest? resolvedPosition = includePosition ? position ?? _mediaPositionRequestFixture.Create() : null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
if (!includeConsecutivePagesRead)
return new StopConsumptionRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds);
return new StopConsumptionRequest(resolvedPosition, resolvedProgressFraction, resolvedConsumedDurationInSeconds, consecutivePagesRead);
}
/// <summary>
/// Creates a list of <see cref="StopConsumptionRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="StopConsumptionRequest"/> instances.</returns>
public List<StopConsumptionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}