mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Implements tests for commit f777af07cf
This commit is contained in:
1 parent
99fc721d8c
commit
54b468855a
54 files changed
+10681
-17
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AllUsersConsumptionStatisticsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AllUsersConsumptionStatisticsDtoFixture
|
||||
{
|
||||
private readonly ConsumptionTotalsDtoFixture _consumptionTotalsDtoFixture = new();
|
||||
private readonly ConsumptionStatisticsDtoFixture _consumptionStatisticsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AllUsersConsumptionStatisticsDto"/>.
|
||||
/// </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="AllUsersConsumptionStatisticsDto"/>.</returns>
|
||||
public AllUsersConsumptionStatisticsDto Create(
|
||||
ConsumptionTotalsDto? total = null,
|
||||
IReadOnlyList<ConsumptionStatisticsDto>? users = null,
|
||||
bool includeUsers = true)
|
||||
{
|
||||
IReadOnlyList<ConsumptionStatisticsDto> resolvedUsers = includeUsers
|
||||
? users ?? [_consumptionStatisticsDtoFixture.Create()]
|
||||
: [];
|
||||
|
||||
return new AllUsersConsumptionStatisticsDto(
|
||||
total ?? _consumptionTotalsDtoFixture.Create(),
|
||||
resolvedUsers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AllUsersConsumptionStatisticsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AllUsersConsumptionStatisticsDto"/> instances.</returns>
|
||||
public List<AllUsersConsumptionStatisticsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionTotalsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionTotalsDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionStatisticsDtoFixture _mediaKindConsumptionStatisticsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ConsumptionTotalsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="totalConsumedDurationMilliseconds">Optional. The total consumed duration, in milliseconds. 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="ConsumptionTotalsDto"/>.</returns>
|
||||
public ConsumptionTotalsDto Create(
|
||||
long? totalConsumedDurationMilliseconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto> resolvedMediaKindSummaries = includeMediaKindSummaries
|
||||
? mediaKindSummaries ?? [_mediaKindConsumptionStatisticsDtoFixture.Create()]
|
||||
: [];
|
||||
|
||||
return new ConsumptionTotalsDto(
|
||||
totalConsumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
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="ConsumptionTotalsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionTotalsDto"/> instances.</returns>
|
||||
public List<ConsumptionTotalsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -57,22 +57,22 @@ public class MediaConsumptionRecordEntityFixture
|
||||
/// <param name="startedOnUtc">Optional. The date and time when the session started. Defaults to a moment in the past, or before the last activity when it is supplied.</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="consumedDurationMilliseconds">Optional. The active duration consumed by the session, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="lastPositionKind">Optional. The kind of the last known position. Defaults to no position for a photo, a location for a book, and a time offset for every other kind.</param>
|
||||
/// <param name="includeLastPositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="lastPositionTimeOffsetMilliseconds">Optional. The last known position, in milliseconds. Defaults to a bounded random offset for a time offset position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="lastPositionLocation">Optional. The last known opaque locator. Defaults to a random word for a location position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location 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>
|
||||
/// <param name="version">Optional. The optimistic concurrency version of the row. Defaults to a bounded random positive version.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the row was created. Defaults to the start of the session.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the row was last updated. Defaults to no value.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row. Defaults to <see langword="null"/>.</param>
|
||||
/// <param name="includeEndedOnUtc">Whether the end time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionRecordEntity"/>.</returns>
|
||||
public MediaConsumptionRecordEntity Create(
|
||||
@@ -85,22 +85,22 @@ public class MediaConsumptionRecordEntityFixture
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? lastActivityOnUtc = null,
|
||||
DateTime? endedOnUtc = null,
|
||||
bool includeEndedOnUtc = true,
|
||||
long? consumedDurationMilliseconds = null,
|
||||
MediaPositionKind? lastPositionKind = null,
|
||||
bool includeLastPositionKind = true,
|
||||
long? lastPositionTimeOffsetMilliseconds = null,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
string? lastPositionLocation = null,
|
||||
bool includeLastPositionLocation = true,
|
||||
double? lastProgressFraction = null,
|
||||
int? consecutivePagesRead = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
Guid? updatedBy = null,
|
||||
bool includeEndedOnUtc = true,
|
||||
bool includeLastPositionKind = true,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
bool includeLastPositionLocation = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
|
||||
+6
-6
@@ -46,17 +46,17 @@ public class MediaResumePointEntityFixture
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
|
||||
/// <param name="lastPositionKind">Optional. The kind of the position at which the media item can be resumed. Defaults to a location for a book, and to a time offset for every other kind.</param>
|
||||
/// <param name="lastPositionTimeOffsetMilliseconds">Optional. The position, in milliseconds. Defaults to a bounded random offset for a time offset position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="lastPositionLocation">Optional. The opaque locator. Defaults to a random word for a location position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</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>
|
||||
/// <param name="version">Optional. The optimistic concurrency version of the row. Defaults to a bounded random positive version.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the row was created. Defaults to the last consumption time.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the row was last updated. Defaults to no value.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row. Defaults to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MediaResumePointEntity"/>.</returns>
|
||||
public MediaResumePointEntity Create(
|
||||
@@ -67,17 +67,17 @@ public class MediaResumePointEntityFixture
|
||||
Guid? mediaItemId = null,
|
||||
MediaPositionKind? lastPositionKind = null,
|
||||
long? lastPositionTimeOffsetMilliseconds = null,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
string? lastPositionLocation = null,
|
||||
bool includeLastPositionLocation = true,
|
||||
double? lastProgressFraction = null,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
Guid? updatedBy = null,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
bool includeLastPositionLocation = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.ClearConsumptionHistory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearConsumptionHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearConsumptionHistoryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearConsumptionHistoryCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ClearConsumptionHistoryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose consumption history is cleared. Defaults to a random user Id.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <returns>The created <see cref="ClearConsumptionHistoryCommand"/>.</returns>
|
||||
public ClearConsumptionHistoryCommand Create(
|
||||
string? targetUserId = null,
|
||||
bool includeTargetUserId = true)
|
||||
{
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new ClearConsumptionHistoryCommand(resolvedTargetUserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ClearConsumptionHistoryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearConsumptionHistoryCommand"/> instances.</returns>
|
||||
public List<ClearConsumptionHistoryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.ClearResumePoints;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearResumePoints;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearResumePointsCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearResumePointsCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ClearResumePointsCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose resume points are cleared. Defaults to a random user Id.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deletion is restricted to. Defaults to a random library Id.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/> so that every library is cleared.</param>
|
||||
/// <returns>The created <see cref="ClearResumePointsCommand"/>.</returns>
|
||||
public ClearResumePointsCommand Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedLibraryId = includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new ClearResumePointsCommand(resolvedTargetUserId, resolvedLibraryId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ClearResumePointsCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearResumePointsCommand"/> instances.</returns>
|
||||
public List<ClearResumePointsCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteConsumptionRecordCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteConsumptionRecordCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeleteConsumptionRecordCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record to delete, taken from the route. Defaults to a random Id.</param>
|
||||
/// <param name="targetUserId">Optional. The Id of the user the record must belong to. Defaults to a random user Id.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <returns>The created <see cref="DeleteConsumptionRecordCommand"/>.</returns>
|
||||
public DeleteConsumptionRecordCommand Create(
|
||||
string? consumptionRecordId = null,
|
||||
string? targetUserId = null,
|
||||
bool includeConsumptionRecordId = true,
|
||||
bool includeTargetUserId = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new DeleteConsumptionRecordCommand(resolvedConsumptionRecordId, resolvedTargetUserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeleteConsumptionRecordCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteConsumptionRecordCommand"/> instances.</returns>
|
||||
public List<DeleteConsumptionRecordCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetAllUsersConsumptionStatistics;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetAllUsersConsumptionStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetAllUsersConsumptionStatisticsQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAllUsersConsumptionStatisticsQueryFixture
|
||||
{
|
||||
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="GetAllUsersConsumptionStatisticsQuery"/>.
|
||||
/// </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 kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</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 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="GetAllUsersConsumptionStatisticsQuery"/>.</returns>
|
||||
public GetAllUsersConsumptionStatisticsQuery Create(
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
|
||||
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
|
||||
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
|
||||
|
||||
return new GetAllUsersConsumptionStatisticsQuery(
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetAllUsersConsumptionStatisticsQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetAllUsersConsumptionStatisticsQuery"/> instances.</returns>
|
||||
public List<GetAllUsersConsumptionStatisticsQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetConsumptionRecord;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetConsumptionRecord;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetConsumptionRecordQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetConsumptionRecordQueryFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetConsumptionRecordQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record to read, taken from the route. Defaults to a random Id.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetConsumptionRecordQuery"/>.</returns>
|
||||
public GetConsumptionRecordQuery Create(
|
||||
string? consumptionRecordId = null,
|
||||
bool includeConsumptionRecordId = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new GetConsumptionRecordQuery(resolvedConsumptionRecordId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetConsumptionRecordQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetConsumptionRecordQuery"/> instances.</returns>
|
||||
public List<GetConsumptionRecordQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetConsumptionStatistics;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetConsumptionStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetConsumptionStatisticsQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetConsumptionStatisticsQueryFixture
|
||||
{
|
||||
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="GetConsumptionStatisticsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
|
||||
/// <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 kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user 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>
|
||||
/// <param name="includeMediaKind">Whether the media kind 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="GetConsumptionStatisticsQuery"/>.</returns>
|
||||
public GetConsumptionStatisticsQuery Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
|
||||
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
|
||||
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
|
||||
|
||||
return new GetConsumptionStatisticsQuery(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetConsumptionStatisticsQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetConsumptionStatisticsQuery"/> instances.</returns>
|
||||
public List<GetConsumptionStatisticsQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetMostConsumed;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetMostConsumed;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetMostConsumedQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetMostConsumedQueryFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = 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="GetMostConsumedQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
|
||||
/// <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 kind of media to restrict the history to. Defaults to a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
|
||||
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user 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>
|
||||
/// <param name="includeMediaKind">Whether the media kind 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>
|
||||
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetMostConsumedQuery"/>.</returns>
|
||||
public GetMostConsumedQuery Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
PaginationDataDto? paginationData = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true,
|
||||
bool includePaginationData = false)
|
||||
{
|
||||
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
|
||||
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
|
||||
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
|
||||
|
||||
return new GetMostConsumedQuery(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null,
|
||||
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetMostConsumedQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetMostConsumedQuery"/> instances.</returns>
|
||||
public List<GetMostConsumedQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetRecentlyConsumed;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetRecentlyConsumed;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetRecentlyConsumedQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRecentlyConsumedQueryFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = 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="GetRecentlyConsumedQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
|
||||
/// <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 kind of media to restrict the history to. Defaults to a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
|
||||
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user 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>
|
||||
/// <param name="includeMediaKind">Whether the media kind 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>
|
||||
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetRecentlyConsumedQuery"/>.</returns>
|
||||
public GetRecentlyConsumedQuery Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
PaginationDataDto? paginationData = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true,
|
||||
bool includePaginationData = false)
|
||||
{
|
||||
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
|
||||
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
|
||||
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
|
||||
|
||||
return new GetRecentlyConsumedQuery(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null,
|
||||
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetRecentlyConsumedQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetRecentlyConsumedQuery"/> instances.</returns>
|
||||
public List<GetRecentlyConsumedQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetResumePoint;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetResumePoint;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetResumePointQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetResumePointQueryFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetResumePointQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The name of the kind of media to resume, taken from the route. Defaults to a resumable kind supported by the current catalogues.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to resume, taken from the route. Defaults to a random Id.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind 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>
|
||||
/// <returns>The created <see cref="GetResumePointQuery"/>.</returns>
|
||||
public GetResumePointQuery Create(
|
||||
string? mediaKind = null,
|
||||
string? mediaItemId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
string? resolvedMediaKind = includeMediaKind ? mediaKind ?? nameof(MediaKind.MusicTrack) : null;
|
||||
string? resolvedMediaItemId = includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new GetResumePointQuery(resolvedMediaKind, resolvedMediaItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetResumePointQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetResumePointQuery"/> instances.</returns>
|
||||
public List<GetResumePointQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetTagConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetTagConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetTagConsumptionQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTagConsumptionQueryFixture
|
||||
{
|
||||
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="GetTagConsumptionQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
|
||||
/// <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 kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user 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>
|
||||
/// <param name="includeMediaKind">Whether the media kind 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="GetTagConsumptionQuery"/>.</returns>
|
||||
public GetTagConsumptionQuery Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
|
||||
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
|
||||
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
|
||||
|
||||
return new GetTagConsumptionQuery(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetTagConsumptionQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetTagConsumptionQuery"/> instances.</returns>
|
||||
public List<GetTagConsumptionQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user