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:
BinaryAlley committed 2026-10-28 12:27:34 +02:00
1 parent 968061e89a
commit 1afb078efc
91 files changed
+14499 -50

No files matched your search

@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}