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,49 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="AllUsersConsumptionStatisticsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AllUsersConsumptionStatisticsResponseFixture
{
private readonly ConsumptionTotalsResponseFixture _consumptionTotalsResponseFixture = new();
private readonly ConsumptionSummaryResponseFixture _consumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="AllUsersConsumptionStatisticsResponse"/>.
/// </summary>
/// <param name="total">Optional. The combined statistics of every user. Defaults to a random set of totals.</param>
/// <param name="users">Optional. The statistics of each user. Defaults to a single random user summary.</param>
/// <param name="includeUsers">Whether the user summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="AllUsersConsumptionStatisticsResponse"/>.</returns>
public AllUsersConsumptionStatisticsResponse Create(
ConsumptionTotalsResponse? total = null,
IReadOnlyList<ConsumptionSummaryResponse>? users = null,
bool includeUsers = true)
{
IReadOnlyList<ConsumptionSummaryResponse> resolvedUsers = includeUsers
? users ?? [_consumptionSummaryResponseFixture.Create()]
: [];
return new AllUsersConsumptionStatisticsResponse(
total ?? _consumptionTotalsResponseFixture.Create(),
resolvedUsers);
}
/// <summary>
/// Creates a list of <see cref="AllUsersConsumptionStatisticsResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AllUsersConsumptionStatisticsResponse"/> instances.</returns>
public List<AllUsersConsumptionStatisticsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,90 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumedItemResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumedItemResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
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="ConsumedItemResponse"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of the consumed media item. Defaults to a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="isAvailable">Optional. Whether the media item is still available.</param>
/// <param name="title">Optional. The title of the media item.</param>
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed.</param>
/// <param name="countedSessionCount">Optional. The number of consumption sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of consumption sessions that completed.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed in the media item, in seconds. Defaults to a bounded random duration.</param>
/// <returns>The created <see cref="ConsumedItemResponse"/>.</returns>
public ConsumedItemResponse Create(
MediaKind? mediaKind = null,
Guid? mediaItemId = null,
Guid? libraryId = null,
bool? isAvailable = null,
string? title = null,
string? collectionTitle = null,
string? creatorName = null,
string? coverPath = null,
bool includeCoverPath = true,
DateTime? lastConsumedOnUtc = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
double? consumedDurationInSeconds = null)
{
return new ConsumedItemResponse(
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
mediaItemId ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
isAvailable ?? _faker.Random.Bool(),
title ?? _faker.Commerce.ProductName(),
collectionTitle ?? _faker.Commerce.Department(),
creatorName ?? _faker.Name.FullName(),
includeCoverPath ? coverPath ?? _faker.System.FilePath() : null,
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS));
}
/// <summary>
/// Creates a list of <see cref="ConsumedItemResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumedItemResponse"/> instances.</returns>
public List<ConsumedItemResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,126 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionRecordResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionRecordResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaPositionResponseFixture _mediaPositionResponseFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
private readonly ConsumptionStatus[] _statuses =
[
ConsumptionStatus.InProgress,
ConsumptionStatus.Completed,
ConsumptionStatus.Stopped
];
/// <summary>
/// Creates a random valid <see cref="ConsumptionRecordResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the consumption record.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the consumed media item.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
/// <param name="status">Optional. The state of the consumption session. Defaults to a random valid status.</param>
/// <param name="startedOnUtc">Optional. The date and time when the session started. Defaults to a moment in the past.</param>
/// <param name="lastActivityOnUtc">Optional. The date and time when the session last received activity. Defaults to a moment at or after the start.</param>
/// <param name="endedOnUtc">Optional. The date and time when the session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
/// <param name="includeEndedOnUtc">Whether the end time 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="lastPosition">Optional. The last known position. Defaults to a position matching the position kind of the media kind, and to no position for a photo.</param>
/// <param name="includeLastPosition">Whether the last position should be included, or forced to <see langword="null"/>.</param>
/// <param name="lastProgressFraction">Optional. The latest reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a book, and to zero for every other kind.</param>
/// <returns>The created <see cref="ConsumptionRecordResponse"/>.</returns>
public ConsumptionRecordResponse Create(
Guid? id = null,
Guid? libraryId = null,
Guid? mediaItemId = null,
MediaKind? mediaKind = null,
ConsumptionStatus? status = null,
DateTime? startedOnUtc = null,
DateTime? lastActivityOnUtc = null,
DateTime? endedOnUtc = null,
bool includeEndedOnUtc = true,
double? consumedDurationInSeconds = null,
MediaPositionResponse? lastPosition = null,
bool includeLastPosition = true,
double? lastProgressFraction = null,
int? consecutivePagesRead = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement(_statuses);
DateTime resolvedStartedOnUtc = startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
DateTime? resolvedEndedOnUtc = includeEndedOnUtc
? endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
? null
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60)))
: null;
MediaPositionKind? defaultPositionKind = ResolveDefaultPositionKind(resolvedMediaKind);
MediaPositionResponse? resolvedLastPosition = includeLastPosition && (lastPosition is not null || defaultPositionKind.HasValue)
? lastPosition ?? _mediaPositionResponseFixture.Create(kind: defaultPositionKind)
: null;
return new ConsumptionRecordResponse(
id ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
mediaItemId ?? _faker.Random.Guid(),
resolvedMediaKind,
resolvedStatus,
resolvedStartedOnUtc,
resolvedLastActivityOnUtc,
resolvedEndedOnUtc,
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
resolvedLastPosition,
lastProgressFraction ?? _faker.Random.Double(0, 1),
consecutivePagesRead ?? (resolvedMediaKind == MediaKind.Book ? _faker.Random.Int(0, 100) : 0));
}
/// <summary>
/// Creates a list of <see cref="ConsumptionRecordResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionRecordResponse"/> instances.</returns>
public List<ConsumptionRecordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the default kind of position used by a media kind.
/// </summary>
/// <param name="mediaKind">The kind of media.</param>
/// <returns>The position kind that a session of the media kind reports, or <see langword="null"/> when the kind carries no position.</returns>
private static MediaPositionKind? ResolveDefaultPositionKind(MediaKind mediaKind)
{
if (mediaKind == MediaKind.Photo)
return null;
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionSummaryResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKindConsumptionSummaryResponseFixture _mediaKindConsumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ConsumptionSummaryResponse"/>.
/// </summary>
/// <param name="userId">Optional. The Id of the user the statistics belong to.</param>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="ConsumptionSummaryResponse"/>.</returns>
public ConsumptionSummaryResponse Create(
Guid? userId = null,
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null,
IReadOnlyList<MediaKindConsumptionSummaryResponse>? mediaKindSummaries = null,
bool includeMediaKindSummaries = true)
{
IReadOnlyList<MediaKindConsumptionSummaryResponse> resolvedMediaKindSummaries = includeMediaKindSummaries
? mediaKindSummaries ?? [_mediaKindConsumptionSummaryResponseFixture.Create()]
: [];
return new ConsumptionSummaryResponse(
userId ?? _faker.Random.Guid(),
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1),
resolvedMediaKindSummaries);
}
/// <summary>
/// Creates a list of <see cref="ConsumptionSummaryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionSummaryResponse"/> instances.</returns>
public List<ConsumptionSummaryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionTotalsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionTotalsResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKindConsumptionSummaryResponseFixture _mediaKindConsumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ConsumptionTotalsResponse"/>.
/// </summary>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="ConsumptionTotalsResponse"/>.</returns>
public ConsumptionTotalsResponse Create(
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null,
IReadOnlyList<MediaKindConsumptionSummaryResponse>? mediaKindSummaries = null,
bool includeMediaKindSummaries = true)
{
IReadOnlyList<MediaKindConsumptionSummaryResponse> resolvedMediaKindSummaries = includeMediaKindSummaries
? mediaKindSummaries ?? [_mediaKindConsumptionSummaryResponseFixture.Create()]
: [];
return new ConsumptionTotalsResponse(
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1),
resolvedMediaKindSummaries);
}
/// <summary>
/// Creates a list of <see cref="ConsumptionTotalsResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionTotalsResponse"/> instances.</returns>
public List<ConsumptionTotalsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GenreConsumptionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GenreConsumptionResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GenreConsumptionResponse"/>.
/// </summary>
/// <param name="name">Optional. The lowercase name of the genre. Defaults to a random lowercase word.</param>
/// <param name="consumedItemCount">Optional. The number of distinct consumed media items that carry the genre. Defaults to a bounded random count.</param>
/// <param name="consumedDurationInSeconds">Optional. The consumed duration of the media items that carry the genre, in seconds. Defaults to a bounded random duration.</param>
/// <param name="includeName">Whether the genre name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsumedItemCount">Whether the consumed item count should be included, or forced to zero.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to zero.</param>
/// <returns>The created <see cref="GenreConsumptionResponse"/>.</returns>
public GenreConsumptionResponse Create(
string? name = null,
int? consumedItemCount = null,
double? consumedDurationInSeconds = null,
bool includeName = true,
bool includeConsumedItemCount = true,
bool includeConsumedDurationInSeconds = true)
{
return new GenreConsumptionResponse(
includeName ? name ?? _faker.Lorem.Word().ToLowerInvariant() : null!,
includeConsumedItemCount ? consumedItemCount ?? _faker.Random.Int(0, 1000) : 0,
includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : 0);
}
/// <summary>
/// Creates a list of <see cref="GenreConsumptionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GenreConsumptionResponse"/> instances.</returns>
public List<GenreConsumptionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.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.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="MediaKindConsumptionSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaKindConsumptionSummaryResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
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="MediaKindConsumptionSummaryResponse"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of media the statistics belong to. Defaults to a random supported kind.</param>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration of the media kind, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <returns>The created <see cref="MediaKindConsumptionSummaryResponse"/>.</returns>
public MediaKindConsumptionSummaryResponse Create(
MediaKind? mediaKind = null,
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null)
{
return new MediaKindConsumptionSummaryResponse(
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1));
}
/// <summary>
/// Creates a list of <see cref="MediaKindConsumptionSummaryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaKindConsumptionSummaryResponse"/> instances.</returns>
public List<MediaKindConsumptionSummaryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.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.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="MediaPositionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaPositionResponseFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private readonly Faker _faker = new();
private readonly MediaPositionKind[] _positionKinds =
[
MediaPositionKind.TimeOffset,
MediaPositionKind.Location
];
/// <summary>
/// Creates a random valid <see cref="MediaPositionResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of representation used by the position. 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="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="MediaPositionResponse"/>.</returns>
public MediaPositionResponse Create(
MediaPositionKind? kind = null,
double? timeOffsetSeconds = null,
string? location = null,
bool includeTimeOffsetSeconds = true,
bool includeLocation = true)
{
MediaPositionKind resolvedKind = kind ?? _faker.Random.ArrayElement(_positionKinds);
bool isTimeOffset = resolvedKind == MediaPositionKind.TimeOffset;
double? resolvedTimeOffsetSeconds = includeTimeOffsetSeconds
? timeOffsetSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedLocation = includeLocation
? location ?? (isTimeOffset ? null : _faker.Lorem.Word())
: null;
return new MediaPositionResponse(resolvedKind, resolvedTimeOffsetSeconds, resolvedLocation);
}
/// <summary>
/// Creates a list of <see cref="MediaPositionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaPositionResponse"/> instances.</returns>
public List<MediaPositionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ResumePointResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ResumePointResponseFixture
{
private readonly Faker _faker = new();
private readonly MediaPositionResponseFixture _mediaPositionResponseFixture = new();
private readonly MediaKind[] _resumableMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="ResumePointResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the resume point.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
/// <param name="lastPosition">Optional. The position at which the media item can be resumed. Defaults to a position matching the position kind of the media kind.</param>
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
/// <returns>The created <see cref="ResumePointResponse"/>.</returns>
public ResumePointResponse Create(
Guid? id = null,
Guid? libraryId = null,
Guid? mediaItemId = null,
MediaKind? mediaKind = null,
MediaPositionResponse? lastPosition = null,
double? lastProgressFraction = null,
DateTime? lastConsumedOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
return new ResumePointResponse(
id ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
mediaItemId ?? _faker.Random.Guid(),
resolvedMediaKind,
lastPosition ?? _mediaPositionResponseFixture.Create(kind: ResolveDefaultPositionKind(resolvedMediaKind)),
lastProgressFraction ?? _faker.Random.Double(0, 1),
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)));
}
/// <summary>
/// Creates a list of <see cref="ResumePointResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ResumePointResponse"/> instances.</returns>
public List<ResumePointResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the default kind of position used by a media kind.
/// </summary>
/// <param name="mediaKind">The kind of media.</param>
/// <returns>The position kind that a resume point of the media kind uses.</returns>
private static MediaPositionKind ResolveDefaultPositionKind(MediaKind mediaKind)
{
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="TagConsumptionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TagConsumptionResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TagConsumptionResponse"/>.
/// </summary>
/// <param name="name">Optional. The lowercase name of the tag.</param>
/// <param name="consumedItemCount">Optional. The number of distinct consumed media items that carry the tag.</param>
/// <param name="consumedDurationInSeconds">Optional. The consumed duration of the media items that carry the tag, in seconds. Defaults to a bounded random duration.</param>
/// <returns>The created <see cref="TagConsumptionResponse"/>.</returns>
public TagConsumptionResponse Create(
string? name = null,
int? consumedItemCount = null,
double? consumedDurationInSeconds = null)
{
return new TagConsumptionResponse(
name ?? _faker.Lorem.Word().ToLowerInvariant(),
consumedItemCount ?? _faker.Random.Int(0, 1000),
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS));
}
/// <summary>
/// Creates a list of <see cref="TagConsumptionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="TagConsumptionResponse"/> instances.</returns>
public List<TagConsumptionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}