Implements tests for commit dfd979ec1e

This commit is contained in:
BinaryAlley committed 2026-10-28 10:07:57 +02:00
1 parent d8adf3c1b6
commit 968061e89a
111 files changed
+19955 -292

No files matched your search

@@ -35,4 +35,5 @@ public sealed record ValidatorUtilitiesTestRequest(
int InclusiveIntValue,
int? InclusiveNullableIntValue,
string? EqualValue,
string? EqualComparisonValue);
string? EqualComparisonValue,
string? TextualEnumValue);
@@ -44,6 +44,7 @@ public class ValidatorUtilitiesTestRequestFixture
/// <param name="inclusiveNullableIntValue">Optional. The nullable integer value that must be between 1 and 10.</param>
/// <param name="equalValue">Optional. The value that must equal the comparison value.</param>
/// <param name="equalComparisonValue">Optional. The comparison value.</param>
/// <param name="textualEnumValue">Optional. The textual enum value that must be a member name of the test enumeration.</param>
/// <returns>A configured <see cref="ValidatorUtilitiesTestRequest"/> instance.</returns>
public ValidatorUtilitiesTestRequest Create(
int? intValue = null,
@@ -70,7 +71,8 @@ public class ValidatorUtilitiesTestRequestFixture
int? inclusiveIntValue = null,
int? inclusiveNullableIntValue = null,
string? equalValue = null,
string? equalComparisonValue = null)
string? equalComparisonValue = null,
string? textualEnumValue = null)
{
string resolvedPattern = patternValue ?? ValidPattern;
return new Faker<ValidatorUtilitiesTestRequest>()
@@ -99,7 +101,8 @@ public class ValidatorUtilitiesTestRequestFixture
InclusiveIntValue: inclusiveIntValue ?? f.Random.Int(1, 10),
InclusiveNullableIntValue: inclusiveNullableIntValue ?? f.Random.Int(1, 10),
EqualValue: equalValue ?? "same",
EqualComparisonValue: equalComparisonValue ?? "same"))
EqualComparisonValue: equalComparisonValue ?? "same",
TextualEnumValue: textualEnumValue ?? f.PickRandom<ValidatorUtilitiesTestEnum>().ToString()))
.Generate();
}
@@ -4,6 +4,7 @@ using Lumina.Application.Core.MediaConsumption.Queries.GetAllUsersConsumptionSta
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
@@ -33,9 +34,9 @@ public class GetAllUsersConsumptionStatisticsQueryFixture
/// Creates a random valid <see cref="GetAllUsersConsumptionStatisticsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
/// <param name="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, 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 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>
@@ -43,22 +44,20 @@ public class GetAllUsersConsumptionStatisticsQueryFixture
/// <returns>The created <see cref="GetAllUsersConsumptionStatisticsQuery"/>.</returns>
public GetAllUsersConsumptionStatisticsQuery Create(
string? libraryId = null,
MediaKind? mediaKind = null,
DateTime? fromUtc = null,
DateTime? toUtc = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
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 GetAllUsersConsumptionStatisticsQuery(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
@@ -4,6 +4,7 @@ using Lumina.Application.Core.MediaConsumption.Queries.GetConsumptionStatistics;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
@@ -34,9 +35,9 @@ public class GetConsumptionStatisticsQueryFixture
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
/// <param name="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, 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 should be included, or forced to <see langword="null"/>.</param>
@@ -46,24 +47,22 @@ public class GetConsumptionStatisticsQueryFixture
public GetConsumptionStatisticsQuery Create(
string? targetUserId = null,
string? libraryId = null,
MediaKind? mediaKind = null,
DateTime? fromUtc = null,
DateTime? toUtc = 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)
{
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
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 GetConsumptionStatisticsQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
@@ -6,6 +6,7 @@ using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
@@ -37,9 +38,9 @@ public class GetMostConsumedQueryFixture
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The kind of media to restrict the history to. Defaults to a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history 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, as a text value.</param>
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
@@ -51,9 +52,9 @@ public class GetMostConsumedQueryFixture
public GetMostConsumedQuery Create(
string? targetUserId = null,
string? libraryId = null,
MediaKind? mediaKind = null,
DateTime? fromUtc = null,
DateTime? toUtc = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
PaginationDataDto? paginationData = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
@@ -62,15 +63,13 @@ public class GetMostConsumedQueryFixture
bool includeToUtc = true,
bool includePaginationData = false)
{
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
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 GetMostConsumedQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null,
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
@@ -6,6 +6,7 @@ using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
@@ -37,9 +38,9 @@ public class GetRecentlyConsumedQueryFixture
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The kind of media to restrict the history to. Defaults to a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history 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, as a text value.</param>
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
@@ -51,9 +52,9 @@ public class GetRecentlyConsumedQueryFixture
public GetRecentlyConsumedQuery Create(
string? targetUserId = null,
string? libraryId = null,
MediaKind? mediaKind = null,
DateTime? fromUtc = null,
DateTime? toUtc = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
PaginationDataDto? paginationData = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
@@ -62,15 +63,13 @@ public class GetRecentlyConsumedQueryFixture
bool includeToUtc = true,
bool includePaginationData = false)
{
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
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 GetRecentlyConsumedQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null,
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
@@ -4,6 +4,7 @@ using Lumina.Application.Core.MediaConsumption.Queries.GetTagConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
@@ -34,9 +35,9 @@ public class GetTagConsumptionQueryFixture
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The kind of media to restrict the statistics to. Defaults to a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded moment in the past.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded moment after the start.</param>
/// <param name="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, 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 should be included, or forced to <see langword="null"/>.</param>
@@ -46,24 +47,22 @@ public class GetTagConsumptionQueryFixture
public GetTagConsumptionQuery Create(
string? targetUserId = null,
string? libraryId = null,
MediaKind? mediaKind = null,
DateTime? fromUtc = null,
DateTime? toUtc = 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)
{
DateTime resolvedFromUtc = fromUtc ?? (toUtc.HasValue
? toUtc.Value.AddDays(-_faker.Random.Int(1, 30))
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)));
DateTime resolvedToUtc = toUtc ?? resolvedFromUtc.AddDays(_faker.Random.Int(1, 30));
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 GetTagConsumptionQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds) : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
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="ClearResumePointsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ClearResumePointsRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ClearResumePointsRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the deletion to. Defaults to a random Id.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ClearResumePointsRequest"/>.</returns>
public ClearResumePointsRequest Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new ClearResumePointsRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null);
}
/// <summary>
/// Creates a list of <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,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.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetAllUsersConsumptionStatisticsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAllUsersConsumptionStatisticsRequestFixture
{
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="GetAllUsersConsumptionStatisticsRequest"/>.
/// </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, 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="GetAllUsersConsumptionStatisticsRequest"/>.</returns>
public GetAllUsersConsumptionStatisticsRequest 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 GetAllUsersConsumptionStatisticsRequest(
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="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,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.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetConsumptionStatisticsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetConsumptionStatisticsRequestFixture
{
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="GetConsumptionStatisticsRequest"/>.
/// </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, 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="GetConsumptionStatisticsRequest"/>.</returns>
public GetConsumptionStatisticsRequest 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 GetConsumptionStatisticsRequest(
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="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,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetMostConsumedRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetMostConsumedRequestFixture
{
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="GetMostConsumedRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="currentPage">Optional. The one based page of media items to return. Defaults to a bounded positive page.</param>
/// <param name="perPage">Optional. The number of media items per page. Defaults to a bounded positive count.</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, 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="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the count per page 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="GetMostConsumedRequest"/>.</returns>
public GetMostConsumedRequest Create(
string? libraryId = null,
string? mediaKind = null,
int? currentPage = null,
int? perPage = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeCurrentPage = true,
bool includePerPage = 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 GetMostConsumedRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeCurrentPage ? currentPage ?? _faker.Random.Int(1, 100) : null,
includePerPage ? perPage ?? _faker.Random.Int(1, 50) : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <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,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetRecentlyConsumedRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRecentlyConsumedRequestFixture
{
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="GetRecentlyConsumedRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="currentPage">Optional. The one based page of media items to return. Defaults to a bounded positive page.</param>
/// <param name="perPage">Optional. The number of media items per page. Defaults to a bounded positive count.</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, 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="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the count per page 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="GetRecentlyConsumedRequest"/>.</returns>
public GetRecentlyConsumedRequest Create(
string? libraryId = null,
string? mediaKind = null,
int? currentPage = null,
int? perPage = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeCurrentPage = true,
bool includePerPage = 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 GetRecentlyConsumedRequest(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeCurrentPage ? currentPage ?? _faker.Random.Int(1, 100) : null,
includePerPage ? perPage ?? _faker.Random.Int(1, 50) : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <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,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.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GetTagConsumptionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTagConsumptionRequestFixture
{
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="GetTagConsumptionRequest"/>.
/// </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, 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="GetTagConsumptionRequest"/>.</returns>
public GetTagConsumptionRequest 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 GetTagConsumptionRequest(
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="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())];
}
}