mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Implements tests for commit 00d7eff777
Covers genre consumption and delete-item-history across application, contracts, API, and Web. Changes the new string-bound request pipelines to return validation problems instead of 500 for malformed values.
This commit is contained in:
1 parent
968061e89a
commit
1afb078efc
91 files changed
+14499
-50
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
#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="GenreConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreConsumptionDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GenreConsumptionDto"/>.
|
||||
/// </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="consumedDurationMilliseconds">Optional. The consumed duration of the media items that carry the genre, in milliseconds. 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="includeConsumedDurationMilliseconds">Whether the consumed duration should be included, or forced to zero.</param>
|
||||
/// <returns>The created <see cref="GenreConsumptionDto"/>.</returns>
|
||||
public GenreConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
long? consumedDurationMilliseconds = null,
|
||||
bool includeName = true,
|
||||
bool includeConsumedItemCount = true,
|
||||
bool includeConsumedDurationMilliseconds = true)
|
||||
{
|
||||
return new GenreConsumptionDto(
|
||||
includeName ? name ?? _faker.Lorem.Word().ToLowerInvariant() : null!,
|
||||
includeConsumedItemCount ? consumedItemCount ?? _faker.Random.Int(0, 1000) : 0,
|
||||
includeConsumedDurationMilliseconds ? consumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS) : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GenreConsumptionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GenreConsumptionDto"/> instances.</returns>
|
||||
public List<GenreConsumptionDto> 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())];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Queries.GetGenreConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetGenreConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetGenreConsumptionQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetGenreConsumptionQueryFixture
|
||||
{
|
||||
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="GetGenreConsumptionQuery"/>.
|
||||
/// </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 name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment in the future, as a text value.</param>
|
||||
/// <param name="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 name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetGenreConsumptionQuery"/>.</returns>
|
||||
public GetGenreConsumptionQuery Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
string? mediaKind = null,
|
||||
string? fromUtc = null,
|
||||
string? toUtc = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
|
||||
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
|
||||
|
||||
return new GetGenreConsumptionQuery(
|
||||
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetGenreConsumptionQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetGenreConsumptionQuery"/> instances.</returns>
|
||||
public List<GetGenreConsumptionQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteConsumptionItemHistoryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteConsumptionItemHistoryRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeleteConsumptionItemHistoryRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The name of the kind of the consumed media item. Defaults to the name of a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item. Defaults to a random Id.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item. Defaults to a random Id.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeleteConsumptionItemHistoryRequest"/>.</returns>
|
||||
public DeleteConsumptionItemHistoryRequest Create(
|
||||
string? mediaKind = null,
|
||||
string? mediaItemId = null,
|
||||
string? libraryId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
return new DeleteConsumptionItemHistoryRequest(
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
|
||||
includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeleteConsumptionItemHistoryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteConsumptionItemHistoryRequest"/> instances.</returns>
|
||||
public List<DeleteConsumptionItemHistoryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetGenreConsumptionRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetGenreConsumptionRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetGenreConsumptionRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
|
||||
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
|
||||
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
|
||||
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment in the future, as a text value.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetGenreConsumptionRequest"/>.</returns>
|
||||
public GetGenreConsumptionRequest Create(
|
||||
string? libraryId = null,
|
||||
string? mediaKind = null,
|
||||
string? fromUtc = null,
|
||||
string? toUtc = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
|
||||
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
|
||||
|
||||
return new GetGenreConsumptionRequest(
|
||||
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
|
||||
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
|
||||
includeFromUtc ? resolvedFromUtc : null,
|
||||
includeToUtc ? resolvedToUtc : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetGenreConsumptionRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetGenreConsumptionRequest"/> instances.</returns>
|
||||
public List<GetGenreConsumptionRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -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())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.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 ConsumptionSummaryDtoFixture _consumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AllUsersConsumptionStatisticsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="total">Optional combined consumption statistics of every user.</param>
|
||||
/// <param name="users">Optional consumption statistics of each user.</param>
|
||||
/// <param name="includeUsers">Whether the per user statistics should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="AllUsersConsumptionStatisticsDto"/> instance.</returns>
|
||||
public AllUsersConsumptionStatisticsDto Create(
|
||||
ConsumptionTotalsDto? total = null,
|
||||
IReadOnlyList<ConsumptionSummaryDto>? users = null,
|
||||
bool includeUsers = true)
|
||||
{
|
||||
return new AllUsersConsumptionStatisticsDto(
|
||||
Total: total ?? _consumptionTotalsDtoFixture.Create(),
|
||||
Users: includeUsers ? (users ?? [.. _consumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <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())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumedItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumedItemDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumedItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the consumed media item.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the media item is still available.</param>
|
||||
/// <param name="title">Optional title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the media item.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional date and time when the media item was last consumed.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ConsumedItemDto"/> instance.</returns>
|
||||
public ConsumedItemDto 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,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ConsumedItemDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
IsAvailable: isAvailable ?? _faker.Random.Bool(),
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
LastConsumedOnUtc: lastConsumedOnUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31)),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumedItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumedItemDto"/> instances.</returns>
|
||||
public List<ConsumedItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionSummaryDtoFixture _mediaKindConsumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user the statistics belong to.</param>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <param name="mediaKindSummaries">Optional consumption statistics broken down by media kind.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="ConsumptionSummaryDto"/> instance.</returns>
|
||||
public ConsumptionSummaryDto Create(
|
||||
Guid? userId = null,
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionSummaryDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
return new ConsumptionSummaryDto(
|
||||
UserId: userId ?? _faker.Random.Guid(),
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1),
|
||||
MediaKindSummaries: includeMediaKindSummaries ? (mediaKindSummaries ?? [.. _mediaKindConsumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumptionSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionSummaryDto"/> instances.</returns>
|
||||
public List<ConsumptionSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionTotalsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionTotalsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionSummaryDtoFixture _mediaKindConsumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionTotalsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <param name="mediaKindSummaries">Optional consumption statistics broken down by media kind.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="ConsumptionTotalsDto"/> instance.</returns>
|
||||
public ConsumptionTotalsDto Create(
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionSummaryDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
return new ConsumptionTotalsDto(
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1),
|
||||
MediaKindSummaries: includeMediaKindSummaries ? (mediaKindSummaries ?? [.. _mediaKindConsumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <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())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GenreConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreConsumptionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GenreConsumptionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional lowercase name of the genre.</param>
|
||||
/// <param name="consumedItemCount">Optional number of distinct consumed media items that carry the genre.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <returns>A configured <see cref="GenreConsumptionDto"/> instance.</returns>
|
||||
public GenreConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
double? consumedDurationInSeconds = null)
|
||||
{
|
||||
return new GenreConsumptionDto(
|
||||
Name: name ?? _faker.Lorem.Word().ToLowerInvariant(),
|
||||
ConsumedItemCount: consumedItemCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GenreConsumptionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GenreConsumptionDto"/> instances.</returns>
|
||||
public List<GenreConsumptionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaKindConsumptionSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaKindConsumptionSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaKindConsumptionSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of media the statistics belong to.</param>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <returns>A configured <see cref="MediaKindConsumptionSummaryDto"/> instance.</returns>
|
||||
public MediaKindConsumptionSummaryDto Create(
|
||||
MediaKind? mediaKind = null,
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null)
|
||||
{
|
||||
return new MediaKindConsumptionSummaryDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaKindConsumptionSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaKindConsumptionSummaryDto"/> instances.</returns>
|
||||
public List<MediaKindConsumptionSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StatisticsPageDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StatisticsPageDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatisticsPageDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional localized title of the page.</param>
|
||||
/// <param name="isAdmin">Optional value indicating whether the current user is an administrator.</param>
|
||||
/// <param name="currentUserId">Optional Id of the current user.</param>
|
||||
/// <param name="culture">Optional culture of the page.</param>
|
||||
/// <param name="getStatisticsUrl">Optional route that returns the statistics of the selected user.</param>
|
||||
/// <param name="getAllUsersStatisticsUrl">Optional route that returns the statistics of every user.</param>
|
||||
/// <param name="getRecentlyConsumedUrl">Optional route that returns the recently consumed media items.</param>
|
||||
/// <param name="getMostConsumedUrl">Optional route that returns the most consumed media items.</param>
|
||||
/// <param name="getTagConsumptionUrl">Optional route that returns the tag consumption.</param>
|
||||
/// <param name="getGenreConsumptionUrl">Optional route that returns the genre consumption.</param>
|
||||
/// <param name="getLibrariesUrl">Optional route that returns the libraries available for the library filter.</param>
|
||||
/// <param name="getUsersUrl">Optional route that returns the users available for the administrator user selector.</param>
|
||||
/// <param name="deleteConsumptionItemHistoryUrl">Optional route that deletes every consumption record of a media item.</param>
|
||||
/// <param name="clearConsumptionHistoryUrl">Optional route that deletes the consumption history.</param>
|
||||
/// <param name="clearResumePointsUrl">Optional route that deletes the resume points.</param>
|
||||
/// <param name="includeCurrentUserId">Whether the current user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="StatisticsPageDto"/> instance.</returns>
|
||||
public StatisticsPageDto Create(
|
||||
string? title = null,
|
||||
bool? isAdmin = null,
|
||||
Guid? currentUserId = null,
|
||||
string? culture = null,
|
||||
string? getStatisticsUrl = null,
|
||||
string? getAllUsersStatisticsUrl = null,
|
||||
string? getRecentlyConsumedUrl = null,
|
||||
string? getMostConsumedUrl = null,
|
||||
string? getTagConsumptionUrl = null,
|
||||
string? getGenreConsumptionUrl = null,
|
||||
string? getLibrariesUrl = null,
|
||||
string? getUsersUrl = null,
|
||||
string? deleteConsumptionItemHistoryUrl = null,
|
||||
string? clearConsumptionHistoryUrl = null,
|
||||
string? clearResumePointsUrl = null,
|
||||
bool includeCurrentUserId = true)
|
||||
{
|
||||
return new StatisticsPageDto(
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
IsAdmin: isAdmin ?? _faker.Random.Bool(),
|
||||
CurrentUserId: includeCurrentUserId ? (currentUserId ?? _faker.Random.Guid()) : null,
|
||||
Culture: culture ?? _faker.PickRandom("en-US", "de-DE", "fr-FR"),
|
||||
GetStatisticsUrl: getStatisticsUrl ?? _faker.Internet.Url(),
|
||||
GetAllUsersStatisticsUrl: getAllUsersStatisticsUrl ?? _faker.Internet.Url(),
|
||||
GetRecentlyConsumedUrl: getRecentlyConsumedUrl ?? _faker.Internet.Url(),
|
||||
GetMostConsumedUrl: getMostConsumedUrl ?? _faker.Internet.Url(),
|
||||
GetTagConsumptionUrl: getTagConsumptionUrl ?? _faker.Internet.Url(),
|
||||
GetGenreConsumptionUrl: getGenreConsumptionUrl ?? _faker.Internet.Url(),
|
||||
GetLibrariesUrl: getLibrariesUrl ?? _faker.Internet.Url(),
|
||||
GetUsersUrl: getUsersUrl ?? _faker.Internet.Url(),
|
||||
DeleteConsumptionItemHistoryUrl: deleteConsumptionItemHistoryUrl ?? _faker.Internet.Url(),
|
||||
ClearConsumptionHistoryUrl: clearConsumptionHistoryUrl ?? _faker.Internet.Url(),
|
||||
ClearResumePointsUrl: clearResumePointsUrl ?? _faker.Internet.Url()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="StatisticsPageDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="StatisticsPageDto"/> instances.</returns>
|
||||
public List<StatisticsPageDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TagConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagConsumptionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TagConsumptionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional lowercase name of the tag.</param>
|
||||
/// <param name="consumedItemCount">Optional number of distinct consumed media items that carry the tag.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <returns>A configured <see cref="TagConsumptionDto"/> instance.</returns>
|
||||
public TagConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
double? consumedDurationInSeconds = null)
|
||||
{
|
||||
return new TagConsumptionDto(
|
||||
Name: name ?? _faker.Lorem.Word().ToLowerInvariant(),
|
||||
ConsumedItemCount: consumedItemCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TagConsumptionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TagConsumptionDto"/> instances.</returns>
|
||||
public List<TagConsumptionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearConsumptionHistoryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearConsumptionHistoryRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ClearConsumptionHistoryRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose history is deleted.</param>
|
||||
/// <param name="includeUserId">Whether the user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ClearConsumptionHistoryRequest"/> instance.</returns>
|
||||
public ClearConsumptionHistoryRequest Create(
|
||||
string? userId = null,
|
||||
bool includeUserId = true)
|
||||
{
|
||||
return new ClearConsumptionHistoryRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ClearConsumptionHistoryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearConsumptionHistoryRequest"/> instances.</returns>
|
||||
public List<ClearConsumptionHistoryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearResumePointsRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearResumePointsRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ClearResumePointsRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose resume points are deleted.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the deletion to.</param>
|
||||
/// <param name="includeUserId">Whether the 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>
|
||||
/// <returns>A configured <see cref="ClearResumePointsRequest"/> instance.</returns>
|
||||
public ClearResumePointsRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
return new ClearResumePointsRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ClearResumePointsRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearResumePointsRequest"/> instances.</returns>
|
||||
public List<ClearResumePointsRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteConsumptionItemHistoryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteConsumptionItemHistoryRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeleteConsumptionItemHistoryRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose history is deleted.</param>
|
||||
/// <param name="mediaKind">Optional kind of the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the consumed media item.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="includeUserId">Whether the user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="DeleteConsumptionItemHistoryRequest"/> instance.</returns>
|
||||
public DeleteConsumptionItemHistoryRequest Create(
|
||||
string? userId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
Guid? libraryId = null,
|
||||
bool includeUserId = true)
|
||||
{
|
||||
return new DeleteConsumptionItemHistoryRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeleteConsumptionItemHistoryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteConsumptionItemHistoryRequest"/> instances.</returns>
|
||||
public List<DeleteConsumptionItemHistoryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetAllUsersConsumptionStatisticsRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAllUsersConsumptionStatisticsRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetAllUsersConsumptionStatisticsRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the statistics to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the statistics to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</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>A configured <see cref="GetAllUsersConsumptionStatisticsRequest"/> instance.</returns>
|
||||
public GetAllUsersConsumptionStatisticsRequest 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)
|
||||
{
|
||||
return new GetAllUsersConsumptionStatisticsRequest(
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetAllUsersConsumptionStatisticsRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetAllUsersConsumptionStatisticsRequest"/> instances.</returns>
|
||||
public List<GetAllUsersConsumptionStatisticsRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetConsumptionStatisticsRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetConsumptionStatisticsRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetConsumptionStatisticsRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose statistics are retrieved.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the statistics to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the statistics to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</param>
|
||||
/// <param name="includeUserId">Whether the 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>A configured <see cref="GetConsumptionStatisticsRequest"/> instance.</returns>
|
||||
public GetConsumptionStatisticsRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
return new GetConsumptionStatisticsRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetConsumptionStatisticsRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetConsumptionStatisticsRequest"/> instances.</returns>
|
||||
public List<GetConsumptionStatisticsRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetGenreConsumptionRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetGenreConsumptionRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetGenreConsumptionRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose statistics are retrieved.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the statistics to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the statistics to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</param>
|
||||
/// <param name="includeUserId">Whether the 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>A configured <see cref="GetGenreConsumptionRequest"/> instance.</returns>
|
||||
public GetGenreConsumptionRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
return new GetGenreConsumptionRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetGenreConsumptionRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetGenreConsumptionRequest"/> instances.</returns>
|
||||
public List<GetGenreConsumptionRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetMostConsumedRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetMostConsumedRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetMostConsumedRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose history is retrieved.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the history to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the history to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</param>
|
||||
/// <param name="currentPage">Optional one based page of media items to return.</param>
|
||||
/// <param name="perPage">Optional number of media items per page.</param>
|
||||
/// <param name="includeUserId">Whether the 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="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the page size should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="GetMostConsumedRequest"/> instance.</returns>
|
||||
public GetMostConsumedRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetMostConsumedRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 10)) : null,
|
||||
PerPage: includePerPage ? (perPage ?? _faker.Random.Int(1, 100)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetMostConsumedRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetMostConsumedRequest"/> instances.</returns>
|
||||
public List<GetMostConsumedRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetRecentlyConsumedRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRecentlyConsumedRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetRecentlyConsumedRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose history is retrieved.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the history to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the history to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</param>
|
||||
/// <param name="currentPage">Optional one based page of media items to return.</param>
|
||||
/// <param name="perPage">Optional number of media items per page.</param>
|
||||
/// <param name="includeUserId">Whether the 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="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the page size should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="GetRecentlyConsumedRequest"/> instance.</returns>
|
||||
public GetRecentlyConsumedRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetRecentlyConsumedRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 10)) : null,
|
||||
PerPage: includePerPage ? (perPage ?? _faker.Random.Int(1, 100)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetRecentlyConsumedRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetRecentlyConsumedRequest"/> instances.</returns>
|
||||
public List<GetRecentlyConsumedRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Statistics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Statistics;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetTagConsumptionRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTagConsumptionRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetTagConsumptionRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user whose statistics are retrieved.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library to restrict the statistics to.</param>
|
||||
/// <param name="mediaKind">Optional kind of media to restrict the statistics to.</param>
|
||||
/// <param name="fromUtc">Optional inclusive start of the date range.</param>
|
||||
/// <param name="toUtc">Optional inclusive end of the date range.</param>
|
||||
/// <param name="includeUserId">Whether the 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>A configured <see cref="GetTagConsumptionRequest"/> instance.</returns>
|
||||
public GetTagConsumptionRequest Create(
|
||||
string? userId = null,
|
||||
string? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? fromUtc = null,
|
||||
DateTime? toUtc = null,
|
||||
bool includeUserId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeMediaKind = true,
|
||||
bool includeFromUtc = true,
|
||||
bool includeToUtc = true)
|
||||
{
|
||||
return new GetTagConsumptionRequest(
|
||||
UserId: includeUserId ? (userId ?? _faker.Random.Guid().ToString()) : null,
|
||||
LibraryId: includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video)) : null,
|
||||
FromUtc: includeFromUtc ? (fromUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null,
|
||||
ToUtc: includeToUtc ? (toUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31))) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetTagConsumptionRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetTagConsumptionRequest"/> instances.</returns>
|
||||
public List<GetTagConsumptionRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user