mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+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())];
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.CompleteConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.CompleteConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="CompleteConsumptionCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CompleteConsumptionCommandFixture
|
||||
{
|
||||
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
|
||||
private const double MAXIMUM_DURATION_SECONDS = 36_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="CompleteConsumptionCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
|
||||
/// <param name="positionKind">Optional. The name of the kind of the final position. Defaults to a time offset.</param>
|
||||
/// <param name="positionTimeOffsetInSeconds">Optional. The final position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
|
||||
/// <param name="positionLocation">Optional. The final opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
|
||||
/// <param name="progressFraction">Optional. The final progress fraction. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to no value.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeConsecutivePagesRead">Whether the consecutive pages count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="CompleteConsumptionCommand"/>.</returns>
|
||||
public CompleteConsumptionCommand Create(
|
||||
string? consumptionRecordId = null,
|
||||
string? positionKind = null,
|
||||
double? positionTimeOffsetInSeconds = null,
|
||||
string? positionLocation = null,
|
||||
double? progressFraction = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
int? consecutivePagesRead = null,
|
||||
bool includeConsumptionRecordId = true,
|
||||
bool includePositionKind = true,
|
||||
bool includePositionTimeOffsetInSeconds = true,
|
||||
bool includePositionLocation = true,
|
||||
bool includeProgressFraction = true,
|
||||
bool includeConsumedDurationInSeconds = true,
|
||||
bool includeConsecutivePagesRead = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
|
||||
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
|
||||
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
|
||||
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
|
||||
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
|
||||
: null;
|
||||
string? resolvedPositionLocation = includePositionLocation
|
||||
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
|
||||
: null;
|
||||
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
|
||||
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
|
||||
int? resolvedConsecutivePagesRead = includeConsecutivePagesRead ? consecutivePagesRead : null;
|
||||
|
||||
return new CompleteConsumptionCommand(
|
||||
resolvedConsumptionRecordId,
|
||||
resolvedPositionKind,
|
||||
resolvedPositionTimeOffsetInSeconds,
|
||||
resolvedPositionLocation,
|
||||
resolvedProgressFraction,
|
||||
resolvedConsumedDurationInSeconds,
|
||||
resolvedConsecutivePagesRead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="CompleteConsumptionCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="CompleteConsumptionCommand"/> instances.</returns>
|
||||
public List<CompleteConsumptionCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.DeleteConsumptionItemHistory;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.DeleteConsumptionItemHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteConsumptionItemHistoryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteConsumptionItemHistoryCommandFixture
|
||||
{
|
||||
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="DeleteConsumptionItemHistoryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user the records must belong to. Defaults to a random user Id.</param>
|
||||
/// <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="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="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="DeleteConsumptionItemHistoryCommand"/>.</returns>
|
||||
public DeleteConsumptionItemHistoryCommand Create(
|
||||
string? targetUserId = null,
|
||||
string? mediaKind = null,
|
||||
string? mediaItemId = null,
|
||||
string? libraryId = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
return new DeleteConsumptionItemHistoryCommand(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
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="DeleteConsumptionItemHistoryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteConsumptionItemHistoryCommand"/> instances.</returns>
|
||||
public List<DeleteConsumptionItemHistoryCommand> 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())];
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.ReportConsumptionProgress;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ReportConsumptionProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReportConsumptionProgressCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReportConsumptionProgressCommandFixture
|
||||
{
|
||||
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
|
||||
private const double MAXIMUM_DURATION_SECONDS = 36_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReportConsumptionProgressCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
|
||||
/// <param name="positionKind">Optional. The name of the kind of the reported position. Defaults to a time offset.</param>
|
||||
/// <param name="positionTimeOffsetInSeconds">Optional. The reported position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
|
||||
/// <param name="positionLocation">Optional. The reported opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
|
||||
/// <param name="progressFraction">Optional. The reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the current session. Defaults to zero.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ReportConsumptionProgressCommand"/>.</returns>
|
||||
public ReportConsumptionProgressCommand Create(
|
||||
string? consumptionRecordId = null,
|
||||
string? positionKind = null,
|
||||
double? positionTimeOffsetInSeconds = null,
|
||||
string? positionLocation = null,
|
||||
double? progressFraction = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
int consecutivePagesRead = 0,
|
||||
bool includeConsumptionRecordId = true,
|
||||
bool includePositionKind = true,
|
||||
bool includePositionTimeOffsetInSeconds = true,
|
||||
bool includePositionLocation = true,
|
||||
bool includeProgressFraction = true,
|
||||
bool includeConsumedDurationInSeconds = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
|
||||
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
|
||||
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
|
||||
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
|
||||
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
|
||||
: null;
|
||||
string? resolvedPositionLocation = includePositionLocation
|
||||
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
|
||||
: null;
|
||||
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
|
||||
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
|
||||
|
||||
return new ReportConsumptionProgressCommand(
|
||||
resolvedConsumptionRecordId,
|
||||
resolvedPositionKind,
|
||||
resolvedPositionTimeOffsetInSeconds,
|
||||
resolvedPositionLocation,
|
||||
resolvedProgressFraction,
|
||||
resolvedConsumedDurationInSeconds,
|
||||
consecutivePagesRead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReportConsumptionProgressCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReportConsumptionProgressCommand"/> instances.</returns>
|
||||
public List<ReportConsumptionProgressCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.StartConsumption;
|
||||
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.Commands.StartConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StartConsumptionCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StartConsumptionCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="StartConsumptionCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item, taken from the route.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is consumed, taken from the route. Defaults to the name of a kind supported by the current catalogues.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item, taken from the route.</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="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="StartConsumptionCommand"/>.</returns>
|
||||
public StartConsumptionCommand Create(
|
||||
string? libraryId = null,
|
||||
string? mediaKind = null,
|
||||
string? mediaItemId = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
string? resolvedLibraryId = includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedMediaKind = includeMediaKind ? mediaKind ?? nameof(MediaKind.MusicTrack) : null;
|
||||
string? resolvedMediaItemId = includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new StartConsumptionCommand(resolvedLibraryId, resolvedMediaKind, resolvedMediaItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StartConsumptionCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="StartConsumptionCommand"/> instances.</returns>
|
||||
public List<StartConsumptionCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.StopConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.StopConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StopConsumptionCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StopConsumptionCommandFixture
|
||||
{
|
||||
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
|
||||
private const double MAXIMUM_DURATION_SECONDS = 36_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="StopConsumptionCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
|
||||
/// <param name="positionKind">Optional. The name of the kind of the final position. Defaults to a time offset.</param>
|
||||
/// <param name="positionTimeOffsetInSeconds">Optional. The final position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
|
||||
/// <param name="positionLocation">Optional. The final opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
|
||||
/// <param name="progressFraction">Optional. The final progress fraction. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to no value.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeConsecutivePagesRead">Whether the consecutive pages count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="StopConsumptionCommand"/>.</returns>
|
||||
public StopConsumptionCommand Create(
|
||||
string? consumptionRecordId = null,
|
||||
string? positionKind = null,
|
||||
double? positionTimeOffsetInSeconds = null,
|
||||
string? positionLocation = null,
|
||||
double? progressFraction = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
int? consecutivePagesRead = null,
|
||||
bool includeConsumptionRecordId = true,
|
||||
bool includePositionKind = true,
|
||||
bool includePositionTimeOffsetInSeconds = true,
|
||||
bool includePositionLocation = true,
|
||||
bool includeProgressFraction = true,
|
||||
bool includeConsumedDurationInSeconds = true,
|
||||
bool includeConsecutivePagesRead = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
|
||||
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
|
||||
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
|
||||
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
|
||||
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
|
||||
: null;
|
||||
string? resolvedPositionLocation = includePositionLocation
|
||||
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
|
||||
: null;
|
||||
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
|
||||
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
|
||||
int? resolvedConsecutivePagesRead = includeConsecutivePagesRead ? consecutivePagesRead : null;
|
||||
|
||||
return new StopConsumptionCommand(
|
||||
resolvedConsumptionRecordId,
|
||||
resolvedPositionKind,
|
||||
resolvedPositionTimeOffsetInSeconds,
|
||||
resolvedPositionLocation,
|
||||
resolvedProgressFraction,
|
||||
resolvedConsumedDurationInSeconds,
|
||||
resolvedConsecutivePagesRead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StopConsumptionCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="StopConsumptionCommand"/> instances.</returns>
|
||||
public List<StopConsumptionCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user