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

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