mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDisplayDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDisplayDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteItemDisplayDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="title">Optional. The title of the media item.</param>
|
||||
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
|
||||
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
|
||||
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteItemDisplayDto"/>.</returns>
|
||||
public FavoriteItemDisplayDto Create(
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
Guid? collectionId = null,
|
||||
string? collectionTitle = null,
|
||||
Guid? creatorId = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new FavoriteItemDisplayDto(
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(3),
|
||||
collectionId ?? _faker.Random.Guid(),
|
||||
collectionTitle ?? _faker.Lorem.Sentence(3),
|
||||
creatorId ?? _faker.Random.Guid(),
|
||||
creatorName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteItemDisplayDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDisplayDto"/> instances.</returns>
|
||||
public List<FavoriteItemDisplayDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using Lumina.Application.Common.DTO.Favorites;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Favorites;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDtoFixture
|
||||
{
|
||||
private readonly FavoriteEntityFixture _favoriteEntityFixture = new();
|
||||
private readonly FavoriteItemDisplayDtoFixture _favoriteItemDisplayDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="favorite">Optional. The stored favorite.</param>
|
||||
/// <param name="display">Optional. The display data of the referenced media item.</param>
|
||||
/// <param name="includeDisplay">Whether the display data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteItemDto"/>.</returns>
|
||||
public FavoriteItemDto Create(
|
||||
FavoriteEntity? favorite = null,
|
||||
FavoriteItemDisplayDto? display = null,
|
||||
bool includeDisplay = true)
|
||||
{
|
||||
return new FavoriteItemDto(
|
||||
favorite ?? _favoriteEntityFixture.Create(),
|
||||
includeDisplay ? (display ?? _favoriteItemDisplayDtoFixture.Create()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDto"/> instances.</returns>
|
||||
public List<FavoriteItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Filtering;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BaseFilterDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BaseFilterDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BaseFilterDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
|
||||
/// <returns>The created <see cref="BaseFilterDto"/>.</returns>
|
||||
public BaseFilterDto Create(string? searchTerm = null)
|
||||
{
|
||||
return new BaseFilterDto
|
||||
{
|
||||
SearchTerm = searchTerm ?? _faker.Lorem.Sentence()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BaseFilterDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<BaseFilterDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Filtering;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryFilterDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryFilterDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryFilterDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library used to filter data.</param>
|
||||
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
|
||||
/// <param name="filterAlphaKey">Optional. The alpha key used to filter by the first character of the item title.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the leading "The " prefix should be ignored when computing the alpha key, or not.</param>
|
||||
/// <returns>The created <see cref="LibraryFilterDto"/>.</returns>
|
||||
public LibraryFilterDto Create(
|
||||
Guid? libraryId = null,
|
||||
string? searchTerm = null,
|
||||
string? filterAlphaKey = null,
|
||||
bool shouldIgnoreThePrefixForAlphaPicker = false)
|
||||
{
|
||||
return new LibraryFilterDto
|
||||
{
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
SearchTerm = searchTerm,
|
||||
FilterAlphaKey = filterAlphaKey,
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryFilterDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryFilterDto"/> instances.</returns>
|
||||
public List<LibraryFilterDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
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="AllUsersConsumptionStatisticsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AllUsersConsumptionStatisticsDtoFixture
|
||||
{
|
||||
private readonly ConsumptionTotalsDtoFixture _consumptionTotalsDtoFixture = new();
|
||||
private readonly ConsumptionStatisticsDtoFixture _consumptionStatisticsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AllUsersConsumptionStatisticsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="total">Optional. The combined statistics of every user. Defaults to a random set of totals.</param>
|
||||
/// <param name="users">Optional. The statistics of each user. Defaults to a single random user summary.</param>
|
||||
/// <param name="includeUsers">Whether the user summaries should be included, or forced to an empty list.</param>
|
||||
/// <returns>The created <see cref="AllUsersConsumptionStatisticsDto"/>.</returns>
|
||||
public AllUsersConsumptionStatisticsDto Create(
|
||||
ConsumptionTotalsDto? total = null,
|
||||
IReadOnlyList<ConsumptionStatisticsDto>? users = null,
|
||||
bool includeUsers = true)
|
||||
{
|
||||
IReadOnlyList<ConsumptionStatisticsDto> resolvedUsers = includeUsers
|
||||
? users ?? [_consumptionStatisticsDtoFixture.Create()]
|
||||
: [];
|
||||
|
||||
return new AllUsersConsumptionStatisticsDto(
|
||||
total ?? _consumptionTotalsDtoFixture.Create(),
|
||||
resolvedUsers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <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())];
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumedItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumedItemDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
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="ConsumedItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the consumed media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="isAvailable">Optional. Whether the media item is still available.</param>
|
||||
/// <param name="title">Optional. The title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed.</param>
|
||||
/// <param name="countedSessionCount">Optional. The number of consumption sessions that count towards statistics.</param>
|
||||
/// <param name="completedSessionCount">Optional. The number of consumption sessions that completed.</param>
|
||||
/// <param name="consumedDurationMilliseconds">Optional. The active duration consumed in the media item, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <returns>The created <see cref="ConsumedItemDto"/>.</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,
|
||||
bool includeCoverPath = true,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
long? consumedDurationMilliseconds = null)
|
||||
{
|
||||
return new ConsumedItemDto(
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
isAvailable ?? _faker.Random.Bool(),
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
collectionTitle ?? _faker.Commerce.Department(),
|
||||
creatorName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? coverPath ?? _faker.System.FilePath() : null,
|
||||
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)),
|
||||
countedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
consumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <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())];
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionRecordDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionRecordDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaPositionDtoFixture _mediaPositionDtoFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
private readonly ConsumptionStatus[] _statuses =
|
||||
[
|
||||
ConsumptionStatus.InProgress,
|
||||
ConsumptionStatus.Completed,
|
||||
ConsumptionStatus.Stopped
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ConsumptionRecordDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the consumption record.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="status">Optional. The state of the consumption session. Defaults to a random valid status.</param>
|
||||
/// <param name="startedOnUtc">Optional. The date and time when the session started. Defaults to a moment in the past.</param>
|
||||
/// <param name="lastActivityOnUtc">Optional. The date and time when the session last received activity. Defaults to a moment at or after the start.</param>
|
||||
/// <param name="endedOnUtc">Optional. The date and time when the session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
|
||||
/// <param name="includeEndedOnUtc">Whether the end time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="consumedDurationMilliseconds">Optional. The active duration consumed by the session, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="lastPosition">Optional. The last known position. Defaults to a position matching the position kind of the media kind, and to no position for a photo.</param>
|
||||
/// <param name="includeLastPosition">Whether the last position should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The latest reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a book, and to zero for every other kind.</param>
|
||||
/// <returns>The created <see cref="ConsumptionRecordDto"/>.</returns>
|
||||
public ConsumptionRecordDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
ConsumptionStatus? status = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? lastActivityOnUtc = null,
|
||||
DateTime? endedOnUtc = null,
|
||||
bool includeEndedOnUtc = true,
|
||||
long? consumedDurationMilliseconds = null,
|
||||
MediaPositionDto? lastPosition = null,
|
||||
bool includeLastPosition = true,
|
||||
double? lastProgressFraction = null,
|
||||
int? consecutivePagesRead = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement(_statuses);
|
||||
DateTime resolvedStartedOnUtc = startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
|
||||
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
|
||||
DateTime? resolvedEndedOnUtc = includeEndedOnUtc
|
||||
? endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
|
||||
? null
|
||||
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60)))
|
||||
: null;
|
||||
MediaPositionKind? defaultPositionKind = ResolveDefaultPositionKind(resolvedMediaKind);
|
||||
MediaPositionDto? resolvedLastPosition = includeLastPosition && (lastPosition is not null || defaultPositionKind.HasValue)
|
||||
? lastPosition ?? _mediaPositionDtoFixture.Create(kind: defaultPositionKind)
|
||||
: null;
|
||||
|
||||
return new ConsumptionRecordDto(
|
||||
id ?? _faker.Random.Guid(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
resolvedMediaKind,
|
||||
resolvedStatus,
|
||||
resolvedStartedOnUtc,
|
||||
resolvedLastActivityOnUtc,
|
||||
resolvedEndedOnUtc,
|
||||
consumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
resolvedLastPosition,
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
consecutivePagesRead ?? (resolvedMediaKind == MediaKind.Book ? _faker.Random.Int(0, 100) : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ConsumptionRecordDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionRecordDto"/> instances.</returns>
|
||||
public List<ConsumptionRecordDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the default kind of position used by a media kind.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media.</param>
|
||||
/// <returns>The position kind that a session of the media kind reports, or <see langword="null"/> when the kind carries no position.</returns>
|
||||
private static MediaPositionKind? ResolveDefaultPositionKind(MediaKind mediaKind)
|
||||
{
|
||||
if (mediaKind == MediaKind.Photo)
|
||||
return null;
|
||||
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using System;
|
||||
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="ConsumptionStatisticsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionStatisticsDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionStatisticsDtoFixture _mediaKindConsumptionStatisticsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ConsumptionStatisticsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user the statistics belong to.</param>
|
||||
/// <param name="totalConsumedDurationMilliseconds">Optional. The total consumed duration, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
|
||||
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
|
||||
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
|
||||
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
|
||||
/// <returns>The created <see cref="ConsumptionStatisticsDto"/>.</returns>
|
||||
public ConsumptionStatisticsDto Create(
|
||||
Guid? userId = null,
|
||||
long? totalConsumedDurationMilliseconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto> resolvedMediaKindSummaries = includeMediaKindSummaries
|
||||
? mediaKindSummaries ?? [_mediaKindConsumptionStatisticsDtoFixture.Create()]
|
||||
: [];
|
||||
|
||||
return new ConsumptionStatisticsDto(
|
||||
userId ?? _faker.Random.Guid(),
|
||||
totalConsumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
countedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
stoppedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completionRate ?? _faker.Random.Double(0, 1),
|
||||
resolvedMediaKindSummaries);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ConsumptionStatisticsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionStatisticsDto"/> instances.</returns>
|
||||
public List<ConsumptionStatisticsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#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="ConsumptionTotalsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionTotalsDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionStatisticsDtoFixture _mediaKindConsumptionStatisticsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ConsumptionTotalsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="totalConsumedDurationMilliseconds">Optional. The total consumed duration, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
|
||||
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
|
||||
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
|
||||
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
|
||||
/// <returns>The created <see cref="ConsumptionTotalsDto"/>.</returns>
|
||||
public ConsumptionTotalsDto Create(
|
||||
long? totalConsumedDurationMilliseconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto> resolvedMediaKindSummaries = includeMediaKindSummaries
|
||||
? mediaKindSummaries ?? [_mediaKindConsumptionStatisticsDtoFixture.Create()]
|
||||
: [];
|
||||
|
||||
return new ConsumptionTotalsDto(
|
||||
totalConsumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
countedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
stoppedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completionRate ?? _faker.Random.Double(0, 1),
|
||||
resolvedMediaKindSummaries);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <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())];
|
||||
}
|
||||
}
|
||||
+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.Common.DTO.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
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="MediaKindConsumptionStatisticsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaKindConsumptionStatisticsDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
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="MediaKindConsumptionStatisticsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of media the statistics belong to. Defaults to a random supported kind.</param>
|
||||
/// <param name="totalConsumedDurationMilliseconds">Optional. The total consumed duration of the media kind, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
|
||||
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
|
||||
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
|
||||
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <returns>The created <see cref="MediaKindConsumptionStatisticsDto"/>.</returns>
|
||||
public MediaKindConsumptionStatisticsDto Create(
|
||||
MediaKind? mediaKind = null,
|
||||
long? totalConsumedDurationMilliseconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null)
|
||||
{
|
||||
return new MediaKindConsumptionStatisticsDto(
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
totalConsumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
countedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
stoppedSessionCount ?? _faker.Random.Int(0, 100),
|
||||
completionRate ?? _faker.Random.Double(0, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaKindConsumptionStatisticsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaKindConsumptionStatisticsDto"/> instances.</returns>
|
||||
public List<MediaKindConsumptionStatisticsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.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="MediaPositionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaPositionDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_OFFSET_MILLISECONDS = 7_200_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaPositionKind[] _positionKinds =
|
||||
[
|
||||
MediaPositionKind.TimeOffset,
|
||||
MediaPositionKind.Location
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaPositionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional. The kind of representation used by the position. Defaults to a random valid kind.</param>
|
||||
/// <param name="timeOffsetMilliseconds">Optional. The position within the media item, in milliseconds. Defaults to a bounded random offset for a time offset position.</param>
|
||||
/// <param name="location">Optional. The opaque locator within the media item. Defaults to a random word for a location position.</param>
|
||||
/// <param name="includeTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MediaPositionDto"/>.</returns>
|
||||
public MediaPositionDto Create(
|
||||
MediaPositionKind? kind = null,
|
||||
long? timeOffsetMilliseconds = null,
|
||||
string? location = null,
|
||||
bool includeTimeOffsetMilliseconds = true,
|
||||
bool includeLocation = true)
|
||||
{
|
||||
MediaPositionKind resolvedKind = kind ?? _faker.Random.ArrayElement(_positionKinds);
|
||||
bool isTimeOffset = resolvedKind == MediaPositionKind.TimeOffset;
|
||||
long? resolvedTimeOffsetMilliseconds = includeTimeOffsetMilliseconds
|
||||
? timeOffsetMilliseconds ?? (isTimeOffset ? _faker.Random.Long(0, MAXIMUM_OFFSET_MILLISECONDS) : (long?)null)
|
||||
: null;
|
||||
string? resolvedLocation = includeLocation
|
||||
? location ?? (isTimeOffset ? (string?)null : _faker.Lorem.Word())
|
||||
: null;
|
||||
|
||||
return new MediaPositionDto(resolvedKind, resolvedTimeOffsetMilliseconds, resolvedLocation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaPositionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaPositionDto"/> instances.</returns>
|
||||
public List<MediaPositionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ResumePointDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ResumePointDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaPositionDtoFixture _mediaPositionDtoFixture = new();
|
||||
private readonly MediaKind[] _resumableMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ResumePointDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the resume point.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
|
||||
/// <param name="lastPosition">Optional. The position at which the media item can be resumed. Defaults to a position matching the position kind of the media kind.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
|
||||
/// <returns>The created <see cref="ResumePointDto"/>.</returns>
|
||||
public ResumePointDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
MediaPositionDto? lastPosition = null,
|
||||
double? lastProgressFraction = null,
|
||||
DateTime? lastConsumedOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
|
||||
|
||||
return new ResumePointDto(
|
||||
id ?? _faker.Random.Guid(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
resolvedMediaKind,
|
||||
lastPosition ?? _mediaPositionDtoFixture.Create(kind: ResolveDefaultPositionKind(resolvedMediaKind)),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ResumePointDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ResumePointDto"/> instances.</returns>
|
||||
public List<ResumePointDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the default kind of position used by a media kind.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media.</param>
|
||||
/// <returns>The position kind that a resume point of the media kind uses.</returns>
|
||||
private static MediaPositionKind ResolveDefaultPositionKind(MediaKind mediaKind)
|
||||
{
|
||||
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#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="TagConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagConsumptionDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TagConsumptionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The lowercase name of the tag.</param>
|
||||
/// <param name="consumedItemCount">Optional. The number of distinct consumed media items that carry the tag.</param>
|
||||
/// <param name="consumedDurationMilliseconds">Optional. The consumed duration of the media items that carry the tag, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <returns>The created <see cref="TagConsumptionDto"/>.</returns>
|
||||
public TagConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
long? consumedDurationMilliseconds = null)
|
||||
{
|
||||
return new TagConsumptionDto(
|
||||
name ?? _faker.Lorem.Word().ToLowerInvariant(),
|
||||
consumedItemCount ?? _faker.Random.Int(0, 1000),
|
||||
consumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <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())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumLiteRow"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumLiteRowFixture
|
||||
{
|
||||
private const int MINIMUM_RELEASE_YEAR = 1900;
|
||||
private const int MAXIMUM_RELEASE_YEAR = 2026;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the album.</param>
|
||||
/// <param name="releaseYear">Optional. The release year of the album.</param>
|
||||
/// <param name="releaseTypes">Optional. The set of types of the release.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseYear">Whether the release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseTypes">Whether the release types should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AlbumLiteRow"/>.</returns>
|
||||
public AlbumLiteRow Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? totalTracks = null,
|
||||
string? coverPath = null,
|
||||
int? releaseYear = null,
|
||||
List<MusicReleaseType>? releaseTypes = null,
|
||||
bool includeCoverPath = true,
|
||||
bool includeReleaseYear = true,
|
||||
bool includeReleaseTypes = true)
|
||||
{
|
||||
return new AlbumLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Music.Genre(),
|
||||
totalTracks ?? _faker.Random.Int(1, 30),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
includeReleaseYear ? (releaseYear ?? _faker.Random.Int(MINIMUM_RELEASE_YEAR, MAXIMUM_RELEASE_YEAR)) : null,
|
||||
includeReleaseTypes ? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(index => _faker.PickRandom<MusicReleaseType>())]) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AlbumLiteRow"/> instances.</returns>
|
||||
public List<AlbumLiteRow> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistLiteRow"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistLiteRowFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artist.</param>
|
||||
/// <param name="name">Optional. The name of the artist.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the artist.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ArtistLiteRow"/>.</returns>
|
||||
public ArtistLiteRow Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ArtistLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ArtistLiteRow"/> instances.</returns>
|
||||
public List<ArtistLiteRow> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="NormalizedTrackDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class NormalizedTrackDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly NormalizedTrackSegmentDtoFixture _normalizedTrackSegmentDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="NormalizedTrackDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track whose audio the cached entry holds.</param>
|
||||
/// <param name="cacheId">Optional. The opaque identifier of the cached entry that holds the normalized audio.</param>
|
||||
/// <param name="mode">Optional. The way the audio is delivered.</param>
|
||||
/// <param name="container">Optional. The container of the delivered audio.</param>
|
||||
/// <param name="codec">Optional. The codec of the delivered audio.</param>
|
||||
/// <param name="segmentDurationSeconds">Optional. The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the produced and cached audio, in seconds.</param>
|
||||
/// <param name="segments">Optional. The segments that make up the delivered audio, in playback order.</param>
|
||||
/// <param name="includeSegments">Whether the segments should be included, or forced to an empty collection.</param>
|
||||
/// <returns>The created <see cref="NormalizedTrackDto"/>.</returns>
|
||||
public NormalizedTrackDto Create(
|
||||
Guid? trackId = null,
|
||||
string? cacheId = null,
|
||||
PlaybackDeliveryMode? mode = null,
|
||||
string? container = null,
|
||||
string? codec = null,
|
||||
int? segmentDurationSeconds = null,
|
||||
int? durationInSeconds = null,
|
||||
IReadOnlyList<NormalizedTrackSegmentDto>? segments = null,
|
||||
bool includeSegments = true)
|
||||
{
|
||||
int resolvedSegmentDurationSeconds = segmentDurationSeconds ?? _faker.Random.Int(1, 30);
|
||||
List<NormalizedTrackSegmentDto> generatedSegments = [];
|
||||
int generatedSegmentCount = _faker.Random.Int(1, 6);
|
||||
for (int index = 0; index < generatedSegmentCount; index++)
|
||||
generatedSegments.Add(_normalizedTrackSegmentDtoFixture.Create(
|
||||
index: index,
|
||||
startSeconds: index * resolvedSegmentDurationSeconds,
|
||||
durationSeconds: resolvedSegmentDurationSeconds));
|
||||
|
||||
return new NormalizedTrackDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
cacheId ?? _faker.Random.Guid().ToString("N") + _faker.Random.Guid().ToString("N"),
|
||||
mode ?? _faker.PickRandom(PlaybackDeliveryMode.Remux, PlaybackDeliveryMode.Transcode),
|
||||
container ?? _faker.PickRandom("MP3", "AAC", "FLAC", "WAV", "OGG"),
|
||||
codec ?? _faker.PickRandom("MP3", "AAC", "FLAC", "PCM", "OPUS"),
|
||||
resolvedSegmentDurationSeconds,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
includeSegments ? (segments ?? generatedSegments) : []);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="NormalizedTrackDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="NormalizedTrackDto"/> instances.</returns>
|
||||
public List<NormalizedTrackDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="NormalizedTrackRequestDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class NormalizedTrackRequestDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="NormalizedTrackRequestDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track whose audio is normalized.</param>
|
||||
/// <param name="userId">Optional. The Id of the user whose request starts the production.</param>
|
||||
/// <param name="sourcePath">Optional. The file system path of the stored audio file of the track.</param>
|
||||
/// <param name="allowedRoots">Optional. The content locations the source path is allowed to be inside.</param>
|
||||
/// <param name="sourceContainer">Optional. The container of the stored audio file, as captured by the probe.</param>
|
||||
/// <param name="mode">Optional. The way the audio is delivered.</param>
|
||||
/// <param name="container">Optional. The container of the delivered audio.</param>
|
||||
/// <param name="codec">Optional. The codec of the delivered audio.</param>
|
||||
/// <param name="segmentDurationSeconds">Optional. The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="bitrate">Optional. The stored audio bitrate of the track, in kbps.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the stored audio of the track, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the stored audio of the track.</param>
|
||||
/// <param name="quality">Optional. The quality cap applied to the delivered audio when it has to be re-encoded.</param>
|
||||
/// <param name="sourceLength">Optional. The length the source file had when the delivery was declared, in bytes.</param>
|
||||
/// <param name="sourceLastModifiedUtc">Optional. The last modification time the source file had when the delivery was declared.</param>
|
||||
/// <param name="includeSourceContainer">Whether the source container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="NormalizedTrackRequestDto"/>.</returns>
|
||||
public NormalizedTrackRequestDto Create(
|
||||
Guid? trackId = null,
|
||||
Guid? userId = null,
|
||||
string? sourcePath = null,
|
||||
IReadOnlyList<string>? allowedRoots = null,
|
||||
string? sourceContainer = null,
|
||||
PlaybackDeliveryMode? mode = null,
|
||||
string? container = null,
|
||||
string? codec = null,
|
||||
int? segmentDurationSeconds = null,
|
||||
int? durationInSeconds = null,
|
||||
int? bitrate = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
PlaybackStreamingQuality? quality = null,
|
||||
long? sourceLength = null,
|
||||
DateTime? sourceLastModifiedUtc = null,
|
||||
bool includeSourceContainer = true,
|
||||
bool includeBitrate = true,
|
||||
bool includeBitDepth = true)
|
||||
{
|
||||
IReadOnlyList<string> resolvedAllowedRoots = allowedRoots ?? [Path.Combine(Path.GetTempPath(), "lumina-tests", _faker.Random.AlphaNumeric(12))];
|
||||
string resolvedSourcePath = sourcePath ?? (resolvedAllowedRoots.Count > 0
|
||||
? Path.Combine(resolvedAllowedRoots[0], "track-" + _faker.Random.AlphaNumeric(8) + ".flac")
|
||||
: Path.Combine(Path.GetTempPath(), "track-" + _faker.Random.AlphaNumeric(8) + ".flac"));
|
||||
|
||||
return new NormalizedTrackRequestDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
userId ?? _faker.Random.Guid(),
|
||||
resolvedSourcePath,
|
||||
resolvedAllowedRoots,
|
||||
includeSourceContainer ? (sourceContainer ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "WAV")) : null,
|
||||
mode ?? _faker.PickRandom(PlaybackDeliveryMode.Remux, PlaybackDeliveryMode.Transcode),
|
||||
container ?? _faker.PickRandom("MP3", "AAC", "FLAC", "WAV", "OGG"),
|
||||
codec ?? _faker.PickRandom("MP3", "AAC", "FLAC", "PCM", "OPUS"),
|
||||
segmentDurationSeconds ?? _faker.Random.Int(1, 30),
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null,
|
||||
sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
|
||||
channels ?? _faker.PickRandom(1, 2, 6),
|
||||
includeBitDepth ? (bitDepth ?? _faker.Random.Int(16, 24)) : null,
|
||||
quality ?? _faker.PickRandom<PlaybackStreamingQuality>(),
|
||||
sourceLength ?? _faker.Random.Long(1, 100_000_000),
|
||||
sourceLastModifiedUtc ?? _faker.Date.Past().ToUniversalTime());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="NormalizedTrackRequestDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="NormalizedTrackRequestDto"/> instances.</returns>
|
||||
public List<NormalizedTrackRequestDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="NormalizedTrackSegmentDataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class NormalizedTrackSegmentDataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="NormalizedTrackSegmentDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="content">Optional. The read stream over the segment. When it is not supplied, a fresh empty <see cref="MemoryStream"/> is created.</param>
|
||||
/// <param name="length">Optional. The length of the segment, in bytes.</param>
|
||||
/// <param name="startSeconds">Optional. The exact start of the segment on the track timeline, in seconds.</param>
|
||||
/// <param name="container">Optional. The container of the delivered audio.</param>
|
||||
/// <param name="segmentCount">Optional. The number of segments the production holds.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the produced normalized audio, in seconds.</param>
|
||||
/// <returns>The created <see cref="NormalizedTrackSegmentDataDto"/>.</returns>
|
||||
public NormalizedTrackSegmentDataDto Create(
|
||||
Stream? content = null,
|
||||
long? length = null,
|
||||
decimal? startSeconds = null,
|
||||
string? container = null,
|
||||
int? segmentCount = null,
|
||||
int? durationInSeconds = null)
|
||||
{
|
||||
return new NormalizedTrackSegmentDataDto(
|
||||
content ?? new MemoryStream(),
|
||||
length ?? _faker.Random.Long(1, 10_000_000),
|
||||
startSeconds ?? _faker.Random.Decimal(0, 3600),
|
||||
container ?? _faker.PickRandom("MP3", "AAC", "FLAC", "WAV", "OGG"),
|
||||
segmentCount ?? _faker.Random.Int(1, 1000),
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="NormalizedTrackSegmentDataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="NormalizedTrackSegmentDataDto"/> instances.</returns>
|
||||
public List<NormalizedTrackSegmentDataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="NormalizedTrackSegmentDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class NormalizedTrackSegmentDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="NormalizedTrackSegmentDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="index">Optional. The zero based position of the segment in the delivered audio.</param>
|
||||
/// <param name="startSeconds">Optional. The time, in seconds from the start of the track, at which the segment starts.</param>
|
||||
/// <param name="durationSeconds">Optional. The duration of the segment, in seconds.</param>
|
||||
/// <param name="length">Optional. The length of the segment, in bytes.</param>
|
||||
/// <returns>The created <see cref="NormalizedTrackSegmentDto"/>.</returns>
|
||||
public NormalizedTrackSegmentDto Create(
|
||||
int? index = null,
|
||||
decimal? startSeconds = null,
|
||||
decimal? durationSeconds = null,
|
||||
long? length = null)
|
||||
{
|
||||
return new NormalizedTrackSegmentDto(
|
||||
index ?? _faker.Random.Int(0, 1000),
|
||||
startSeconds ?? _faker.Random.Decimal(0, 3600),
|
||||
durationSeconds ?? _faker.Random.Decimal(1, 30),
|
||||
length ?? _faker.Random.Long(1, 10_000_000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="NormalizedTrackSegmentDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="NormalizedTrackSegmentDto"/> instances.</returns>
|
||||
public List<NormalizedTrackSegmentDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackCapabilityDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackCapabilityDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackCapabilityDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="container">Optional. The container the player can demux.</param>
|
||||
/// <param name="codec">Optional. The codec the player can decode.</param>
|
||||
/// <returns>The created <see cref="PlaybackCapabilityDto"/>.</returns>
|
||||
public PlaybackCapabilityDto Create(
|
||||
string? container = null,
|
||||
string? codec = null)
|
||||
{
|
||||
return new PlaybackCapabilityDto(
|
||||
container ?? _faker.Random.AlphaNumeric(4).ToUpperInvariant(),
|
||||
codec ?? _faker.Random.AlphaNumeric(4).ToUpperInvariant());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackCapabilityDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaybackCapabilityDto"/> instances.</returns>
|
||||
public List<PlaybackCapabilityDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackDeliveryDecisionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackDeliveryDecisionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackDeliveryDecisionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="mode">Optional. The way the audio is delivered.</param>
|
||||
/// <param name="container">Optional. The container of the delivered audio.</param>
|
||||
/// <param name="codec">Optional. The codec of the delivered audio.</param>
|
||||
/// <param name="shape">Optional. The shape the delivered audio is addressed and seeked by.</param>
|
||||
/// <param name="segmentDurationSeconds">Optional. The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <returns>The created <see cref="PlaybackDeliveryDecisionDto"/>.</returns>
|
||||
public PlaybackDeliveryDecisionDto Create(
|
||||
PlaybackDeliveryMode? mode = null,
|
||||
string? container = null,
|
||||
string? codec = null,
|
||||
PlaybackDeliveryShape? shape = null,
|
||||
int? segmentDurationSeconds = null)
|
||||
{
|
||||
PlaybackDeliveryShape resolvedShape = shape ?? _faker.PickRandom<PlaybackDeliveryShape>();
|
||||
return new PlaybackDeliveryDecisionDto(
|
||||
mode ?? _faker.PickRandom(PlaybackDeliveryMode.Remux, PlaybackDeliveryMode.Transcode),
|
||||
container ?? _faker.PickRandom("MP3", "AAC", "FLAC", "WAV", "OGG"),
|
||||
codec ?? _faker.PickRandom("MP3", "AAC", "FLAC", "PCM", "OPUS"),
|
||||
resolvedShape,
|
||||
segmentDurationSeconds ?? (resolvedShape == PlaybackDeliveryShape.TimeAddressedSegments ? _faker.Random.Int(1, 30) : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackDeliveryDecisionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaybackDeliveryDecisionDto"/> instances.</returns>
|
||||
public List<PlaybackDeliveryDecisionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackDeliveryHandleDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackDeliveryHandleDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly NormalizedTrackRequestDtoFixture _normalizedTrackRequestDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackDeliveryHandleDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">Optional. The complete normalization request the delivery declares.</param>
|
||||
/// <param name="shape">Optional. The shape the delivered audio is addressed by.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the library the track belongs to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that owns the album.</param>
|
||||
/// <returns>The created <see cref="PlaybackDeliveryHandleDto"/>.</returns>
|
||||
public PlaybackDeliveryHandleDto Create(
|
||||
NormalizedTrackRequestDto? request = null,
|
||||
PlaybackDeliveryShape? shape = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? albumId = null,
|
||||
Guid? artistId = null)
|
||||
{
|
||||
return new PlaybackDeliveryHandleDto(
|
||||
request ?? _normalizedTrackRequestDtoFixture.Create(),
|
||||
shape ?? _faker.PickRandom<PlaybackDeliveryShape>(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
albumId ?? _faker.Random.Guid(),
|
||||
artistId ?? _faker.Random.Guid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackDeliveryHandleDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaybackDeliveryHandleDto"/> instances.</returns>
|
||||
public List<PlaybackDeliveryHandleDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackSourceFormatDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackSourceFormatDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackSourceFormatDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="codec">Optional. The codec of the audio of the track.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCodec">Whether the codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaybackSourceFormatDto"/>.</returns>
|
||||
public PlaybackSourceFormatDto Create(
|
||||
string? container = null,
|
||||
string? codec = null,
|
||||
bool includeContainer = true,
|
||||
bool includeCodec = true)
|
||||
{
|
||||
return new PlaybackSourceFormatDto(
|
||||
includeContainer ? (container ?? _faker.Random.AlphaNumeric(4).ToUpperInvariant()) : null,
|
||||
includeCodec ? (codec ?? _faker.Random.AlphaNumeric(4).ToUpperInvariant()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackSourceFormatDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaybackSourceFormatDto"/> instances.</returns>
|
||||
public List<PlaybackSourceFormatDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ShuffleTrackRowDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ShuffleTrackRowFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ShuffleTrackRowDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ShuffleTrackRowDto"/>.</returns>
|
||||
public ShuffleTrackRowDto Create(
|
||||
Guid? trackId = null,
|
||||
string? title = null,
|
||||
int? durationInSeconds = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
Guid? artistId = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ShuffleTrackRowDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
durationInSeconds ?? _faker.Random.Int(1, 7200),
|
||||
albumId ?? _faker.Random.Guid(),
|
||||
albumTitle ?? _faker.Lorem.Sentence(),
|
||||
artistId ?? _faker.Random.Guid(),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FileName("jpg")) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ShuffleTrackRowDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ShuffleTrackRowDto"/> instances.</returns>
|
||||
public List<ShuffleTrackRowDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackAccessSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackAccessSummaryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackAccessSummaryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackCount">Optional. The number of distinct requested tracks that exist.</param>
|
||||
/// <param name="libraryIds">Optional. The Ids of the media libraries that contain those tracks. Defaults to a single random library.</param>
|
||||
/// <returns>The created <see cref="TrackAccessSummaryDto"/>.</returns>
|
||||
public TrackAccessSummaryDto Create(
|
||||
int? trackCount = null,
|
||||
IReadOnlyList<Guid>? libraryIds = null)
|
||||
{
|
||||
return new TrackAccessSummaryDto(
|
||||
trackCount ?? 1,
|
||||
libraryIds ?? [Guid.NewGuid()]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackAccessSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackAccessSummaryDto"/> instances.</returns>
|
||||
public List<TrackAccessSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackLiteRow"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackLiteRowFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
|
||||
/// <returns>The created <see cref="TrackLiteRow"/>.</returns>
|
||||
public TrackLiteRow Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
bool includeDiscNumber = true,
|
||||
int? durationInSeconds = null)
|
||||
{
|
||||
return new TrackLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
trackNumber ?? _faker.Random.Int(1, 30),
|
||||
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 600));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackLiteRow"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackLiteRow"/> instances.</returns>
|
||||
public List<TrackLiteRow> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackPlaybackManifestDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackPlaybackManifestDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackPlaybackManifestDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The file system path of the stored audio file of the track.</param>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used by the audio file of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio of the track, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio of the track.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio of the track, in kbps.</param>
|
||||
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak of the track.</param>
|
||||
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak of the track.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGain">Whether the ReplayGain values should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TrackPlaybackManifestDto"/>.</returns>
|
||||
public TrackPlaybackManifestDto Create(
|
||||
string? path = null,
|
||||
string? container = null,
|
||||
string? audioCodec = null,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
int? bitrate = null,
|
||||
decimal? replayGainTrackGain = null,
|
||||
decimal? replayGainTrackPeak = null,
|
||||
decimal? replayGainAlbumGain = null,
|
||||
decimal? replayGainAlbumPeak = null,
|
||||
bool includeContainer = true,
|
||||
bool includeAudioCodec = true,
|
||||
bool includeBitDepth = true,
|
||||
bool includeBitrate = true,
|
||||
bool includeReplayGain = true)
|
||||
{
|
||||
return new TrackPlaybackManifestDto(
|
||||
path ?? Path.Combine(_faker.System.DirectoryPath(), _faker.System.FileName("flac")),
|
||||
includeContainer ? (container ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV")) : null,
|
||||
includeAudioCodec ? (audioCodec ?? _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC", "PCM")) : null,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
|
||||
channels ?? _faker.PickRandom(1, 2, 6),
|
||||
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
|
||||
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null,
|
||||
includeReplayGain ? (replayGainTrackGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
includeReplayGain ? (replayGainTrackPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null,
|
||||
includeReplayGain ? (replayGainAlbumGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
includeReplayGain ? (replayGainAlbumPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackPlaybackManifestDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackPlaybackManifestDto"/> instances.</returns>
|
||||
public List<TrackPlaybackManifestDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackStreamDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackStreamDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackStreamDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The file system path of the track.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that owns the album the track belongs to.</param>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used by the audio file of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio of the track, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio of the track.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio of the track, in kbps.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TrackStreamDto"/>.</returns>
|
||||
public TrackStreamDto Create(
|
||||
string? path = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? albumId = null,
|
||||
Guid? artistId = null,
|
||||
string? container = null,
|
||||
string? audioCodec = null,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
int? bitrate = null,
|
||||
bool includeContainer = true,
|
||||
bool includeAudioCodec = true,
|
||||
bool includeBitDepth = true,
|
||||
bool includeBitrate = true)
|
||||
{
|
||||
return new TrackStreamDto(
|
||||
path ?? Path.Combine(_faker.System.DirectoryPath(), _faker.System.FileName("flac")),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
albumId ?? Guid.NewGuid(),
|
||||
artistId ?? Guid.NewGuid(),
|
||||
includeContainer ? (container ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV")) : null,
|
||||
includeAudioCodec ? (audioCodec ?? _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC", "PCM")) : null,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
|
||||
channels ?? _faker.PickRandom(1, 2, 6),
|
||||
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
|
||||
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackStreamDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackStreamDto"/> instances.</returns>
|
||||
public List<TrackStreamDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathTemplatePartDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathTemplatePartDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryPathTemplatePartDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional. The kind of the path part.</param>
|
||||
/// <param name="representation">Optional. The literal text or the value mask of the path part.</param>
|
||||
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
|
||||
/// <returns>The created <see cref="LibraryPathTemplatePartDto"/>.</returns>
|
||||
public LibraryPathTemplatePartDto Create(
|
||||
string? kind = null,
|
||||
string? representation = null,
|
||||
bool isOptional = false)
|
||||
{
|
||||
return new LibraryPathTemplatePartDto(
|
||||
kind ?? "Artist",
|
||||
representation ?? "{0}",
|
||||
isOptional);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryPathTemplatePartDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryPathTemplatePartDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryProviderSelectionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryProviderSelectionDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryProviderSelectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the provider or reader.</param>
|
||||
/// <param name="isEnabled">Whether the provider or reader is enabled.</param>
|
||||
/// <param name="includeIsEnabled">Whether the choice carries an enabled state. When <see langword="false"/>, the enabled state is <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="LibraryProviderSelectionDto"/>.</returns>
|
||||
public LibraryProviderSelectionDto Create(
|
||||
Guid? pluginId = null,
|
||||
bool isEnabled = true,
|
||||
bool includeIsEnabled = true)
|
||||
{
|
||||
return new LibraryProviderSelectionDto(
|
||||
pluginId ?? Guid.NewGuid(),
|
||||
includeIsEnabled ? isEnabled : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryProviderSelectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryProviderSelectionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookLiteRow"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLiteRowFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookLiteRow"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="releaseYear">Optional. The release year of the book.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover image of the book.</param>
|
||||
/// <returns>The created <see cref="BookLiteRow"/>.</returns>
|
||||
public BookLiteRow Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? releaseYear = null,
|
||||
string? coverPath = null)
|
||||
{
|
||||
return new BookLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
releaseYear,
|
||||
coverPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookLiteRow"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookLiteRow"/> instances.</returns>
|
||||
public List<BookLiteRow> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedResultDto{TData}"/> record.
|
||||
/// </summary>
|
||||
/// <typeparam name="TData">The type of the data items contained in the paginated result.</typeparam>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedResultDtoFixture<TData>
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PaginatedResultDto{TData}"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The collection of data items.</param>
|
||||
/// <param name="currentPage">Optional. The current page number.</param>
|
||||
/// <param name="perPage">Optional. The number of items per page.</param>
|
||||
/// <param name="count">Optional. The total number of elements available.</param>
|
||||
/// <param name="numberOfPages">Optional. The total number of pages.</param>
|
||||
/// <returns>The created <see cref="PaginatedResultDto{TData}"/>.</returns>
|
||||
public PaginatedResultDto<TData> Create(
|
||||
IReadOnlyList<TData>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedResultDto<TData>
|
||||
{
|
||||
Data = data ?? [],
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 100),
|
||||
Count = count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PaginatedResultDto{TData}"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedResultDto{TData}"/> instances.</returns>
|
||||
public List<PaginatedResultDto<TData>> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginationDataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginationDataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PaginationDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="currentPage">Optional. The current page number in a paginated collection.</param>
|
||||
/// <param name="perPage">Optional. The number of items to include per page in paginated results.</param>
|
||||
/// <returns>The created <see cref="PaginationDataDto"/>.</returns>
|
||||
public PaginationDataDto Create(
|
||||
int? currentPage = null,
|
||||
int? perPage = null)
|
||||
{
|
||||
return new PaginationDataDto
|
||||
{
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 100),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 200)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PaginationDataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginationDataDto"/> instances.</returns>
|
||||
public List<PaginationDataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistBulkAddResultDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistBulkAddResultDtoFixture
|
||||
{
|
||||
private const long MAXIMUM_RANDOM_POSITION = 1_000_000_000L;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistBulkAddResultDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="firstPosition">Optional. The sparse order key of the first appended entry. Defaults to a bounded random key.</param>
|
||||
/// <param name="addedCount">Optional. The number of entries appended. Defaults to a bounded random count.</param>
|
||||
/// <returns>The created <see cref="PlaylistBulkAddResultDto"/>.</returns>
|
||||
public PlaylistBulkAddResultDto Create(
|
||||
long? firstPosition = null,
|
||||
int? addedCount = null)
|
||||
{
|
||||
return new PlaylistBulkAddResultDto(
|
||||
firstPosition ?? _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION),
|
||||
addedCount ?? _faker.Random.Int(0, 1_000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistBulkAddResultDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistBulkAddResultDto"/> instances.</returns>
|
||||
public List<PlaylistBulkAddResultDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsDtoFixture
|
||||
{
|
||||
private readonly PlaylistEntityFixture _playlistEntityFixture = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PlaylistEntryDto> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistDetailsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlist">Optional. The stored playlist.</param>
|
||||
/// <param name="entries">Optional. The requested page of entries. Defaults to a page of random entries.</param>
|
||||
/// <returns>The created <see cref="PlaylistDetailsDto"/>.</returns>
|
||||
public PlaylistDetailsDto Create(
|
||||
PlaylistEntity? playlist = null,
|
||||
PaginatedResultDto<PlaylistEntryDto>? entries = null)
|
||||
{
|
||||
List<PlaylistEntryDto> entryDtos = _playlistEntryDtoFixture.CreateMany();
|
||||
return new PlaylistDetailsDto(
|
||||
playlist ?? _playlistEntityFixture.Create(),
|
||||
entries ?? _paginatedResultDtoFixture.Create(data: entryDtos, count: entryDtos.Count));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDisplayDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDisplayDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_SECONDS = 36_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryDisplayDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track.</param>
|
||||
/// <param name="trackTitle">Optional. The title of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track, in seconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the track.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album that contains the track.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album that contains the track.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that produced the track.</param>
|
||||
/// <param name="artistName">Optional. The name of the artist that produced the track.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryDisplayDto"/>.</returns>
|
||||
public PlaylistEntryDisplayDto Create(
|
||||
Guid? trackId = null,
|
||||
string? trackTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
Guid? artistId = null,
|
||||
string? artistName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new PlaylistEntryDisplayDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
trackTitle ?? _faker.Lorem.Sentence(3),
|
||||
durationInSeconds ?? _faker.Random.Int(0, MAXIMUM_DURATION_SECONDS),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
albumId ?? _faker.Random.Guid(),
|
||||
albumTitle ?? _faker.Lorem.Sentence(3),
|
||||
artistId ?? _faker.Random.Guid(),
|
||||
artistName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryDisplayDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDisplayDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDisplayDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryEntityFixture _playlistEntryEntityFixture = new();
|
||||
private readonly PlaylistEntryDisplayDtoFixture _playlistEntryDisplayDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="entry">Optional. The stored playlist entry.</param>
|
||||
/// <param name="display">Optional. The display data of the referenced media item.</param>
|
||||
/// <param name="displayPosition">Optional. The dense zero based position shown to the client.</param>
|
||||
/// <param name="includeDisplay">Whether the display data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryDto"/>.</returns>
|
||||
public PlaylistEntryDto Create(
|
||||
PlaylistEntryEntity? entry = null,
|
||||
PlaylistEntryDisplayDto? display = null,
|
||||
int? displayPosition = null,
|
||||
bool includeDisplay = true)
|
||||
{
|
||||
return new PlaylistEntryDto(
|
||||
entry ?? _playlistEntryEntityFixture.Create(),
|
||||
includeDisplay ? (display ?? _playlistEntryDisplayDtoFixture.Create()) : null,
|
||||
displayPosition ?? _faker.Random.Int(0, 1_000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistSummaryDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_ENTRY_COUNT = 10_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistSummaryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
|
||||
/// <param name="entryCount">Optional. The number of entries of the playlist. Defaults to a bounded random count.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date and time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistSummaryDto"/>.</returns>
|
||||
public PlaylistSummaryDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
int? entryCount = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = false)
|
||||
{
|
||||
return new PlaylistSummaryDto(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
type ?? PlaylistType.Music,
|
||||
entryCount ?? _faker.Random.Int(0, MAXIMUM_ENTRY_COUNT),
|
||||
createdOnUtc ?? _faker.Date.Past(),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistSummaryDto"/> instances.</returns>
|
||||
public List<PlaylistSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PermissionEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PermissionEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PermissionEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The permission Id.</param>
|
||||
/// <param name="permissionName">Optional. The permission name.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the permission.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the permission was created.</param>
|
||||
/// <returns>The created <see cref="PermissionEntity"/>.</returns>
|
||||
public PermissionEntity Create(
|
||||
Guid? id = null,
|
||||
AuthorizationPermission? permissionName = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? createdOnUtc = null)
|
||||
{
|
||||
return new Faker<PermissionEntity>()
|
||||
.RuleFor(x => x.Id, f => id ?? f.Random.Guid())
|
||||
.RuleFor(x => x.PermissionName, f => permissionName ?? f.PickRandom<AuthorizationPermission>())
|
||||
.RuleFor(x => x.RolePermissions, [])
|
||||
.RuleFor(x => x.UserPermissions, [])
|
||||
.RuleFor(x => x.CreatedOnUtc, f => createdOnUtc ?? f.Date.Past())
|
||||
.RuleFor(x => x.CreatedBy, f => createdBy ?? f.Random.Guid())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.RuleFor(x => x.UpdatedBy, f => f.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PermissionEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PermissionEntity"/> instances.</returns>
|
||||
public List<PermissionEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RoleEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RoleEntityFixture
|
||||
{
|
||||
private readonly RolePermissionEntityFixture _rolePermissionEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RoleEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the role.</param>
|
||||
/// <param name="roleName">Optional. The name of the role.</param>
|
||||
/// <param name="rolePermissions">Optional. The role permission associations of the role.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the role.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the role was added.</param>
|
||||
/// <param name="includeRolePermissions">Whether the role permission associations should be included, or forced to an empty collection.</param>
|
||||
/// <returns>The created <see cref="RoleEntity"/>.</returns>
|
||||
public RoleEntity Create(
|
||||
Guid? id = null,
|
||||
string? roleName = null,
|
||||
IEnumerable<RolePermissionEntity>? rolePermissions = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
bool includeRolePermissions = false)
|
||||
{
|
||||
return new Faker<RoleEntity>()
|
||||
.CustomInstantiator(faker => new RoleEntity
|
||||
{
|
||||
Id = id ?? faker.Random.Guid(),
|
||||
RoleName = roleName ?? faker.Random.String2(faker.Random.Number(1, 50)),
|
||||
RolePermissions = includeRolePermissions ? (rolePermissions ?? _rolePermissionEntityFixture.CreateMany()).ToList() : [],
|
||||
CreatedOnUtc = createdOnUtc ?? faker.Date.Past(),
|
||||
CreatedBy = createdBy ?? faker.Random.Guid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RoleEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RoleEntity"/> instances.</returns>
|
||||
public List<RoleEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RolePermissionEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RolePermissionEntityFixture
|
||||
{
|
||||
// RoleEntityFixture composes this fixture, so the role fixture is resolved lazily to avoid an eager mutual composition cycle.
|
||||
private readonly Lazy<RoleEntityFixture> _roleEntityFixture = new();
|
||||
private readonly PermissionEntityFixture _permissionEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RolePermissionEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the role permission association.</param>
|
||||
/// <param name="roleId">Optional. The Id of the role the permission is granted to.</param>
|
||||
/// <param name="role">Optional. The role the permission is granted to.</param>
|
||||
/// <param name="permissionId">Optional. The Id of the permission granted to the role.</param>
|
||||
/// <param name="permission">Optional. The permission granted to the role.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the association was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the association.</param>
|
||||
/// <returns>The created <see cref="RolePermissionEntity"/>.</returns>
|
||||
public RolePermissionEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? roleId = null,
|
||||
RoleEntity? role = null,
|
||||
Guid? permissionId = null,
|
||||
PermissionEntity? permission = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
RoleEntity resolvedRole = role ?? _roleEntityFixture.Value.Create(id: roleId);
|
||||
PermissionEntity resolvedPermission = permission ?? _permissionEntityFixture.Create(id: permissionId);
|
||||
|
||||
return new Faker<RolePermissionEntity>()
|
||||
.CustomInstantiator(f => new RolePermissionEntity
|
||||
{
|
||||
Id = id ?? f.Random.Guid(),
|
||||
RoleId = resolvedRole.Id,
|
||||
Role = role ?? resolvedRole,
|
||||
PermissionId = resolvedPermission.Id,
|
||||
Permission = permission ?? resolvedPermission,
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid(),
|
||||
UpdatedOnUtc = f.Date.Recent(),
|
||||
UpdatedBy = f.Random.Guid()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RolePermissionEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RolePermissionEntity"/> instances.</returns>
|
||||
public List<RolePermissionEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserAuthorizationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserAuthorizationEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid authorization entity.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The user Id to use. If null, a random GUID will be generated.</param>
|
||||
/// <param name="isAdmin">Whether the user should have admin role.</param>
|
||||
/// <param name="role">Optional. The role associated to the user. If null, it is derived from the <paramref name="isAdmin"/> flag.</param>
|
||||
/// <param name="permissions">Optional. The permissions associated to the user. If null, a default set is generated.</param>
|
||||
/// <returns>The created entity.</returns>
|
||||
public UserAuthorizationEntity Create(
|
||||
Guid? userId = null,
|
||||
bool isAdmin = false,
|
||||
string? role = null,
|
||||
IReadOnlySet<AuthorizationPermission>? permissions = null)
|
||||
{
|
||||
string resolvedRole = role ?? (isAdmin ? "Admin" : string.Empty);
|
||||
|
||||
return new UserAuthorizationEntity
|
||||
{
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
Role = resolvedRole,
|
||||
Permissions = permissions ?? new HashSet<AuthorizationPermission>
|
||||
{
|
||||
AuthorizationPermission.CanViewUsers,
|
||||
AuthorizationPermission.CanRegisterUsers
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserAuthorizationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="isAdmin">Whether the users should have admin role.</param>
|
||||
/// <returns>List of configured <see cref="UserAuthorizationEntity"/> instances.</returns>
|
||||
public List<UserAuthorizationEntity> CreateMany(int count = 3, bool isAdmin = false)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(isAdmin: isAdmin))];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserPermissionEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserPermissionEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserPermissionEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="user">The user the permission is granted to.</param>
|
||||
/// <param name="permission">The permission granted to the user.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the association was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the association.</param>
|
||||
/// <returns>The created <see cref="UserPermissionEntity"/>.</returns>
|
||||
public UserPermissionEntity Create(
|
||||
UserEntity user,
|
||||
PermissionEntity permission,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
return new Faker<UserPermissionEntity>()
|
||||
.CustomInstantiator(f => new UserPermissionEntity
|
||||
{
|
||||
Id = f.Random.Guid(),
|
||||
UserId = user.Id,
|
||||
User = user,
|
||||
PermissionId = permission.Id,
|
||||
Permission = permission,
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? user.Id,
|
||||
UpdatedOnUtc = f.Random.Bool() ? f.Date.Recent() : null,
|
||||
UpdatedBy = f.Random.Bool() ? user.Id : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserRoleEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserRoleEntityFixture
|
||||
{
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly RoleEntityFixture _roleEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserRoleEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the user role association.</param>
|
||||
/// <param name="userId">Optional. The Id of the user the role is granted to.</param>
|
||||
/// <param name="user">Optional. The user the role is granted to.</param>
|
||||
/// <param name="roleId">Optional. The Id of the role granted to the user.</param>
|
||||
/// <param name="role">Optional. The role granted to the user.</param>
|
||||
/// <param name="includeUser">Whether the user should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the association was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the association.</param>
|
||||
/// <returns>The created <see cref="UserRoleEntity"/>.</returns>
|
||||
public UserRoleEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
UserEntity? user = null,
|
||||
Guid? roleId = null,
|
||||
RoleEntity? role = null,
|
||||
bool includeUser = true,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
UserEntity resolvedUser = user ?? _userEntityFixture.Create(id: userId);
|
||||
RoleEntity resolvedRole = role ?? _roleEntityFixture.Create(id: roleId);
|
||||
|
||||
return new Faker<UserRoleEntity>()
|
||||
.CustomInstantiator(f => new UserRoleEntity
|
||||
{
|
||||
Id = id ?? f.Random.Guid(),
|
||||
UserId = resolvedUser.Id,
|
||||
User = includeUser ? (user ?? resolvedUser) : null!,
|
||||
RoleId = resolvedRole.Id,
|
||||
Role = role ?? resolvedRole,
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserRoleEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserRoleEntity"/> instances.</returns>
|
||||
public List<UserRoleEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GenreEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the genre.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GenreEntity"/>.</returns>
|
||||
public GenreEntity Create(
|
||||
string? name = null,
|
||||
bool includeName = true)
|
||||
{
|
||||
return new GenreEntity(includeName ? name ?? _faker.UniqueName() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GenreEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TagEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the tag.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TagEntity"/>.</returns>
|
||||
public TagEntity Create(
|
||||
string? name = null,
|
||||
bool includeName = true)
|
||||
{
|
||||
return new TagEntity(includeName ? name ?? _faker.UniqueName() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TagEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the favorite.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the favorite.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the favorite was created. Defaults to a moment in the past.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the favorite was last updated. Defaults to a moment at or after the creation date.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteEntity"/>.</returns>
|
||||
public FavoriteEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
|
||||
|
||||
return new FavoriteEntity
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
UserId = userId ?? _faker.Random.Guid(),
|
||||
MediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
MediaItemId = mediaItemId ?? _faker.Random.Guid(),
|
||||
CreatedOnUtc = resolvedCreatedOnUtc,
|
||||
CreatedBy = createdBy ?? _faker.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? resolvedCreatedOnUtc.AddMinutes(_faker.Random.Int(0, 120))) : null,
|
||||
UpdatedBy = includeUpdatedBy ? (updatedBy ?? _faker.Random.Guid()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteEntity"/> instances.</returns>
|
||||
public List<FavoriteEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionRecordEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionRecordEntityFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_MILLISECONDS = 36_000_000;
|
||||
private const int MAXIMUM_OFFSET_MILLISECONDS = 7_200_000;
|
||||
|
||||
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
|
||||
];
|
||||
private readonly ConsumptionStatus[] _statuses =
|
||||
[
|
||||
ConsumptionStatus.InProgress,
|
||||
ConsumptionStatus.Completed,
|
||||
ConsumptionStatus.Stopped
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionRecordEntity"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every default produced here is accepted by the conversion of the entity to its domain aggregate: the status and end time agree, the last
|
||||
/// activity never precedes the start, the end never precedes the last activity, consecutive pages are only counted for a book, and a generated
|
||||
/// position always uses the position kind of its media kind. Supplying contradicting values is allowed, so that the invalid branches of the
|
||||
/// conversion can be exercised.
|
||||
/// </remarks>
|
||||
/// <param name="id">Optional. The Id of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that started the session.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
|
||||
/// <param name="status">Optional. The state of the session. Defaults to a random valid status.</param>
|
||||
/// <param name="startedOnUtc">Optional. The date and time when the session started. Defaults to a moment in the past, or before the last activity when it is supplied.</param>
|
||||
/// <param name="lastActivityOnUtc">Optional. The date and time when the session last received activity. Defaults to a moment at or after the start.</param>
|
||||
/// <param name="endedOnUtc">Optional. The date and time when the session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
|
||||
/// <param name="consumedDurationMilliseconds">Optional. The active duration consumed by the session, in milliseconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="lastPositionKind">Optional. The kind of the last known position. Defaults to no position for a photo, a location for a book, and a time offset for every other kind.</param>
|
||||
/// <param name="lastPositionTimeOffsetMilliseconds">Optional. The last known position, in milliseconds. Defaults to a bounded random offset for a time offset position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="lastPositionLocation">Optional. The last known opaque locator. Defaults to a random word for a location position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The latest reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a book, and to zero for every other kind.</param>
|
||||
/// <param name="version">Optional. The optimistic concurrency version of the row. Defaults to a bounded random positive version.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the row was created. Defaults to the start of the session.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the row was last updated. Defaults to no value.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row. Defaults to <see langword="null"/>.</param>
|
||||
/// <param name="includeEndedOnUtc">Whether the end time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionRecordEntity"/>.</returns>
|
||||
public MediaConsumptionRecordEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
Guid? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
ConsumptionStatus? status = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? lastActivityOnUtc = null,
|
||||
DateTime? endedOnUtc = null,
|
||||
long? consumedDurationMilliseconds = null,
|
||||
MediaPositionKind? lastPositionKind = null,
|
||||
long? lastPositionTimeOffsetMilliseconds = null,
|
||||
string? lastPositionLocation = null,
|
||||
double? lastProgressFraction = null,
|
||||
int? consecutivePagesRead = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null,
|
||||
bool includeEndedOnUtc = true,
|
||||
bool includeLastPositionKind = true,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
bool includeLastPositionLocation = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement(_statuses);
|
||||
DateTime resolvedStartedOnUtc = startedOnUtc ?? (lastActivityOnUtc.HasValue
|
||||
? lastActivityOnUtc.Value.AddMinutes(-_faker.Random.Int(0, 120))
|
||||
: DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59)));
|
||||
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
|
||||
DateTime? resolvedEndedOnUtc = includeEndedOnUtc
|
||||
? endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
|
||||
? null
|
||||
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60)))
|
||||
: null;
|
||||
MediaPositionKind? resolvedLastPositionKind = includeLastPositionKind
|
||||
? lastPositionKind ?? ResolveDefaultPositionKind(resolvedMediaKind)
|
||||
: null;
|
||||
long? resolvedLastPositionTimeOffsetMilliseconds = includeLastPositionTimeOffsetMilliseconds
|
||||
? lastPositionTimeOffsetMilliseconds ?? (resolvedLastPositionKind == MediaPositionKind.TimeOffset
|
||||
? _faker.Random.Long(0, MAXIMUM_OFFSET_MILLISECONDS)
|
||||
: (long?)null)
|
||||
: null;
|
||||
string? resolvedLastPositionLocation = includeLastPositionLocation
|
||||
? lastPositionLocation ?? (resolvedLastPositionKind == MediaPositionKind.Location
|
||||
? _faker.Lorem.Word()
|
||||
: (string?)null)
|
||||
: null;
|
||||
|
||||
return new MediaConsumptionRecordEntity
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
UserId = userId ?? _faker.Random.Guid(),
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
MediaKind = resolvedMediaKind,
|
||||
MediaItemId = mediaItemId ?? _faker.Random.Guid(),
|
||||
Status = resolvedStatus,
|
||||
StartedOnUtc = resolvedStartedOnUtc,
|
||||
LastActivityOnUtc = resolvedLastActivityOnUtc,
|
||||
EndedOnUtc = resolvedEndedOnUtc,
|
||||
ConsumedDurationMilliseconds = consumedDurationMilliseconds ?? _faker.Random.Long(0, MAXIMUM_DURATION_MILLISECONDS),
|
||||
LastPositionKind = resolvedLastPositionKind,
|
||||
LastPositionTimeOffsetMilliseconds = resolvedLastPositionTimeOffsetMilliseconds,
|
||||
LastPositionLocation = resolvedLastPositionLocation,
|
||||
LastProgressFraction = lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
ConsecutivePagesRead = consecutivePagesRead ?? (resolvedMediaKind == MediaKind.Book ? _faker.Random.Int(0, 100) : 0),
|
||||
Version = version ?? _faker.Random.Long(1, 1000),
|
||||
CreatedOnUtc = createdOnUtc ?? resolvedStartedOnUtc,
|
||||
CreatedBy = createdBy ?? _faker.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? updatedOnUtc : null,
|
||||
UpdatedBy = includeUpdatedBy ? updatedBy : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaConsumptionRecordEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaConsumptionRecordEntity"/> instances.</returns>
|
||||
public List<MediaConsumptionRecordEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the default kind of position used by a media kind.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media.</param>
|
||||
/// <returns>The position kind that a session of the media kind reports, or <see langword="null"/> when the kind carries no position.</returns>
|
||||
private static MediaPositionKind? ResolveDefaultPositionKind(MediaKind mediaKind)
|
||||
{
|
||||
if (mediaKind == MediaKind.Photo)
|
||||
return null;
|
||||
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaResumePointEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaResumePointEntityFixture
|
||||
{
|
||||
private const int MAXIMUM_OFFSET_MILLISECONDS = 7_200_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKind[] _resumableMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaResumePointEntity"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every default produced here is accepted by the conversion of the entity to its domain aggregate: the media kind can be resumed, the progress
|
||||
/// fraction stays within its boundaries, and a generated position always uses the position kind of its media kind. Supplying contradicting values is
|
||||
/// allowed, so that the invalid branches of the conversion can be exercised.
|
||||
/// </remarks>
|
||||
/// <param name="id">Optional. The Id of the resume point.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the resume point.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
|
||||
/// <param name="lastPositionKind">Optional. The kind of the position at which the media item can be resumed. Defaults to a location for a book, and to a time offset for every other kind.</param>
|
||||
/// <param name="lastPositionTimeOffsetMilliseconds">Optional. The position, in milliseconds. Defaults to a bounded random offset for a time offset position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="lastPositionLocation">Optional. The opaque locator. Defaults to a random word for a location position, and to <see langword="null"/> otherwise.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
|
||||
/// <param name="version">Optional. The optimistic concurrency version of the row. Defaults to a bounded random positive version.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the row was created. Defaults to the last consumption time.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the row was last updated. Defaults to no value.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row. Defaults to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionTimeOffsetMilliseconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MediaResumePointEntity"/>.</returns>
|
||||
public MediaResumePointEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
Guid? libraryId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
MediaPositionKind? lastPositionKind = null,
|
||||
long? lastPositionTimeOffsetMilliseconds = null,
|
||||
string? lastPositionLocation = null,
|
||||
double? lastProgressFraction = null,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null,
|
||||
bool includeLastPositionTimeOffsetMilliseconds = true,
|
||||
bool includeLastPositionLocation = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
|
||||
MediaPositionKind resolvedLastPositionKind = lastPositionKind ?? ResolveDefaultPositionKind(resolvedMediaKind);
|
||||
long? resolvedLastPositionTimeOffsetMilliseconds = includeLastPositionTimeOffsetMilliseconds
|
||||
? lastPositionTimeOffsetMilliseconds ?? (resolvedLastPositionKind == MediaPositionKind.TimeOffset
|
||||
? _faker.Random.Long(0, MAXIMUM_OFFSET_MILLISECONDS)
|
||||
: (long?)null)
|
||||
: null;
|
||||
string? resolvedLastPositionLocation = includeLastPositionLocation
|
||||
? lastPositionLocation ?? (resolvedLastPositionKind == MediaPositionKind.Location
|
||||
? _faker.Lorem.Word()
|
||||
: (string?)null)
|
||||
: null;
|
||||
DateTime resolvedLastConsumedOnUtc = lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720));
|
||||
|
||||
return new MediaResumePointEntity
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
UserId = userId ?? _faker.Random.Guid(),
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
MediaKind = resolvedMediaKind,
|
||||
MediaItemId = mediaItemId ?? _faker.Random.Guid(),
|
||||
LastPositionKind = resolvedLastPositionKind,
|
||||
LastPositionTimeOffsetMilliseconds = resolvedLastPositionTimeOffsetMilliseconds,
|
||||
LastPositionLocation = resolvedLastPositionLocation,
|
||||
LastProgressFraction = lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
LastConsumedOnUtc = resolvedLastConsumedOnUtc,
|
||||
Version = version ?? _faker.Random.Long(1, 1000),
|
||||
CreatedOnUtc = createdOnUtc ?? resolvedLastConsumedOnUtc,
|
||||
CreatedBy = createdBy ?? _faker.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? updatedOnUtc : null,
|
||||
UpdatedBy = includeUpdatedBy ? updatedBy : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaResumePointEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaResumePointEntity"/> instances.</returns>
|
||||
public List<MediaResumePointEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the default kind of position used by a media kind.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media.</param>
|
||||
/// <returns>The position kind that a resume point of the media kind uses.</returns>
|
||||
private static MediaPositionKind ResolveDefaultPositionKind(MediaKind mediaKind)
|
||||
{
|
||||
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="displayName">Optional. The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">Optional. The legal name of the contributor.</param>
|
||||
/// <param name="biography">Optional. The biography of the contributor.</param>
|
||||
/// <param name="dateOfBirth">Optional. The date of birth of the contributor.</param>
|
||||
/// <param name="dateOfDeath">Optional. The date of death of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributorEntity"/>.</returns>
|
||||
public MediaContributorEntity Create(
|
||||
Guid? id = null,
|
||||
string? displayName = null,
|
||||
string? legalName = null,
|
||||
string? biography = null,
|
||||
DateOnly? dateOfBirth = null,
|
||||
DateOnly? dateOfDeath = null)
|
||||
{
|
||||
return new MediaContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
DisplayName = displayName ?? _faker.Person.FullName,
|
||||
LegalName = legalName ?? _faker.Person.FullName,
|
||||
Biography = biography ?? _faker.Lorem.Sentence(),
|
||||
DateOfBirth = dateOfBirth ?? _faker.DateOnlyBetween(new DateOnly(1900, 1, 1), new DateOnly(2000, 12, 31)),
|
||||
DateOfDeath = dateOfDeath,
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorEntity"/> instances.</returns>
|
||||
public List<MediaContributorEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumCatalogNumberEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumCatalogNumberEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumCatalogNumberEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="catalogNumber">Optional. The catalog number assigned by the label.</param>
|
||||
/// <returns>The created <see cref="AlbumCatalogNumberEntity"/>.</returns>
|
||||
public AlbumCatalogNumberEntity Create(
|
||||
string? catalogNumber = null)
|
||||
{
|
||||
return new AlbumCatalogNumberEntity(catalogNumber ?? _faker.Random.String2(_faker.Random.Number(1, 50)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumCatalogNumberEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AlbumCatalogNumberEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the participation.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the contributor participated in.</param>
|
||||
/// <param name="mediaContributorId">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played in the album.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the participation.</param>
|
||||
/// <returns>The created <see cref="AlbumContributorEntity"/>.</returns>
|
||||
public AlbumContributorEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? albumId = null,
|
||||
Guid? mediaContributorId = null,
|
||||
MediaContributorRole? role = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
return new AlbumContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
AlbumId = albumId ?? Guid.NewGuid(),
|
||||
MediaContributorId = mediaContributorId ?? Guid.NewGuid(),
|
||||
Role = role ?? _faker.PickRandom<MediaContributorRole>(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = createdBy ?? Guid.NewGuid(),
|
||||
UpdatedOnUtc = _faker.Random.Bool() ? _faker.Date.Recent() : null,
|
||||
UpdatedBy = _faker.Random.Bool() ? Guid.NewGuid() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the contributors participated in.</param>
|
||||
/// <returns>List of configured <see cref="AlbumContributorEntity"/> instances.</returns>
|
||||
public List<AlbumContributorEntity> CreateMany(int count = 3, Guid? albumId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(albumId: albumId))];
|
||||
}
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly TrackEntityFixture _trackEntityFixture = new();
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
private readonly AlbumReleaseTypeEntityFixture _albumReleaseTypeEntityFixture = new();
|
||||
private readonly AlbumCatalogNumberEntityFixture _albumCatalogNumberEntityFixture = new();
|
||||
private readonly AlbumContributorEntityFixture _albumContributorEntityFixture = new();
|
||||
private readonly AudioRatingEntityFixture _audioRatingEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that owns the album.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that owns the album.</param>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="tracks">Optional. The tracks of the album.</param>
|
||||
/// <param name="originalReleaseDate">Optional. The original release date of the album.</param>
|
||||
/// <param name="originalReleaseYear">Optional. The original release year of the album.</param>
|
||||
/// <param name="reReleaseDate">Optional. The re-release date of the album.</param>
|
||||
/// <param name="reReleaseYear">Optional. The re-release year of the album.</param>
|
||||
/// <param name="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the album.</param>
|
||||
/// <param name="description">Optional. A brief description or summary of the album.</param>
|
||||
/// <param name="languageCode">Optional. The language code of the album.</param>
|
||||
/// <param name="languageName">Optional. The language name of the album.</param>
|
||||
/// <param name="languageNativeName">Optional. The language native name of the album.</param>
|
||||
/// <param name="originalLanguageCode">Optional. The original language code of the album.</param>
|
||||
/// <param name="originalLanguageName">Optional. The original language name of the album.</param>
|
||||
/// <param name="originalLanguageNativeName">Optional. The original language native name of the album.</param>
|
||||
/// <param name="releaseType">Optional. The release type of the album.</param>
|
||||
/// <param name="releaseStatus">Optional. The release status of the album.</param>
|
||||
/// <param name="totalDiscs">Optional. The total number of discs of the album.</param>
|
||||
/// <param name="mediaFormat">Optional. The media format of the album.</param>
|
||||
/// <param name="catalogNumbers">Optional. The catalog numbers of the album.</param>
|
||||
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz release identifier of the album.</param>
|
||||
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz release group identifier of the album.</param>
|
||||
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz release artist identifier of the album.</param>
|
||||
/// <param name="isDeleted">Whether the album is soft deleted.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the album was deleted.</param>
|
||||
/// <param name="includeTracks">Whether the album should own a generated track, or no track at all.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, Contributors, Ratings) should be included, or forced to empty collections.</param>
|
||||
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReReleaseDate">Whether the re-release date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReReleaseYear">Whether the re-release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLanguage">Whether the language of the album should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalLanguage">Whether the original language of the album should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseType">Whether the release type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseStatus">Whether the release status should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTotalDiscs">Whether the total number of discs should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release identifier should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group identifier should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist identifier should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeletedOnUtc">Whether a deleted album should carry a deletion time, or <see langword="null"/>.</param>
|
||||
/// <param name="metadataStatus">Optional. The metadata enrichment status of the album.</param>
|
||||
/// <returns>The created <see cref="AlbumEntity"/>.</returns>
|
||||
public AlbumEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? artistId = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
List<TrackEntity>? tracks = null,
|
||||
DateOnly? originalReleaseDate = null,
|
||||
int? originalReleaseYear = null,
|
||||
DateOnly? reReleaseDate = null,
|
||||
int? reReleaseYear = null,
|
||||
string? barcode = null,
|
||||
string? originalTitle = null,
|
||||
string? description = null,
|
||||
string? languageCode = null,
|
||||
string? languageName = null,
|
||||
string? languageNativeName = null,
|
||||
string? originalLanguageCode = null,
|
||||
string? originalLanguageName = null,
|
||||
string? originalLanguageNativeName = null,
|
||||
MusicReleaseType? releaseType = null,
|
||||
MusicReleaseStatus? releaseStatus = null,
|
||||
int? totalDiscs = null,
|
||||
MusicMediaFormat? mediaFormat = null,
|
||||
List<string>? catalogNumbers = null,
|
||||
Guid? musicBrainzReleaseId = null,
|
||||
Guid? musicBrainzReleaseGroupId = null,
|
||||
Guid? musicBrainzReleaseArtistId = null,
|
||||
bool isDeleted = false,
|
||||
DateTime? deletedOnUtc = null,
|
||||
bool includeTracks = true,
|
||||
bool includeMetadata = true,
|
||||
bool includeOriginalReleaseDate = true,
|
||||
bool includeOriginalReleaseYear = true,
|
||||
bool includeReReleaseDate = true,
|
||||
bool includeReReleaseYear = true,
|
||||
bool includeBarcode = true,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeDescription = true,
|
||||
bool includeLanguage = true,
|
||||
bool includeOriginalLanguage = true,
|
||||
bool includeReleaseType = true,
|
||||
bool includeReleaseStatus = true,
|
||||
bool includeTotalDiscs = true,
|
||||
bool includeMediaFormat = true,
|
||||
bool includeCatalogNumbers = true,
|
||||
bool includeMusicBrainzReleaseId = true,
|
||||
bool includeMusicBrainzReleaseGroupId = true,
|
||||
bool includeMusicBrainzReleaseArtistId = true,
|
||||
bool includeDeletedOnUtc = true,
|
||||
MetadataStatus? metadataStatus = null)
|
||||
{
|
||||
Guid resolvedId = id ?? Guid.NewGuid();
|
||||
Guid resolvedArtistId = artistId ?? Guid.NewGuid();
|
||||
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
|
||||
const int MAXIMUM_RELEASE_YEAR = 2026;
|
||||
int resolvedOriginalReleaseYear = originalReleaseYear ?? Random.Shared.Next(1900, MAXIMUM_RELEASE_YEAR);
|
||||
int resolvedReReleaseYearUpperBound = Math.Max(resolvedOriginalReleaseYear + 1, MAXIMUM_RELEASE_YEAR);
|
||||
int resolvedReReleaseYear = reReleaseYear ?? Random.Shared.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound);
|
||||
DateOnly resolvedOriginalReleaseDate = originalReleaseDate ?? _faker.DateOnlyBetween(new DateOnly(resolvedOriginalReleaseYear, 1, 1), new DateOnly(resolvedOriginalReleaseYear, 12, 31));
|
||||
DateOnly resolvedReReleaseDate = reReleaseDate ?? _faker.DateOnlyBetween(resolvedReReleaseYear == resolvedOriginalReleaseYear ? resolvedOriginalReleaseDate : new DateOnly(resolvedReReleaseYear, 1, 1), new DateOnly(resolvedReReleaseYear, 12, 31));
|
||||
List<TrackEntity> resolvedTracks = tracks ?? (includeTracks ? [_trackEntityFixture.Create(albumId: resolvedId, libraryId: resolvedLibraryId, includeMetadata: includeMetadata, includeOriginalReleaseDate: includeOriginalReleaseDate, includeOriginalReleaseYear: includeOriginalReleaseYear, includeReReleaseDate: includeReReleaseDate, includeReReleaseYear: includeReReleaseYear)] : []);
|
||||
|
||||
return new Faker<AlbumEntity>()
|
||||
.CustomInstantiator(f => new AlbumEntity
|
||||
{
|
||||
Id = resolvedId,
|
||||
ArtistId = resolvedArtistId,
|
||||
LibraryId = resolvedLibraryId,
|
||||
MetadataStatus = metadataStatus ?? MetadataStatus.Pending,
|
||||
Title = default!,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.RuleFor(x => x.Title, f => title ?? f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.OriginalTitle, f => includeOriginalTitle ? (originalTitle ?? f.Random.String2(f.Random.Number(1, 255))) : null)
|
||||
.RuleFor(x => x.ReleaseTitle, f => f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.Description, f => includeDescription ? (description ?? f.Random.String2(f.Random.Number(1, 2000))) : null)
|
||||
.RuleFor(x => x.OriginalReleaseDate, includeOriginalReleaseDate ? resolvedOriginalReleaseDate : (DateOnly?)null)
|
||||
.RuleFor(x => x.OriginalReleaseYear, includeOriginalReleaseYear ? resolvedOriginalReleaseYear : (int?)null)
|
||||
.RuleFor(x => x.ReReleaseDate, includeReReleaseDate ? resolvedReReleaseDate : (DateOnly?)null)
|
||||
.RuleFor(x => x.ReReleaseYear, includeReReleaseYear ? resolvedReReleaseYear : (int?)null)
|
||||
.RuleFor(x => x.ReleaseCountry, f => f.PickRandom<ReleaseCountry>())
|
||||
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.LanguageCode, f => includeLanguage ? (languageCode ?? f.Random.String2(2)) : null)
|
||||
.RuleFor(x => x.LanguageName, f => includeLanguage ? (languageName ?? f.Random.String2(f.Random.Number(1, 50))) : null)
|
||||
.RuleFor(x => x.LanguageNativeName, f => includeLanguage ? (languageNativeName ?? f.Random.String2(f.Random.Number(1, 50))) : null)
|
||||
.RuleFor(x => x.OriginalLanguageCode, f => includeOriginalLanguage ? (originalLanguageCode ?? f.Random.String2(2)) : null)
|
||||
.RuleFor(x => x.OriginalLanguageName, f => includeOriginalLanguage ? (originalLanguageName ?? f.Random.String2(f.Random.Number(1, 50))) : null)
|
||||
.RuleFor(x => x.OriginalLanguageNativeName, f => includeOriginalLanguage ? (originalLanguageNativeName ?? f.Random.String2(f.Random.Number(1, 50))) : null)
|
||||
.RuleFor(x => x.ReleaseTypes, f => includeReleaseType ? [_albumReleaseTypeEntityFixture.Create(releaseType: releaseType)] : [])
|
||||
.RuleFor(x => x.ReleaseStatus, f => includeReleaseStatus ? (releaseStatus ?? f.PickRandom<MusicReleaseStatus>()) : (MusicReleaseStatus?)null)
|
||||
.RuleFor(x => x.TotalDiscs, includeTotalDiscs ? (totalDiscs ?? Random.Shared.Next(1, 3)) : (int?)null)
|
||||
.RuleFor(x => x.TotalTracks, resolvedTracks.Count)
|
||||
.RuleFor(x => x.MediaFormat, f => includeMediaFormat ? (mediaFormat ?? f.PickRandom<MusicMediaFormat>()) : (MusicMediaFormat?)null)
|
||||
.RuleFor(x => x.Barcode, f => includeBarcode ? (barcode ?? f.Random.String2(f.Random.Number(12, 13), "0123456789")) : null)
|
||||
.RuleFor(x => x.CatalogNumbers, f => includeCatalogNumbers ? [.. (catalogNumbers ?? [f.Random.String2(f.Random.Number(1, 50))]).Select(catalogNumber => _albumCatalogNumberEntityFixture.Create(catalogNumber: catalogNumber))] : [])
|
||||
.RuleFor(x => x.MusicBrainzReleaseId, f => includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? f.Random.Guid()) : (Guid?)null)
|
||||
.RuleFor(x => x.MusicBrainzReleaseGroupId, f => includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? f.Random.Guid()) : (Guid?)null)
|
||||
.RuleFor(x => x.MusicBrainzReleaseArtistId, f => includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? f.Random.Guid()) : (Guid?)null)
|
||||
.RuleFor(x => x.Tags, f => includeMetadata ? [.. _tagEntityFixture.CreateMany(f.Random.Number(1, 3))] : [])
|
||||
.RuleFor(x => x.Genres, f => includeMetadata ? [.. _genreEntityFixture.CreateMany(f.Random.Number(1, 3))] : [])
|
||||
.RuleFor(x => x.Contributors, f => includeMetadata ? _albumContributorEntityFixture.CreateMany(f.Random.Number(1, 3), albumId: resolvedId) : [])
|
||||
.RuleFor(x => x.Ratings, f => includeMetadata ? _audioRatingEntityFixture.CreateMany(f.Random.Number(1, 3)) : [])
|
||||
.RuleFor(x => x.Tracks, resolvedTracks)
|
||||
.RuleFor(x => x.IsDeleted, isDeleted)
|
||||
.RuleFor(x => x.DeletedOnUtc, f => isDeleted && includeDeletedOnUtc ? (deletedOnUtc ?? f.Date.Recent()) : null)
|
||||
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AlbumEntity"/> instances.</returns>
|
||||
public List<AlbumEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumReleaseTypeEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumReleaseTypeEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumReleaseTypeEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="releaseType">Optional. The type of the release.</param>
|
||||
/// <returns>The created <see cref="AlbumReleaseTypeEntity"/>.</returns>
|
||||
public AlbumReleaseTypeEntity Create(
|
||||
MusicReleaseType? releaseType = null)
|
||||
{
|
||||
return new AlbumReleaseTypeEntity(releaseType ?? _faker.PickRandom<MusicReleaseType>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumReleaseTypeEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AlbumReleaseTypeEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistAliasEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistAliasEntityFixture
|
||||
{
|
||||
private const int MINIMUM_ALIAS_YEAR = 1900;
|
||||
private const int MAXIMUM_ALIAS_YEAR = 2026;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistAliasEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the alias.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the alias.</param>
|
||||
/// <param name="type">Optional. The type of the alias.</param>
|
||||
/// <param name="locale">Optional. The locale the alias is used in.</param>
|
||||
/// <param name="isPrimary">Optional. Whether this is the primary alias of the artist.</param>
|
||||
/// <param name="beginDate">Optional. The date the alias began being used.</param>
|
||||
/// <param name="endDate">Optional. The date the alias stopped being used.</param>
|
||||
/// <param name="isEnded">Optional. Whether the alias is no longer used.</param>
|
||||
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLocale">Whether the locale should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBeginDate">Whether the begin date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeEndDate">Whether the end date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ArtistAliasEntity"/>.</returns>
|
||||
public ArtistAliasEntity Create(
|
||||
string? name = null,
|
||||
string? sortName = null,
|
||||
string? type = null,
|
||||
string? locale = null,
|
||||
bool? isPrimary = null,
|
||||
DateOnly? beginDate = null,
|
||||
DateOnly? endDate = null,
|
||||
bool? isEnded = null,
|
||||
bool includeSortName = true,
|
||||
bool includeType = true,
|
||||
bool includeLocale = true,
|
||||
bool includeBeginDate = true,
|
||||
bool includeEndDate = true)
|
||||
{
|
||||
int beginYear = Random.Shared.Next(MINIMUM_ALIAS_YEAR, MAXIMUM_ALIAS_YEAR);
|
||||
int endYear = Random.Shared.Next(beginYear, Math.Max(beginYear + 1, MAXIMUM_ALIAS_YEAR));
|
||||
|
||||
return new ArtistAliasEntity(
|
||||
name ?? _faker.Name.FullName(),
|
||||
includeSortName ? (sortName ?? _faker.Name.FullName()) : null,
|
||||
includeType ? (type ?? _faker.Random.ArrayElement(["Artist name", "Search hint"])) : null,
|
||||
includeLocale ? (locale ?? _faker.Random.String2(2)) : null,
|
||||
isPrimary ?? _faker.Random.Bool(),
|
||||
includeBeginDate ? (beginDate ?? new DateOnly(beginYear, 1, 1)) : null,
|
||||
includeEndDate ? (endDate ?? new DateOnly(endYear, 1, 1)) : null,
|
||||
isEnded ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistAliasEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ArtistAliasEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the participation.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the contributor participated in.</param>
|
||||
/// <param name="mediaContributorId">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played in the artist.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the participation.</param>
|
||||
/// <returns>The created <see cref="ArtistContributorEntity"/>.</returns>
|
||||
public ArtistContributorEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? artistId = null,
|
||||
Guid? mediaContributorId = null,
|
||||
MediaContributorRole? role = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
return new ArtistContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
ArtistId = artistId ?? Guid.NewGuid(),
|
||||
MediaContributorId = mediaContributorId ?? Guid.NewGuid(),
|
||||
Role = role ?? _faker.PickRandom<MediaContributorRole>(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = createdBy ?? Guid.NewGuid(),
|
||||
UpdatedOnUtc = _faker.Random.Bool() ? _faker.Date.Recent() : null,
|
||||
UpdatedBy = _faker.Random.Bool() ? Guid.NewGuid() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the contributors participated in.</param>
|
||||
/// <returns>List of configured <see cref="ArtistContributorEntity"/> instances.</returns>
|
||||
public List<ArtistContributorEntity> CreateMany(int count = 3, Guid? artistId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(artistId: artistId))];
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistEntityFixture
|
||||
{
|
||||
private readonly AlbumEntityFixture _albumEntityFixture = new();
|
||||
private readonly ArtistContributorEntityFixture _artistContributorEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artist.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that owns the artist.</param>
|
||||
/// <param name="name">Optional. The name of the artist.</param>
|
||||
/// <param name="website">Optional. The website of the artist.</param>
|
||||
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
|
||||
/// <param name="albums">Optional. The albums of the artist.</param>
|
||||
/// <param name="isDeleted">Whether the artist is soft deleted.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the artist was deleted.</param>
|
||||
/// <param name="includeAlbums">Whether the artist should own a generated album, or no album at all.</param>
|
||||
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz identifier should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContributors">Whether the artist should own a generated media contributor, or none at all.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections of the generated album should be included, or forced to empty collections.</param>
|
||||
/// <param name="includeDeletedOnUtc">Whether a deleted artist should carry a deletion time, or <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ArtistEntity"/>.</returns>
|
||||
public ArtistEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? name = null,
|
||||
string? website = null,
|
||||
Guid? musicBrainzArtistId = null,
|
||||
List<AlbumEntity>? albums = null,
|
||||
bool isDeleted = false,
|
||||
DateTime? deletedOnUtc = null,
|
||||
bool includeAlbums = true,
|
||||
bool includeWebsite = true,
|
||||
bool includeMusicBrainzArtistId = true,
|
||||
bool includeContributors = true,
|
||||
bool includeMetadata = true,
|
||||
bool includeDeletedOnUtc = true)
|
||||
{
|
||||
Guid resolvedId = id ?? Guid.NewGuid();
|
||||
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
|
||||
List<AlbumEntity> resolvedAlbums = albums ?? (includeAlbums ? [_albumEntityFixture.Create(artistId: resolvedId, libraryId: resolvedLibraryId, includeMetadata: includeMetadata)] : []);
|
||||
|
||||
return new Faker<ArtistEntity>()
|
||||
.CustomInstantiator(f => new ArtistEntity
|
||||
{
|
||||
Id = resolvedId,
|
||||
LibraryId = resolvedLibraryId,
|
||||
Name = default!,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.RuleFor(x => x.Name, f => name ?? f.Name.FullName())
|
||||
.RuleFor(x => x.Website, f => includeWebsite ? (website ?? f.Internet.Url()) : null)
|
||||
.RuleFor(x => x.MusicBrainzArtistId, f => includeMusicBrainzArtistId ? (musicBrainzArtistId ?? f.Random.Guid()) : null)
|
||||
.RuleFor(x => x.Albums, resolvedAlbums)
|
||||
.RuleFor(x => x.Contributors, f => includeContributors ? _artistContributorEntityFixture.CreateMany(f.Random.Number(1, 3), artistId: resolvedId) : [])
|
||||
.RuleFor(x => x.IsDeleted, isDeleted)
|
||||
.RuleFor(x => x.DeletedOnUtc, f => isDeleted && includeDeletedOnUtc ? (deletedOnUtc ?? f.Date.Recent()) : null)
|
||||
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ArtistEntity"/> instances.</returns>
|
||||
public List<ArtistEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistIpiEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistIpiEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistIpiEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the IPI code.</param>
|
||||
/// <returns>The created <see cref="ArtistIpiEntity"/>.</returns>
|
||||
public ArtistIpiEntity Create(
|
||||
string? value = null)
|
||||
{
|
||||
return new ArtistIpiEntity(value ?? _faker.Random.String2(_faker.Random.Number(1, 20), "0123456789"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistIpiEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ArtistIpiEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistIsniEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistIsniEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistIsniEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the ISNI code.</param>
|
||||
/// <returns>The created <see cref="ArtistIsniEntity"/>.</returns>
|
||||
public ArtistIsniEntity Create(
|
||||
string? value = null)
|
||||
{
|
||||
return new ArtistIsniEntity(value ?? _faker.Random.String2(_faker.Random.Number(1, 20), "0123456789X"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtistIsniEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ArtistIsniEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudioRatingEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioRatingEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AudioRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The rating value of the audio media element.</param>
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value of the audio media element.</param>
|
||||
/// <param name="source">Optional. The source of the audio rating.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes that contributed to the audio rating.</param>
|
||||
/// <param name="includeValue">Whether the value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMaxValue">Whether the maximum value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSource">Whether the source should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeVoteCount">Whether the vote count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AudioRatingEntity"/>.</returns>
|
||||
public AudioRatingEntity Create(
|
||||
decimal? value = null,
|
||||
decimal? maxValue = null,
|
||||
AudioRatingSource? source = null,
|
||||
int? voteCount = null,
|
||||
bool includeValue = true,
|
||||
bool includeMaxValue = true,
|
||||
bool includeSource = true,
|
||||
bool includeVoteCount = true)
|
||||
{
|
||||
return new AudioRatingEntity(
|
||||
includeValue ? (value ?? _faker.Random.Decimal(1, 5)) : null,
|
||||
includeMaxValue ? (maxValue ?? 5) : null,
|
||||
includeSource ? (source ?? _faker.PickRandom<AudioRatingSource>()) : null,
|
||||
includeVoteCount ? (voteCount ?? _faker.Random.Number(1, 1000)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AudioRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AudioRatingEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicAreaEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAreaEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicAreaEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzAreaId">Optional. The MusicBrainz identifier of the area.</param>
|
||||
/// <param name="name">Optional. The name of the area.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the area.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the area.</param>
|
||||
/// <param name="type">Optional. The MusicBrainz type of the area.</param>
|
||||
/// <param name="iso3166Code">Optional. The ISO 3166 code of the area.</param>
|
||||
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIso3166Code">Whether the ISO 3166 code should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MusicAreaEntity"/>.</returns>
|
||||
public MusicAreaEntity Create(
|
||||
Guid? musicBrainzAreaId = null,
|
||||
string? name = null,
|
||||
string? sortName = null,
|
||||
string? disambiguation = null,
|
||||
string? type = null,
|
||||
string? iso3166Code = null,
|
||||
bool includeSortName = true,
|
||||
bool includeDisambiguation = true,
|
||||
bool includeType = true,
|
||||
bool includeIso3166Code = true)
|
||||
{
|
||||
return new MusicAreaEntity(
|
||||
musicBrainzAreaId ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Address.Country(),
|
||||
includeSortName ? (sortName ?? _faker.Address.Country()) : null,
|
||||
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
|
||||
includeType ? (type ?? _faker.Random.ArrayElement(["Country", "City", "Area"])) : null,
|
||||
includeIso3166Code ? (iso3166Code ?? _faker.Address.CountryCode()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MusicAreaEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<MusicAreaEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicArtworkEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtworkEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicArtworkEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artwork.</param>
|
||||
/// <param name="ownerType">Optional. The type of the music library item that owns the artwork.</param>
|
||||
/// <param name="ownerId">Optional. The Id of the music library item that owns the artwork.</param>
|
||||
/// <param name="artworkType">Optional. The type of the artwork.</param>
|
||||
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
|
||||
/// <param name="fileName">Optional. The relative file name of the stored artwork.</param>
|
||||
/// <param name="contentHash">Optional. The content hash of the stored artwork.</param>
|
||||
/// <param name="status">Optional. The status of the artwork enrichment.</param>
|
||||
/// <param name="provider">Optional. The name of the plugin that resolved the artwork.</param>
|
||||
/// <param name="lastUpdateUtc">Optional. The date and time when the artwork was last resolved.</param>
|
||||
/// <param name="includeFileName">Whether the file name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeProvider">Whether the provider should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastUpdateUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MusicArtworkEntity"/>.</returns>
|
||||
public MusicArtworkEntity Create(
|
||||
Guid? id = null,
|
||||
MusicArtworkOwnerType? ownerType = null,
|
||||
Guid? ownerId = null,
|
||||
ArtworkType? artworkType = null,
|
||||
int? ordinal = null,
|
||||
string? fileName = null,
|
||||
ulong? contentHash = null,
|
||||
ArtworkStatus? status = null,
|
||||
string? provider = null,
|
||||
DateTime? lastUpdateUtc = null,
|
||||
bool includeFileName = true,
|
||||
bool includeProvider = true,
|
||||
bool includeLastUpdateUtc = true)
|
||||
{
|
||||
return new MusicArtworkEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
OwnerType = ownerType ?? _faker.PickRandom<MusicArtworkOwnerType>(),
|
||||
OwnerId = ownerId ?? Guid.NewGuid(),
|
||||
ArtworkType = artworkType ?? _faker.PickRandom<ArtworkType>(),
|
||||
Ordinal = ordinal ?? _faker.Random.Int(0, 5),
|
||||
FileName = includeFileName ? (fileName ?? _faker.System.FilePath()) : null,
|
||||
ContentHash = contentHash ?? (ulong)_faker.Random.ULong(),
|
||||
Status = status ?? _faker.PickRandom<ArtworkStatus>(),
|
||||
Provider = includeProvider ? (provider ?? _faker.Company.CompanyName()) : null,
|
||||
LastUpdateUtc = includeLastUpdateUtc ? (lastUpdateUtc ?? _faker.Date.Recent()) : null,
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MusicArtworkEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtworkEntity"/> instances.</returns>
|
||||
public List<MusicArtworkEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicLibraryScanItemMetadataEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicLibraryScanItemMetadataEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicLibraryScanItemMetadataEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the staged metadata.</param>
|
||||
/// <param name="libraryScanId">Optional. The Id of the media library scan the staged metadata belongs to.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the staged metadata belongs to.</param>
|
||||
/// <param name="path">Optional. The file system path of the music file.</param>
|
||||
/// <param name="artistName">Optional. The name of the artist.</param>
|
||||
/// <param name="releaseName">Optional. The name of the release.</param>
|
||||
/// <param name="trackTitle">Optional. The title of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
|
||||
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
|
||||
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
|
||||
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
|
||||
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
|
||||
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
|
||||
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="workTitle">Optional. The title of the work.</param>
|
||||
/// <param name="includeMusicBrainzTags">Whether the MusicBrainz identifiers and the work title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MusicLibraryScanItemMetadataEntity"/>.</returns>
|
||||
public MusicLibraryScanItemMetadataEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryScanId = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
string? artistName = null,
|
||||
string? releaseName = null,
|
||||
string? trackTitle = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
Guid? musicBrainzArtistId = null,
|
||||
Guid? musicBrainzReleaseArtistId = null,
|
||||
Guid? musicBrainzReleaseGroupId = null,
|
||||
Guid? musicBrainzReleaseId = null,
|
||||
Guid? musicBrainzRecordingId = null,
|
||||
Guid? musicBrainzTrackId = null,
|
||||
Guid? musicBrainzWorkId = null,
|
||||
string? workTitle = null,
|
||||
bool includeMusicBrainzTags = true,
|
||||
bool includeContainer = true)
|
||||
{
|
||||
return new MusicLibraryScanItemMetadataEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryScanId = libraryScanId ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
Path = path ?? _faker.System.FilePath(),
|
||||
ArtistName = artistName ?? _faker.Name.FullName(),
|
||||
ReleaseType = _faker.PickRandom<MusicReleaseType>(),
|
||||
ReleaseYear = Random.Shared.Next(1900, 2026),
|
||||
ReleaseName = releaseName ?? _faker.Music.Genre(),
|
||||
TrackTitle = trackTitle ?? _faker.Music.Genre(),
|
||||
TrackNumber = trackNumber ?? _faker.Random.Int(1, 20),
|
||||
DiscNumber = discNumber ?? _faker.Random.Int(1, 3),
|
||||
DurationInSeconds = Random.Shared.Next(60, 7200),
|
||||
SampleRate = _faker.PickRandom(44100, 48000, 96000),
|
||||
Channels = _faker.PickRandom(1, 2, 6),
|
||||
BitDepth = Random.Shared.Next(8, 32),
|
||||
AudioCodec = _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC"),
|
||||
Container = includeContainer ? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV") : null,
|
||||
Bitrate = Random.Shared.Next(96, 1411),
|
||||
MusicBrainzArtistId = includeMusicBrainzTags ? musicBrainzArtistId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzReleaseArtistId = includeMusicBrainzTags ? musicBrainzReleaseArtistId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzReleaseGroupId = includeMusicBrainzTags ? musicBrainzReleaseGroupId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzReleaseId = includeMusicBrainzTags ? musicBrainzReleaseId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzRecordingId = includeMusicBrainzTags ? musicBrainzRecordingId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzTrackId = includeMusicBrainzTags ? musicBrainzTrackId ?? Guid.NewGuid() : null,
|
||||
MusicBrainzWorkId = includeMusicBrainzTags ? musicBrainzWorkId ?? Guid.NewGuid() : null,
|
||||
WorkTitle = includeMusicBrainzTags ? workTitle ?? _faker.Music.Genre() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MusicLibraryScanItemMetadataEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<MusicLibraryScanItemMetadataEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the participation.</param>
|
||||
/// <param name="trackId">Optional. The Id of the track the contributor participated in.</param>
|
||||
/// <param name="mediaContributorId">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played in the track.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the participation.</param>
|
||||
/// <returns>The created <see cref="TrackContributorEntity"/>.</returns>
|
||||
public TrackContributorEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? trackId = null,
|
||||
Guid? mediaContributorId = null,
|
||||
MediaContributorRole? role = null,
|
||||
Guid? createdBy = null)
|
||||
{
|
||||
return new TrackContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
TrackId = trackId ?? Guid.NewGuid(),
|
||||
MediaContributorId = mediaContributorId ?? Guid.NewGuid(),
|
||||
Role = role ?? _faker.PickRandom<MediaContributorRole>(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = createdBy ?? Guid.NewGuid(),
|
||||
UpdatedOnUtc = _faker.Random.Bool() ? _faker.Date.Recent() : null,
|
||||
UpdatedBy = _faker.Random.Bool() ? Guid.NewGuid() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="trackId">Optional. The Id of the track the contributors participated in.</param>
|
||||
/// <returns>List of configured <see cref="TrackContributorEntity"/> instances.</returns>
|
||||
public List<TrackContributorEntity> CreateMany(int count = 3, Guid? trackId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(trackId: trackId))];
|
||||
}
|
||||
}
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
private readonly TrackMoodEntityFixture _trackMoodEntityFixture = new();
|
||||
private readonly TrackIsrcEntityFixture _trackIsrcEntityFixture = new();
|
||||
private readonly TrackContributorEntityFixture _trackContributorEntityFixture = new();
|
||||
private readonly AudioRatingEntityFixture _audioRatingEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the track.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album that owns the track.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that owns the track.</param>
|
||||
/// <param name="path">Optional. The file system path of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="originalReleaseDate">Optional. The original release date of the track.</param>
|
||||
/// <param name="originalReleaseYear">Optional. The original release year of the track.</param>
|
||||
/// <param name="reReleaseDate">Optional. The re-release date of the track.</param>
|
||||
/// <param name="reReleaseYear">Optional. The re-release year of the track.</param>
|
||||
/// <param name="isDeleted">Whether the track is soft deleted.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the track was deleted.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, Moods, ISRCs, Contributors, Ratings) should be included, or forced to empty collections.</param>
|
||||
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReReleaseDate">Whether the re-release date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReReleaseYear">Whether the re-release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="metadataStatus">Optional. The metadata enrichment status of the track.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec of the track.</param>
|
||||
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak of the track.</param>
|
||||
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak of the track.</param>
|
||||
/// <param name="includeReplayGain">Whether the ReplayGain values should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeletedOnUtc">Whether a deleted track should carry a deletion time, or <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TrackEntity"/>.</returns>
|
||||
public TrackEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? albumId = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
string? title = null,
|
||||
string? container = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
DateOnly? originalReleaseDate = null,
|
||||
int? originalReleaseYear = null,
|
||||
DateOnly? reReleaseDate = null,
|
||||
int? reReleaseYear = null,
|
||||
bool isDeleted = false,
|
||||
DateTime? deletedOnUtc = null,
|
||||
bool includeMetadata = true,
|
||||
bool includeOriginalReleaseDate = true,
|
||||
bool includeOriginalReleaseYear = true,
|
||||
bool includeReReleaseDate = true,
|
||||
bool includeReReleaseYear = true,
|
||||
bool includeContainer = true,
|
||||
MetadataStatus? metadataStatus = null,
|
||||
string? audioCodec = null,
|
||||
bool includeAudioCodec = true,
|
||||
decimal? replayGainTrackGain = null,
|
||||
decimal? replayGainTrackPeak = null,
|
||||
decimal? replayGainAlbumGain = null,
|
||||
decimal? replayGainAlbumPeak = null,
|
||||
bool includeReplayGain = true,
|
||||
bool includeDeletedOnUtc = true)
|
||||
{
|
||||
Guid resolvedId = id ?? Guid.NewGuid();
|
||||
Guid resolvedAlbumId = albumId ?? Guid.NewGuid();
|
||||
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
|
||||
const int MAXIMUM_RELEASE_YEAR = 2026;
|
||||
int resolvedOriginalReleaseYear = originalReleaseYear ?? Random.Shared.Next(1900, MAXIMUM_RELEASE_YEAR);
|
||||
int resolvedReReleaseYearUpperBound = Math.Max(resolvedOriginalReleaseYear + 1, MAXIMUM_RELEASE_YEAR);
|
||||
int resolvedReReleaseYear = reReleaseYear ?? Random.Shared.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound);
|
||||
DateOnly resolvedOriginalReleaseDate = originalReleaseDate ?? _faker.DateOnlyBetween(new DateOnly(resolvedOriginalReleaseYear, 1, 1), new DateOnly(resolvedOriginalReleaseYear, 12, 31));
|
||||
DateOnly resolvedReReleaseDate = reReleaseDate ?? _faker.DateOnlyBetween(resolvedReReleaseYear == resolvedOriginalReleaseYear ? resolvedOriginalReleaseDate : new DateOnly(resolvedReReleaseYear, 1, 1), new DateOnly(resolvedReReleaseYear, 12, 31));
|
||||
|
||||
return new Faker<TrackEntity>()
|
||||
.CustomInstantiator(f => new TrackEntity
|
||||
{
|
||||
Id = resolvedId,
|
||||
AlbumId = resolvedAlbumId,
|
||||
LibraryId = resolvedLibraryId,
|
||||
MetadataStatus = metadataStatus ?? MetadataStatus.Pending,
|
||||
Path = default!,
|
||||
Title = default!,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.RuleFor(x => x.Path, f => path ?? f.System.FilePath())
|
||||
.RuleFor(x => x.Title, f => title ?? f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.OriginalTitle, f => f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.Description, f => f.Random.String2(f.Random.Number(1, 2000)))
|
||||
.RuleFor(x => x.OriginalReleaseDate, includeOriginalReleaseDate ? resolvedOriginalReleaseDate : null)
|
||||
.RuleFor(x => x.OriginalReleaseYear, includeOriginalReleaseYear ? resolvedOriginalReleaseYear : null)
|
||||
.RuleFor(x => x.ReReleaseDate, includeReReleaseDate ? resolvedReReleaseDate : null)
|
||||
.RuleFor(x => x.ReReleaseYear, includeReReleaseYear ? resolvedReReleaseYear : null)
|
||||
.RuleFor(x => x.ReleaseCountry, f => f.PickRandom<ReleaseCountry>())
|
||||
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(x => x.LanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.LanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.OriginalLanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.OriginalLanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.DurationInSeconds, Random.Shared.Next(60, 7200))
|
||||
.RuleFor(x => x.SampleRate, f => f.PickRandom(44100, 48000, 96000))
|
||||
.RuleFor(x => x.Channels, f => f.PickRandom(1, 2, 6))
|
||||
.RuleFor(x => x.BitDepth, Random.Shared.Next(8, 32))
|
||||
.RuleFor(x => x.AudioCodec, f => includeAudioCodec ? (audioCodec ?? f.PickRandom("FLAC", "MP3", "AAC", "ALAC")) : null)
|
||||
.RuleFor(x => x.Container, f => includeContainer ? (container ?? f.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV")) : null)
|
||||
.RuleFor(x => x.ReplayGainTrackGain, f => includeReplayGain ? (replayGainTrackGain ?? f.Random.Decimal(-20m, 0m)) : null)
|
||||
.RuleFor(x => x.ReplayGainTrackPeak, f => includeReplayGain ? (replayGainTrackPeak ?? f.Random.Decimal(0m, 1.5m)) : null)
|
||||
.RuleFor(x => x.ReplayGainAlbumGain, f => includeReplayGain ? (replayGainAlbumGain ?? f.Random.Decimal(-20m, 0m)) : null)
|
||||
.RuleFor(x => x.ReplayGainAlbumPeak, f => includeReplayGain ? (replayGainAlbumPeak ?? f.Random.Decimal(0m, 1.5m)) : null)
|
||||
.RuleFor(x => x.Bitrate, Random.Shared.Next(96, 1411))
|
||||
.RuleFor(x => x.TrackNumber, f => trackNumber ?? f.Random.Int(1, 20))
|
||||
.RuleFor(x => x.DiscNumber, discNumber ?? Random.Shared.Next(1, 3))
|
||||
.RuleFor(x => x.Script, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.Key, f => f.PickRandom<MusicKey>())
|
||||
.RuleFor(x => x.Bpm, Random.Shared.Next(40, 240))
|
||||
.RuleFor(x => x.IsVideo, f => f.Random.Bool())
|
||||
.RuleFor(x => x.WorkTitle, f => f.Music.Genre())
|
||||
.RuleFor(x => x.WorkType, f => f.Music.Genre())
|
||||
.RuleFor(x => x.MusicBrainzRecordingId, f => f.Random.Guid())
|
||||
.RuleFor(x => x.MusicBrainzTrackId, f => f.Random.Guid())
|
||||
.RuleFor(x => x.MusicBrainzWorkId, f => f.Random.Guid())
|
||||
.RuleFor(x => x.Tags, f => includeMetadata ? [.. _tagEntityFixture.CreateMany(f.Random.Number(1, 3))] : [])
|
||||
.RuleFor(x => x.Genres, f => includeMetadata ? [.. _genreEntityFixture.CreateMany(f.Random.Number(1, 3))] : [])
|
||||
.RuleFor(x => x.Moods, f => includeMetadata ? _trackMoodEntityFixture.CreateMany(f.Random.Number(1, 3)) : [])
|
||||
.RuleFor(x => x.Isrcs, f => includeMetadata ? _trackIsrcEntityFixture.CreateMany(f.Random.Number(1, 3)) : [])
|
||||
.RuleFor(x => x.Contributors, f => includeMetadata ? _trackContributorEntityFixture.CreateMany(f.Random.Number(1, 3), trackId: resolvedId) : [])
|
||||
.RuleFor(x => x.Ratings, f => includeMetadata ? _audioRatingEntityFixture.CreateMany(f.Random.Number(1, 3)) : [])
|
||||
.RuleFor(x => x.IsDeleted, isDeleted)
|
||||
.RuleFor(x => x.DeletedOnUtc, f => isDeleted && includeDeletedOnUtc ? (deletedOnUtc ?? f.Date.Recent()) : null)
|
||||
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackEntity"/> instances.</returns>
|
||||
public List<TrackEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackIsrcEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackIsrcEntityFixture
|
||||
{
|
||||
private const string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private const string ALPHANUMERICS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
private const string DIGITS = "0123456789";
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackIsrcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the ISRC.</param>
|
||||
/// <returns>The created <see cref="TrackIsrcEntity"/>.</returns>
|
||||
public TrackIsrcEntity Create(string? value = null)
|
||||
{
|
||||
// ISRC codes follow the domain format: two letters, three alphanumeric characters and seven digits.
|
||||
return new TrackIsrcEntity(value ?? (
|
||||
_faker.Random.String2(2, LETTERS)
|
||||
+ _faker.Random.String2(3, ALPHANUMERICS)
|
||||
+ _faker.Random.String2(7, DIGITS)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackIsrcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TrackIsrcEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackMoodEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackMoodEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackMoodEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the mood.</param>
|
||||
/// <returns>The created <see cref="TrackMoodEntity"/>.</returns>
|
||||
public TrackMoodEntity Create(
|
||||
string? name = null)
|
||||
{
|
||||
return new TrackMoodEntity(name ?? _faker.Lorem.Word());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackMoodEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TrackMoodEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackWorkIswcEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackWorkIswcEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackWorkIswcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the ISWC.</param>
|
||||
/// <returns>The created <see cref="TrackWorkIswcEntity"/>.</returns>
|
||||
public TrackWorkIswcEntity Create(
|
||||
string? value = null)
|
||||
{
|
||||
return new TrackWorkIswcEntity(value ?? $"T{_faker.Random.AlphaNumeric(10)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackWorkIswcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TrackWorkIswcEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackWorkLanguageEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackWorkLanguageEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackWorkLanguageEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="languageCode">Optional. The ISO 639-1 two-letter language code.</param>
|
||||
/// <param name="languageName">Optional. The full name of the language in English.</param>
|
||||
/// <param name="nativeName">Optional. The native name of the language.</param>
|
||||
/// <param name="includeNativeName">Whether the native name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TrackWorkLanguageEntity"/>.</returns>
|
||||
public TrackWorkLanguageEntity Create(
|
||||
string? languageCode = null,
|
||||
string? languageName = null,
|
||||
string? nativeName = null,
|
||||
bool includeNativeName = true)
|
||||
{
|
||||
return new TrackWorkLanguageEntity(
|
||||
languageCode ?? _faker.PickRandom("en", "fr", "de", "es", "it", "ja", "ko", "zh", "pt", "ru"),
|
||||
languageName ?? _faker.Lorem.Word(),
|
||||
includeNativeName ? (nativeName ?? _faker.Lorem.Word()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackWorkLanguageEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TrackWorkLanguageEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DirectoryScanFingerprintEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DirectoryScanFingerprintEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DirectoryScanFingerprintEntity"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the directory scan fingerprint.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library to which the fingerprint belongs.</param>
|
||||
/// <param name="path">Optional path of the directory to which the fingerprint belongs.</param>
|
||||
/// <param name="lastWriteTimeUtc">Optional last write time of the directory, in UTC.</param>
|
||||
/// <returns>A configured <see cref="DirectoryScanFingerprintEntity"/> instance.</returns>
|
||||
public DirectoryScanFingerprintEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
DateTime? lastWriteTimeUtc = null)
|
||||
{
|
||||
return new Faker<DirectoryScanFingerprintEntity>()
|
||||
.CustomInstantiator(faker => new DirectoryScanFingerprintEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
Path = path ?? faker.System.DirectoryPath(),
|
||||
LastWriteTimeUtc = lastWriteTimeUtc ?? faker.Date.Recent()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DirectoryScanFingerprintEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DirectoryScanFingerprintEntity"/> instances.</returns>
|
||||
public List<DirectoryScanFingerprintEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryContentLocationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryContentLocationEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryContentLocationEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The path of the media library content location.</param>
|
||||
/// <returns>The created <see cref="LibraryContentLocationEntity"/>.</returns>
|
||||
public LibraryContentLocationEntity Create(
|
||||
string? path = null)
|
||||
{
|
||||
return new LibraryContentLocationEntity
|
||||
{
|
||||
Path = path ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryContentLocationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryContentLocationEntity"/> instances.</returns>
|
||||
public List<LibraryContentLocationEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryEntityFixture
|
||||
{
|
||||
private readonly LibraryContentLocationEntityFixture _libraryContentLocationEntityFixture = new();
|
||||
private readonly LibraryPathTemplatePartEntityFixture _libraryPathTemplatePartEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the media library.</param>
|
||||
/// <param name="title">Optional. The title of the media library.</param>
|
||||
/// <param name="libraryType">Optional. The type of the media library.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the media library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Whether hidden files and directories should be skipped during a scan or not.</param>
|
||||
/// <param name="isContentOnSsd">Whether the content of the media library is stored on a solid state drive.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="completionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="metadataProvidersConfigurationFingerprint">Optional. The fingerprint of the metadata provider configuration of the media library.</param>
|
||||
/// <param name="artworkProvidersConfigurationFingerprint">Optional. The fingerprint of the artwork provider configuration of the media library.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <param name="pathTemplateFingerprint">Optional. The fingerprint of the path template of the media library.</param>
|
||||
/// <returns>The created media library entity.</returns>
|
||||
public LibraryEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? title = null,
|
||||
LibraryType? libraryType = null,
|
||||
IEnumerable<string>? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
bool shouldSkipHiddenFilesAndDirectoriesDuringScan = false,
|
||||
bool isContentOnSsd = false,
|
||||
bool shouldTrackConsumptionProgress = false,
|
||||
int? completionThresholdPercentage = null,
|
||||
string? metadataProvidersConfigurationFingerprint = null,
|
||||
string? artworkProvidersConfigurationFingerprint = null,
|
||||
IEnumerable<LibraryPathTemplatePartEntity>? pathTemplateParts = null,
|
||||
string? pathTemplateFingerprint = null)
|
||||
{
|
||||
return new Faker<LibraryEntity>()
|
||||
.CustomInstantiator(f => new LibraryEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
Title = default!,
|
||||
CoverImage = default,
|
||||
LibraryType = default,
|
||||
ContentLocations = [],
|
||||
PathTemplateParts = [],
|
||||
LibraryScans = [],
|
||||
IsEnabled = isEnabled,
|
||||
IsLocked = isLocked,
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan,
|
||||
ShouldSkipHiddenFilesAndDirectoriesDuringScan = shouldSkipHiddenFilesAndDirectoriesDuringScan,
|
||||
IsContentOnSsd = isContentOnSsd,
|
||||
ShouldTrackConsumptionProgress = shouldTrackConsumptionProgress,
|
||||
CompletionThresholdPercentage = completionThresholdPercentage,
|
||||
MetadataProvidersConfigurationFingerprint = metadataProvidersConfigurationFingerprint,
|
||||
ArtworkProvidersConfigurationFingerprint = artworkProvidersConfigurationFingerprint,
|
||||
PathTemplateFingerprint = pathTemplateFingerprint,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.RuleFor(library => library.Title, f => title ?? f.Lorem.Word())
|
||||
.RuleFor(library => library.LibraryType, f => libraryType ?? f.PickRandom<LibraryType>())
|
||||
.RuleFor(library => library.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(library => library.ContentLocations, f =>
|
||||
{
|
||||
IEnumerable<string> paths = contentLocations ?? [f.System.DirectoryPath(), f.System.DirectoryPath()];
|
||||
return [.. paths.Select(path => _libraryContentLocationEntityFixture.Create(path: path))];
|
||||
})
|
||||
.RuleFor(library => library.PathTemplateParts, f => pathTemplateParts is null ? [] : [.. pathTemplateParts])
|
||||
.RuleFor(library => library.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(library => library.CreatedBy, f => f.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the created media libraries.</param>
|
||||
/// <returns>List of configured <see cref="LibraryEntity"/> instances.</returns>
|
||||
public List<LibraryEntity> CreateMany(int count = 3, Guid? userId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(userId: userId))];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathTemplatePartEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathTemplatePartEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryPathTemplatePartEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="position">Optional. The zero based position of the part in the path template.</param>
|
||||
/// <param name="kind">Optional. The kind of the path part.</param>
|
||||
/// <param name="representation">Optional. The literal text or the value mask of the path part.</param>
|
||||
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
|
||||
/// <returns>The created <see cref="LibraryPathTemplatePartEntity"/>.</returns>
|
||||
public LibraryPathTemplatePartEntity Create(
|
||||
int? position = null,
|
||||
LibraryPathPartKind? kind = null,
|
||||
string? representation = null,
|
||||
bool isOptional = false)
|
||||
{
|
||||
return new Faker<LibraryPathTemplatePartEntity>()
|
||||
.CustomInstantiator(f => new LibraryPathTemplatePartEntity
|
||||
{
|
||||
Position = position ?? 0,
|
||||
Kind = default,
|
||||
Representation = default!,
|
||||
IsOptional = isOptional
|
||||
})
|
||||
.RuleFor(part => part.Kind, f => kind ?? f.PickRandom<LibraryPathPartKind>())
|
||||
.RuleFor(part => part.Representation, f => representation ?? "{0}")
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryPathTemplatePartEntity"/> instances with sequential positions.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryPathTemplatePartEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(index => Create(position: index))];
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanEntityFixture
|
||||
{
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that initiated the media library scan.</param>
|
||||
/// <param name="status">The status of the media library scan.</param>
|
||||
/// <param name="libraryEntity">Optional. The media library that is scanned.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the entity was added.</param>
|
||||
/// <returns>The created media library scan entity.</returns>
|
||||
public LibraryScanEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? userId = null,
|
||||
LibraryScanJobStatus? status = null,
|
||||
LibraryEntity? libraryEntity = null,
|
||||
DateTime? createdOnUtc = null)
|
||||
{
|
||||
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
|
||||
Guid resolvedUserId = userId ?? Guid.NewGuid();
|
||||
LibraryEntity resolvedLibrary = libraryEntity ?? _libraryEntityFixture.Create(id: resolvedLibraryId, userId: resolvedUserId);
|
||||
|
||||
return new Faker<LibraryScanEntity>()
|
||||
.CustomInstantiator(f => new LibraryScanEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryId = resolvedLibraryId,
|
||||
UserId = resolvedUserId,
|
||||
Status = status ?? LibraryScanJobStatus.Running,
|
||||
Library = resolvedLibrary,
|
||||
User = null!,
|
||||
LibraryScanResults = [],
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = resolvedUserId,
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryScanEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanEntity"/> instances.</returns>
|
||||
public List<LibraryScanEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanResultEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanResultEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryScanResultEntity"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library scan result.</param>
|
||||
/// <param name="libraryScanId">Optional. The Id of the media library scan that this result belongs to.</param>
|
||||
/// <param name="status">Optional status of the media library scan file.</param>
|
||||
/// <param name="path">Optional path of the media library scan file.</param>
|
||||
/// <param name="contentHash">Optional hash calculated for the media library scan file.</param>
|
||||
/// <param name="fileSize">Optional size of the media library scan file.</param>
|
||||
/// <param name="ticks">Optional last write time of the media library scan file, stored in ticks.</param>
|
||||
/// <returns>A configured <see cref="LibraryScanResultEntity"/> instance.</returns>
|
||||
public LibraryScanResultEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryScanId = null,
|
||||
LibraryScanFileStatus? status = null,
|
||||
string? path = null,
|
||||
ulong? contentHash = null,
|
||||
long? fileSize = null,
|
||||
long? ticks = null)
|
||||
{
|
||||
return new Faker<LibraryScanResultEntity>()
|
||||
.CustomInstantiator(faker => new LibraryScanResultEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryScanId = libraryScanId ?? Guid.NewGuid(),
|
||||
Status = status ?? faker.PickRandom<LibraryScanFileStatus>(),
|
||||
Path = path ?? faker.System.FilePath(),
|
||||
ContentHash = contentHash ?? faker.Random.ULong(),
|
||||
FileSize = fileSize ?? faker.Random.Long(1, long.MaxValue),
|
||||
Ticks = ticks ?? faker.Random.Long(0, long.MaxValue),
|
||||
LibraryScan = null!
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScanResultEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanResultEntity"/> instances.</returns>
|
||||
public List<LibraryScanResultEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanSnapshotEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanSnapshotEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryScanSnapshotEntity"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library scan snapshot item.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library to which the snapshot item belongs.</param>
|
||||
/// <param name="path">Optional path of the media library scan snapshot item.</param>
|
||||
/// <param name="contentHash">Optional hash calculated for the media library scan snapshot item.</param>
|
||||
/// <param name="fileSize">Optional size of the media library scan snapshot item.</param>
|
||||
/// <param name="ticks">Optional last write time of the media library scan snapshot item, stored in ticks.</param>
|
||||
/// <returns>A configured <see cref="LibraryScanSnapshotEntity"/> instance.</returns>
|
||||
public LibraryScanSnapshotEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
ulong? contentHash = null,
|
||||
long? fileSize = null,
|
||||
long? ticks = null)
|
||||
{
|
||||
return new Faker<LibraryScanSnapshotEntity>()
|
||||
.CustomInstantiator(faker => new LibraryScanSnapshotEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
Path = path ?? faker.System.FilePath(),
|
||||
ContentHash = contentHash ?? faker.Random.ULong(),
|
||||
FileSize = fileSize ?? faker.Random.Long(1, long.MaxValue),
|
||||
Ticks = ticks ?? faker.Random.Long(0, long.MaxValue),
|
||||
Library = null!,
|
||||
CreatedOnUtc = faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = faker.Random.Bool() ? faker.Date.Recent() : null,
|
||||
UpdatedBy = faker.Random.Bool() ? Guid.NewGuid() : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScanSnapshotEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanSnapshotEntity"/> instances.</returns>
|
||||
public List<LibraryScanSnapshotEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanStagingResultsEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanStagingResultsEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryScanStagingResultsEntity"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library scan staging result.</param>
|
||||
/// <param name="libraryScanId">Optional. The Id of the media library scan that this staging result belongs to.</param>
|
||||
/// <param name="path">Optional path of the media library scan staging result.</param>
|
||||
/// <param name="size">Optional size of the media library scan staging result.</param>
|
||||
/// <param name="ticks">Optional last write time of the file system item, stored in ticks.</param>
|
||||
/// <param name="contentHash">Optional hash calculated for the media library scan staging result.</param>
|
||||
/// <param name="previousContentHash">Optional hash stored in the media library scan snapshot of a previous scan.</param>
|
||||
/// <param name="needsRehash">Optional value indicating whether the file system item needs its content hashed.</param>
|
||||
/// <param name="isNew">Optional value indicating whether the file system item is new.</param>
|
||||
/// <returns>A configured <see cref="LibraryScanStagingResultsEntity"/> instance.</returns>
|
||||
public LibraryScanStagingResultsEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryScanId = null,
|
||||
string? path = null,
|
||||
long? size = null,
|
||||
long? ticks = null,
|
||||
ulong? contentHash = null,
|
||||
ulong? previousContentHash = null,
|
||||
bool? needsRehash = null,
|
||||
bool? isNew = null)
|
||||
{
|
||||
return new Faker<LibraryScanStagingResultsEntity>()
|
||||
.CustomInstantiator(faker => new LibraryScanStagingResultsEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
LibraryScanId = libraryScanId ?? Guid.NewGuid(),
|
||||
Path = path ?? faker.System.FilePath(),
|
||||
Size = size ?? faker.Random.Long(1, long.MaxValue),
|
||||
Ticks = ticks ?? faker.Random.Long(0, long.MaxValue),
|
||||
ContentHash = contentHash ?? faker.Random.ULong(),
|
||||
PreviousContentHash = previousContentHash ?? faker.Random.ULong(),
|
||||
NeedsRehash = needsRehash ?? faker.Random.Bool(),
|
||||
IsNew = isNew ?? faker.Random.Bool()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScanStagingResultsEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanStagingResultsEntity"/> instances.</returns>
|
||||
public List<LibraryScanStagingResultsEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookArtworkEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookArtworkEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookArtworkEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artwork.</param>
|
||||
/// <param name="bookId">Optional. The Id of the book the artwork belongs to.</param>
|
||||
/// <param name="artworkType">Optional. The type of the artwork.</param>
|
||||
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
|
||||
/// <param name="fileName">Optional. The relative file name of the stored artwork.</param>
|
||||
/// <param name="contentHash">Optional. The content hash of the stored artwork.</param>
|
||||
/// <param name="status">Optional. The status of the artwork enrichment.</param>
|
||||
/// <param name="provider">Optional. The name of the plugin that resolved the artwork.</param>
|
||||
/// <param name="lastUpdateUtc">Optional. The date and time when the artwork was last resolved.</param>
|
||||
/// <returns>The created <see cref="BookArtworkEntity"/>.</returns>
|
||||
public BookArtworkEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? bookId = null,
|
||||
ArtworkType? artworkType = null,
|
||||
int? ordinal = null,
|
||||
string? fileName = null,
|
||||
ulong? contentHash = null,
|
||||
ArtworkStatus? status = null,
|
||||
string? provider = null,
|
||||
DateTime? lastUpdateUtc = null)
|
||||
{
|
||||
return new BookArtworkEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
ArtworkType = artworkType ?? ArtworkType.Cover,
|
||||
Ordinal = ordinal ?? 0,
|
||||
FileName = fileName ?? _faker.System.FilePath(),
|
||||
ContentHash = contentHash ?? (ulong)_faker.Random.ULong(),
|
||||
Status = status ?? _faker.PickRandom<ArtworkStatus>(),
|
||||
Provider = provider ?? _faker.Company.CompanyName(),
|
||||
LastUpdateUtc = lastUpdateUtc ?? _faker.Date.Recent(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookArtworkEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookArtworkEntity"/> instances.</returns>
|
||||
public List<BookArtworkEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the participation.</param>
|
||||
/// <param name="bookId">Optional. The Id of the book the contributor participated in.</param>
|
||||
/// <param name="mediaContributorId">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played in the book.</param>
|
||||
/// <returns>The created <see cref="BookContributorEntity"/>.</returns>
|
||||
public BookContributorEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? bookId = null,
|
||||
Guid? mediaContributorId = null,
|
||||
MediaContributorRole? role = null)
|
||||
{
|
||||
return new BookContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
MediaContributorId = mediaContributorId ?? Guid.NewGuid(),
|
||||
Role = role ?? MediaContributorRole.Author,
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookContributorEntity"/> instances.</returns>
|
||||
public List<BookContributorEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
private readonly IsbnEntityFixture _isbnEntityFixture = new();
|
||||
private readonly BookRatingEntityFixture _bookRatingEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the book.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that owns the book.</param>
|
||||
/// <param name="path">Optional. The file system path of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the book.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the book was deleted. Only used when the book is marked as deleted.</param>
|
||||
/// <param name="isDeleted">Optional. Whether the book is marked as deleted.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, ISBNs, Ratings) should be included, or forced to empty collections.</param>
|
||||
/// <returns>The created <see cref="BookEntity"/>.</returns>
|
||||
public BookEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
bool isDeleted = false,
|
||||
bool includeMetadata = true)
|
||||
{
|
||||
int releaseYear = Random.Shared.Next(2000, 2010);
|
||||
int reReleaseYear = Random.Shared.Next(2010, 2020);
|
||||
|
||||
return new Faker<BookEntity>()
|
||||
.RuleFor(x => x.Id, f => id ?? f.Random.Guid())
|
||||
.RuleFor(x => x.LibraryId, f => libraryId ?? f.Random.Guid())
|
||||
.RuleFor(x => x.Path, f => path ?? f.System.FilePath())
|
||||
.RuleFor(x => x.Title, f => title ?? f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.OriginalTitle, f => originalTitle ?? f.Random.String2(f.Random.Number(1, 255)))
|
||||
.RuleFor(x => x.Description, f => f.Random.String2(f.Random.Number(1, 2000)))
|
||||
.RuleFor(x => x.OriginalReleaseDate, _faker.DateOnlyBetween(new DateOnly(releaseYear, 1, 1), new DateOnly(releaseYear, 12, 31)))
|
||||
.RuleFor(x => x.OriginalReleaseYear, releaseYear)
|
||||
.RuleFor(x => x.ReReleaseDate, _faker.DateOnlyBetween(new DateOnly(reReleaseYear, 1, 1), new DateOnly(reReleaseYear, 12, 31)))
|
||||
.RuleFor(x => x.ReReleaseYear, reReleaseYear)
|
||||
.RuleFor(x => x.ReleaseCountry, f => f.PickRandom<ReleaseCountry>())
|
||||
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(x => x.LanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.LanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.OriginalLanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.OriginalLanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.Tags, f => includeMetadata ? [.. _tagEntityFixture.CreateMany(f.Random.Number(1, 5))] : [])
|
||||
.RuleFor(x => x.Genres, f => includeMetadata ? [.. _genreEntityFixture.CreateMany(f.Random.Number(1, 5))] : [])
|
||||
.RuleFor(x => x.Publisher, f => f.Random.String2(f.Random.Number(1, 100)))
|
||||
.RuleFor(x => x.PageCount, Random.Shared.Next(100, 300))
|
||||
.RuleFor(x => x.Format, f => f.PickRandom<BookFormat>())
|
||||
.RuleFor(x => x.Edition, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.VolumeNumber, Random.Shared.Next(1, 3))
|
||||
.RuleFor(x => x.ASIN, f => f.Random.String2(10))
|
||||
.RuleFor(x => x.GoodreadsId, Random.Shared.Next(100000, 500000).ToString())
|
||||
.RuleFor(x => x.LCCN, CreateLCCN)
|
||||
.RuleFor(x => x.OCLCNumber, CreateOCLCNumber)
|
||||
.RuleFor(x => x.OpenLibraryId, CreateOpenLibraryId)
|
||||
.RuleFor(x => x.LibraryThingId, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.GoogleBooksId, CreateGoogleBooksId)
|
||||
.RuleFor(x => x.BarnesAndNobleId, f => f.Random.String2(10, "0123456789"))
|
||||
.RuleFor(x => x.AppleBooksId, f => $"id{f.Random.Number(1, 999999)}")
|
||||
.RuleFor(x => x.ISBNs, f => includeMetadata ? _isbnEntityFixture.CreateMany(f.Random.Number(1, 5)) : [])
|
||||
.RuleFor(x => x.Ratings, f => includeMetadata ? _bookRatingEntityFixture.CreateMany(f.Random.Number(1, 5)) : [])
|
||||
.RuleFor(x => x.IsDeleted, isDeleted)
|
||||
.RuleFor(x => x.DeletedOnUtc, f => isDeleted ? (deletedOnUtc ?? f.Date.Recent()) : null)
|
||||
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookEntity"/> instances.</returns>
|
||||
public List<BookEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid Library of Congress Control Number (LCCN).
|
||||
/// </summary>
|
||||
/// <param name="f">The Faker instance used for generating random data.</param>
|
||||
/// <returns>A properly formatted LCCN string.</returns>
|
||||
private string CreateLCCN(Faker f)
|
||||
{
|
||||
string letters = new([.. Enumerable.Range(0, f.Random.Number(0, 3)).Select(_ => f.Random.Char('a', 'z'))]);
|
||||
string digits = f.Random.String2(f.Random.Number(8, 10), "0123456789");
|
||||
return letters + digits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid OCLC (Online Computer Library Center) number.
|
||||
/// </summary>
|
||||
/// <param name="f">The Faker instance used for generating random data.</param>
|
||||
/// <returns>A properly formatted OCLC number string with valid prefix.</returns>
|
||||
private string CreateOCLCNumber(Faker f)
|
||||
{
|
||||
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
|
||||
string prefix = f.Random.ArrayElement(prefixes);
|
||||
string number = prefix switch
|
||||
{
|
||||
"ocm" => f.Random.String2(8, "0123456789"),
|
||||
"ocn" => f.Random.String2(f.Random.Number(9, 11), "0123456789"),
|
||||
"on" => f.Random.String2(10, "0123456789"),
|
||||
"(OCoLC)" => f.Random.String2(f.Random.Number(8, 10), "0123456789"),
|
||||
_ => f.Random.String2(f.Random.Number(8, 10), "0123456789")
|
||||
};
|
||||
return prefix + number;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid Open Library ID.
|
||||
/// </summary>
|
||||
/// <param name="f">The Faker instance used for generating random data.</param>
|
||||
/// <returns>A properly formatted Open Library ID string.</returns>
|
||||
private string CreateOpenLibraryId(Faker f)
|
||||
{
|
||||
int firstDigit = f.Random.Number(1, 9);
|
||||
string remainingDigits = f.Random.String2(f.Random.Number(0, 6), "0123456789");
|
||||
char suffix = f.Random.ArrayElement(['A', 'M', 'W']);
|
||||
return $"OL{firstDigit}{remainingDigits}{suffix}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid Google Books ID.
|
||||
/// </summary>
|
||||
/// <param name="f">The Faker instance used for generating random data.</param>
|
||||
/// <returns>A properly formatted Google Books ID string.</returns>
|
||||
private string CreateGoogleBooksId(Faker f)
|
||||
{
|
||||
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[f.Random.Number(VALID_CHARS.Length - 1)])]);
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookRatingEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The rating value.</param>
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
|
||||
/// <param name="source">Optional. The rating source.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes.</param>
|
||||
/// <param name="includeValues">Whether the rating properties should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created book rating entity.</returns>
|
||||
public BookRatingEntity Create(
|
||||
decimal? value = null,
|
||||
decimal? maxValue = null,
|
||||
BookRatingSource? source = null,
|
||||
int? voteCount = null,
|
||||
bool includeValues = true)
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
includeValues ? (value ?? Random.Shared.Next(1, 5)) : null,
|
||||
includeValues ? (maxValue ?? 5) : null,
|
||||
includeValues ? (source ?? _faker.PickRandom<BookRatingSource>()) : null,
|
||||
includeValues ? (voteCount ?? Random.Shared.Next(1, 1000)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookRatingEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookRatingEntity"/> instances.</returns>
|
||||
public List<BookRatingEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="IsbnEntity"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsbnEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="IsbnEntity"/>, with a value that satisfies the ISBN checksum and a format that matches it.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The ISBN value.</param>
|
||||
/// <param name="format">Optional. The format of the ISBN.</param>
|
||||
/// <param name="includeValue">Whether the value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="IsbnEntity"/>.</returns>
|
||||
public IsbnEntity Create(
|
||||
string? value = null,
|
||||
IsbnFormat? format = null,
|
||||
bool includeValue = true,
|
||||
bool includeFormat = true)
|
||||
{
|
||||
string? resolvedValue = includeValue ? value ?? CreateValidIsbn13() : null;
|
||||
IsbnFormat? resolvedFormat = includeFormat ? format ?? InferFormat(resolvedValue) : null;
|
||||
return new IsbnEntity(resolvedValue, resolvedFormat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<IsbnEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Infers the format of an ISBN from the number of digits of its value.
|
||||
/// </summary>
|
||||
/// <param name="value">The ISBN value whose format is inferred.</param>
|
||||
/// <returns>The inferred ISBN format.</returns>
|
||||
private static IsbnFormat InferFormat(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return IsbnFormat.Isbn13;
|
||||
|
||||
int digitCount = value.Count(char.IsLetterOrDigit);
|
||||
return digitCount is 10 ? IsbnFormat.Isbn10 : IsbnFormat.Isbn13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random ISBN-13 value with a valid check digit.
|
||||
/// </summary>
|
||||
/// <returns>A valid ISBN-13 value of 13 digits.</returns>
|
||||
private string CreateValidIsbn13()
|
||||
{
|
||||
string prefix = _faker.Random.Bool() ? "978" : "979";
|
||||
string firstTwelveDigits = prefix + _faker.Random.String2(9, "0123456789");
|
||||
int sum = 0;
|
||||
for (int index = 0; index < 12; index++)
|
||||
sum += index % 2 == 0 ? firstTwelveDigits[index] - '0' : 3 * (firstTwelveDigits[index] - '0');
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
return firstTwelveDigits + checkDigit;
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="includeDescription">Whether the description should be populated.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds.</param>
|
||||
/// <param name="entries">Optional. The ordered entries of the playlist.</param>
|
||||
/// <param name="entryCount">Optional. The number of entries the playlist holds.</param>
|
||||
/// <param name="version">Optional. The concurrency token of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the playlist was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the playlist.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be populated.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The time and date when the playlist was updated.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that updated the playlist.</param>
|
||||
/// <returns>The created playlist entity.</returns>
|
||||
public PlaylistEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? name = null,
|
||||
bool includeDescription = true,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
IEnumerable<PlaylistEntryEntity>? entries = null,
|
||||
int? entryCount = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
bool includeUpdatedOnUtc = false,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null)
|
||||
{
|
||||
Guid playlistId = id ?? Guid.NewGuid();
|
||||
List<PlaylistEntryEntity> resolvedEntries = entries is null ? [] : [.. entries];
|
||||
|
||||
return new Faker<PlaylistEntity>()
|
||||
.CustomInstantiator(f => new PlaylistEntity
|
||||
{
|
||||
Id = playlistId,
|
||||
UserId = userId ?? f.Random.Guid(),
|
||||
Name = name ?? f.Lorem.Sentence(3),
|
||||
Description = includeDescription ? (description ?? f.Lorem.Sentence()) : null,
|
||||
Type = type ?? f.PickRandom<PlaylistType>(),
|
||||
Entries = resolvedEntries,
|
||||
EntryCount = entryCount ?? resolvedEntries.Count,
|
||||
Version = version ?? f.Random.Long(0, 1_000L),
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? f.Date.Recent()) : null,
|
||||
UpdatedBy = includeUpdatedOnUtc ? (updatedBy ?? f.Random.Guid()) : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the created playlists.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntity"/> instances.</returns>
|
||||
public List<PlaylistEntity> CreateMany(int count = 3, Guid? userId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(userId: userId))];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the entry.</param>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist the entry belongs to.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the referenced media item.</param>
|
||||
/// <param name="mediaItemType">Optional. The kind of the referenced media item.</param>
|
||||
/// <param name="position">Optional. The sparse order key of the entry.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the entry was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the entry.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be populated.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The time and date when the entry was updated.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that updated the entry.</param>
|
||||
/// <returns>The created playlist entry entity.</returns>
|
||||
public PlaylistEntryEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? playlistId = null,
|
||||
Guid? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
long? position = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
bool includeUpdatedOnUtc = false,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null)
|
||||
{
|
||||
return new Faker<PlaylistEntryEntity>()
|
||||
.CustomInstantiator(f => new PlaylistEntryEntity
|
||||
{
|
||||
Id = id ?? f.Random.Guid(),
|
||||
PlaylistId = playlistId ?? f.Random.Guid(),
|
||||
MediaItemId = mediaItemId ?? f.Random.Guid(),
|
||||
MediaItemType = mediaItemType ?? f.PickRandom<PlaylistMediaItemType>(),
|
||||
Position = position ?? f.Random.Long(0, 1_000_000_000L),
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? f.Date.Recent()) : null,
|
||||
UpdatedBy = includeUpdatedOnUtc ? (updatedBy ?? f.Random.Guid()) : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryArtworkProviderConfigurationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryArtworkProviderConfigurationEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryArtworkProviderConfigurationEntity"/> for the provided media library, plugin and rank.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library the configuration belongs to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the artwork.</param>
|
||||
/// <param name="rank">The rank of the artwork provider, determining the order in which providers are tried.</param>
|
||||
/// <param name="isEnabled">Whether the artwork provider is enabled or not.</param>
|
||||
/// <returns>The created <see cref="LibraryArtworkProviderConfigurationEntity"/>.</returns>
|
||||
public LibraryArtworkProviderConfigurationEntity Create(
|
||||
Guid libraryId,
|
||||
Guid pluginId,
|
||||
int rank,
|
||||
bool isEnabled = true)
|
||||
{
|
||||
return new Faker<LibraryArtworkProviderConfigurationEntity>()
|
||||
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.LibraryId, libraryId)
|
||||
.RuleFor(configuration => configuration.PluginId, pluginId)
|
||||
.RuleFor(configuration => configuration.IsEnabled, isEnabled)
|
||||
.RuleFor(configuration => configuration.Rank, rank)
|
||||
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryArtworkProviderConfigurationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="libraryId">The Id of the media library the configurations belong to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the artwork.</param>
|
||||
/// <param name="rank">The rank of the artwork providers.</param>
|
||||
/// <returns>List of configured <see cref="LibraryArtworkProviderConfigurationEntity"/> instances.</returns>
|
||||
public List<LibraryArtworkProviderConfigurationEntity> CreateMany(int count, Guid libraryId, Guid pluginId, int rank)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryId, pluginId, rank))];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryBookReaderConfigurationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryBookReaderConfigurationEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryBookReaderConfigurationEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the configuration.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the configuration belongs to.</param>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the book reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the book reader is enabled for the media library.</param>
|
||||
/// <returns>The created <see cref="LibraryBookReaderConfigurationEntity"/>.</returns>
|
||||
public LibraryBookReaderConfigurationEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new Faker<LibraryBookReaderConfigurationEntity>()
|
||||
.RuleFor(configuration => configuration.Id, _ => id ?? Guid.NewGuid())
|
||||
.RuleFor(configuration => configuration.LibraryId, _ => libraryId ?? Guid.NewGuid())
|
||||
.RuleFor(configuration => configuration.PluginId, _ => pluginId ?? Guid.NewGuid())
|
||||
.RuleFor(configuration => configuration.IsEnabled, _ => isEnabled ?? true)
|
||||
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryBookReaderConfigurationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryBookReaderConfigurationEntity"/> instances.</returns>
|
||||
public List<LibraryBookReaderConfigurationEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryMetadataProviderConfigurationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryMetadataProviderConfigurationEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryMetadataProviderConfigurationEntity"/> for the provided media library, plugin and rank.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library the configuration belongs to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="rank">The rank of the metadata provider, determining the order in which providers are tried.</param>
|
||||
/// <param name="isEnabled">Whether the metadata provider is enabled or not.</param>
|
||||
/// <returns>The created <see cref="LibraryMetadataProviderConfigurationEntity"/>.</returns>
|
||||
public LibraryMetadataProviderConfigurationEntity Create(
|
||||
Guid libraryId,
|
||||
Guid pluginId,
|
||||
int rank,
|
||||
bool isEnabled = true)
|
||||
{
|
||||
return new Faker<LibraryMetadataProviderConfigurationEntity>()
|
||||
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.LibraryId, libraryId)
|
||||
.RuleFor(configuration => configuration.PluginId, pluginId)
|
||||
.RuleFor(configuration => configuration.IsEnabled, isEnabled)
|
||||
.RuleFor(configuration => configuration.Rank, rank)
|
||||
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryMetadataProviderConfigurationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="libraryId">The Id of the media library the configurations belong to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="rank">The rank of the metadata providers.</param>
|
||||
/// <returns>List of configured <see cref="LibraryMetadataProviderConfigurationEntity"/> instances.</returns>
|
||||
public List<LibraryMetadataProviderConfigurationEntity> CreateMany(int count, Guid libraryId, Guid pluginId, int rank)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryId, pluginId, rank))];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PluginEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PluginEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="name">The name of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="loadStatus">The load status of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="settingsJson">The serialized settings of the plugin, or <see langword="null"/> to generate random ones.</param>
|
||||
/// <param name="includeSettingsJson">Whether the settings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PluginEntity"/>.</returns>
|
||||
public PluginEntity Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
PluginLoadStatus? loadStatus = null,
|
||||
string? settingsJson = null,
|
||||
bool includeSettingsJson = true)
|
||||
{
|
||||
return new Faker<PluginEntity>()
|
||||
.RuleFor(plugin => plugin.Id, faker => id ?? faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.Name, faker => name ?? faker.Company.CompanyName())
|
||||
.RuleFor(plugin => plugin.Author, faker => faker.Name.FullName())
|
||||
.RuleFor(plugin => plugin.Version, faker => faker.System.Semver())
|
||||
.RuleFor(plugin => plugin.Description, faker => faker.Lorem.Sentence())
|
||||
.RuleFor(plugin => plugin.LoadStatus, faker => loadStatus ?? faker.PickRandom<PluginLoadStatus>())
|
||||
.RuleFor(plugin => plugin.SettingsJson, faker => includeSettingsJson ? settingsJson ?? JsonSerializer.Serialize(new Dictionary<string, string> { [faker.Random.String2(1, 10)] = faker.Random.String2(1, 20) }) : null)
|
||||
.RuleFor(plugin => plugin.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(plugin => plugin.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
.RuleFor(plugin => plugin.UpdatedBy, faker => faker.Random.Guid())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PluginEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PluginEntity"/> instances.</returns>
|
||||
public List<PluginEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the scheduled job.</param>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
|
||||
/// <param name="hour">Optional. The hour of the schedule.</param>
|
||||
/// <param name="minute">Optional. The minute of the schedule.</param>
|
||||
/// <param name="status">Optional. The status of the scheduled job.</param>
|
||||
/// <param name="ownerUserId">Optional. The Id of the user that owns the scheduled job.</param>
|
||||
/// <param name="lastStartedOnUtc">Optional. The last start time of the scheduled job.</param>
|
||||
/// <param name="lastCompletedOnUtc">Optional. The last completion time of the scheduled job.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobEntity"/>.</returns>
|
||||
public ScheduledJobEntity Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
ScheduleType? scheduleType = null,
|
||||
int? intervalMinutes = null,
|
||||
int? hour = null,
|
||||
int? minute = null,
|
||||
ScheduledJobStatus? status = null,
|
||||
Guid? ownerUserId = null,
|
||||
DateTime? lastStartedOnUtc = null,
|
||||
DateTime? lastCompletedOnUtc = null)
|
||||
{
|
||||
return new Faker<ScheduledJobEntity>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
|
||||
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
|
||||
{
|
||||
return new ScheduledJobEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Name = name ?? f.Commerce.ProductName(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
ScheduleType = resolvedScheduleType,
|
||||
IntervalMinutes = intervalMinutes ?? f.Random.Int(1, 1440),
|
||||
Hour = null,
|
||||
Minute = null,
|
||||
Status = status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
OwnerUserId = ownerUserId ?? Guid.NewGuid(),
|
||||
LastStartedOnUtc = lastStartedOnUtc,
|
||||
LastCompletedOnUtc = lastCompletedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
if (resolvedScheduleType == ScheduleType.OnceAtStartup)
|
||||
{
|
||||
return new ScheduledJobEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Name = name ?? f.Commerce.ProductName(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
ScheduleType = resolvedScheduleType,
|
||||
IntervalMinutes = null,
|
||||
Hour = null,
|
||||
Minute = null,
|
||||
Status = status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
OwnerUserId = ownerUserId ?? Guid.NewGuid(),
|
||||
LastStartedOnUtc = lastStartedOnUtc,
|
||||
LastCompletedOnUtc = lastCompletedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
return new ScheduledJobEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Name = name ?? f.Commerce.ProductName(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
ScheduleType = resolvedScheduleType,
|
||||
IntervalMinutes = null,
|
||||
Hour = hour ?? f.Random.Int(0, 23),
|
||||
Minute = minute ?? f.Random.Int(0, 59),
|
||||
Status = status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
OwnerUserId = ownerUserId ?? Guid.NewGuid(),
|
||||
LastStartedOnUtc = lastStartedOnUtc,
|
||||
LastCompletedOnUtc = lastCompletedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobEntity"/> instances.</returns>
|
||||
public List<ScheduledJobEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the execution.</param>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task was executed.</param>
|
||||
/// <param name="taskType">Optional. The type of the task that was executed.</param>
|
||||
/// <param name="isCycleRun">Optional. Whether the execution was a cycle run.</param>
|
||||
/// <param name="wasCycleActive">Optional. Whether the execution cycle of the scheduled job was active when the execution started.</param>
|
||||
/// <param name="startedOnUtc">Optional. The start time of the execution.</param>
|
||||
/// <param name="completedOnUtc">Optional. The completion time of the execution.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionEntity"/>.</returns>
|
||||
public ScheduledJobExecutionEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? scheduledJobId = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
bool? isCycleRun = null,
|
||||
bool? wasCycleActive = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? completedOnUtc = null)
|
||||
{
|
||||
return new Faker<ScheduledJobExecutionEntity>()
|
||||
.CustomInstantiator(f => new ScheduledJobExecutionEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
ScheduledJobId = scheduledJobId ?? Guid.NewGuid(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
IsCycleRun = isCycleRun ?? f.Random.Bool(),
|
||||
WasCycleActive = wasCycleActive ?? f.Random.Bool(),
|
||||
StartedOnUtc = startedOnUtc ?? DateTime.UtcNow,
|
||||
CompletedOnUtc = completedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobExecutionEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobExecutionEntity"/> instances.</returns>
|
||||
public List<ScheduledJobExecutionEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SchedulerDisplayPreferencesEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SchedulerDisplayPreferencesEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SchedulerDisplayPreferencesEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the display preferences.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the display preferences.</param>
|
||||
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
|
||||
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
|
||||
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
|
||||
/// <returns>The created <see cref="SchedulerDisplayPreferencesEntity"/>.</returns>
|
||||
public SchedulerDisplayPreferencesEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new Faker<SchedulerDisplayPreferencesEntity>()
|
||||
.CustomInstantiator(f => new SchedulerDisplayPreferencesEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
JobTypeFilter = jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
|
||||
DisplayTimeSpan = displayTimeSpan ?? f.Random.Int(1, 24 * 60),
|
||||
DisplayTimeUnit = displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>(),
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SchedulerDisplayPreferencesEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SchedulerDisplayPreferencesEntity"/> instances.</returns>
|
||||
public List<SchedulerDisplayPreferencesEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Themes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional database Id of the theme.</param>
|
||||
/// <param name="themeId">Optional manifest id of the theme.</param>
|
||||
/// <param name="name">Optional display name of the theme.</param>
|
||||
/// <param name="description">Optional description of the theme.</param>
|
||||
/// <param name="author">Optional author of the theme.</param>
|
||||
/// <param name="version">Optional version of the theme.</param>
|
||||
/// <param name="previewPath">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
|
||||
/// <param name="installSource">Optional source the theme was installed from.</param>
|
||||
/// <param name="isCurrent">Optional value indicating whether the theme is the currently active one.</param>
|
||||
/// <param name="isDeleted">Optional value indicating whether the theme was soft deleted.</param>
|
||||
/// <param name="installedAtUtc">Optional UTC timestamp when the theme was installed.</param>
|
||||
/// <param name="createdOnUtc">Optional UTC timestamp when the entity was created.</param>
|
||||
/// <param name="createdBy">Optional Id of the user that created the entity.</param>
|
||||
/// <param name="updatedOnUtc">Optional UTC timestamp when the entity was updated.</param>
|
||||
/// <param name="updatedBy">Optional Id of the user that updated the entity.</param>
|
||||
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the updated-on timestamp should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updated-by user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ThemeEntity"/> instance.</returns>
|
||||
public ThemeEntity Create(
|
||||
Guid? id = null,
|
||||
string? themeId = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
string? author = null,
|
||||
string? version = null,
|
||||
string? previewPath = null,
|
||||
ThemeInstallSource? installSource = null,
|
||||
bool? isCurrent = null,
|
||||
bool? isDeleted = null,
|
||||
DateTime? installedAtUtc = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null,
|
||||
bool includePreviewPath = false,
|
||||
bool includeIsCurrent = false,
|
||||
bool includeUpdatedOnUtc = false,
|
||||
bool includeUpdatedBy = false)
|
||||
{
|
||||
Guid resolvedCreatedBy = createdBy ?? Guid.NewGuid();
|
||||
return new Faker<ThemeEntity>()
|
||||
.CustomInstantiator(f => new ThemeEntity
|
||||
{
|
||||
Id = default,
|
||||
ThemeId = default!,
|
||||
Name = default!,
|
||||
Description = default!,
|
||||
Author = default!,
|
||||
Version = default!,
|
||||
PreviewPath = default,
|
||||
InstallSource = default,
|
||||
IsCurrent = default,
|
||||
IsDeleted = default,
|
||||
InstalledAtUtc = default,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedOnUtc = default,
|
||||
UpdatedBy = default
|
||||
})
|
||||
.RuleFor(theme => theme.Id, f => id ?? f.Random.Guid())
|
||||
.RuleFor(theme => theme.ThemeId, f => themeId ?? f.Lorem.Slug(2))
|
||||
.RuleFor(theme => theme.Name, f => name ?? f.Commerce.ProductName())
|
||||
.RuleFor(theme => theme.Description, f => description ?? f.Lorem.Sentence())
|
||||
.RuleFor(theme => theme.Author, f => author ?? f.Name.FullName())
|
||||
.RuleFor(theme => theme.Version, f => version ?? f.System.Semver())
|
||||
.RuleFor(theme => theme.PreviewPath, f => includePreviewPath ? (previewPath ?? f.System.FilePath()) : null)
|
||||
.RuleFor(theme => theme.InstallSource, f => installSource ?? f.PickRandom<ThemeInstallSource>())
|
||||
.RuleFor(theme => theme.IsCurrent, f => includeIsCurrent ? (isCurrent ?? (f.Random.Bool() ? true : null)) : null)
|
||||
.RuleFor(theme => theme.IsDeleted, f => isDeleted ?? f.Random.Bool())
|
||||
.RuleFor(theme => theme.InstalledAtUtc, f => installedAtUtc ?? f.Date.Recent().ToUniversalTime())
|
||||
.RuleFor(theme => theme.CreatedOnUtc, f => createdOnUtc ?? f.Date.Past().ToUniversalTime())
|
||||
.RuleFor(theme => theme.CreatedBy, resolvedCreatedBy)
|
||||
.RuleFor(theme => theme.UpdatedOnUtc, f => includeUpdatedOnUtc ? (updatedOnUtc ?? f.Date.Recent().ToUniversalTime()) : null)
|
||||
.RuleFor(theme => theme.UpdatedBy, f => includeUpdatedBy ? (updatedBy ?? f.Random.Guid()) : null)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeEntity"/> instances.</returns>
|
||||
public List<ThemeEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserEntityFixture
|
||||
{
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryCount">Number of libraries to generate. Default is 0.</param>
|
||||
/// <param name="username">Optional username to pin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="password">Optional password to pin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="id">Optional Id to pin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="userRole">Optional user role association to pin when including it.</param>
|
||||
/// <param name="userPermissions">Optional user permission associations to pin when including them.</param>
|
||||
/// <param name="libraries">Optional collection of libraries to pin for the user, or <see langword="null"/> to generate them based on <paramref name="libraryCount"/>.</param>
|
||||
/// <param name="includeUserRole">Whether the user role association should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUserPermissions">Whether the user permission associations should be included, or forced to an empty collection.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the user.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the user was created.</param>
|
||||
/// <returns>The created user entity.</returns>
|
||||
public UserEntity Create(
|
||||
int libraryCount = 0,
|
||||
string? username = null,
|
||||
string? password = null,
|
||||
Guid? id = null,
|
||||
UserRoleEntity? userRole = null,
|
||||
IEnumerable<UserPermissionEntity>? userPermissions = null,
|
||||
ICollection<LibraryEntity>? libraries = null,
|
||||
bool includeUserRole = false,
|
||||
bool includeUserPermissions = false,
|
||||
Guid? createdBy = null,
|
||||
DateTime? createdOnUtc = null)
|
||||
{
|
||||
Guid userId = id ?? Guid.NewGuid();
|
||||
ICollection<LibraryEntity> resolvedLibraries = libraries ?? (libraryCount > 0
|
||||
? _libraryEntityFixture.CreateMany(libraryCount, userId)
|
||||
: []);
|
||||
|
||||
return new Faker<UserEntity>()
|
||||
.CustomInstantiator(f => new UserEntity
|
||||
{
|
||||
Id = userId,
|
||||
Username = default!,
|
||||
Password = default!,
|
||||
CreatedOnUtc = default,
|
||||
TotpSecret = default,
|
||||
Libraries = resolvedLibraries,
|
||||
UserPermissions = includeUserPermissions ? (userPermissions ?? []).ToList() : [],
|
||||
UserRole = includeUserRole ? userRole : null,
|
||||
CreatedBy = createdBy ?? userId
|
||||
})
|
||||
.RuleFor(x => x.Username, f => username ?? f.Internet.UserName())
|
||||
.RuleFor(x => x.Password, f => password ?? Uri.EscapeDataString(f.Internet.Password()))
|
||||
.RuleFor(x => x.CreatedOnUtc, f => createdOnUtc ?? f.Date.Past())
|
||||
.RuleFor(x => x.TotpSecret, f => f.Random.Bool() ? f.Random.String2(32) : null)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="libraryCount">Number of libraries to generate for each user.</param>
|
||||
/// <returns>List of configured <see cref="UserEntity"/> instances.</returns>
|
||||
public List<UserEntity> CreateMany(int count = 3, int libraryCount = 0)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryCount))];
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserSettingsEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserSettingsEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserSettingsEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the user settings.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused, or not.</param>
|
||||
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist, or not.</param>
|
||||
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap, or not.</param>
|
||||
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
|
||||
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
|
||||
/// <param name="vuMeterOrientation">Optional. The direction in which each channel of the VU meter of the audio player grows.</param>
|
||||
/// <param name="vuMeterSegmentCount">Optional. The number of segments each channel of the VU meter is divided into.</param>
|
||||
/// <param name="vuMeterSegmentGap">Optional. The gap, in pixels, between the segments and the channels of the VU meter.</param>
|
||||
/// <param name="vuMeterMediumThreshold">Optional. The level above which a segment of the VU meter is drawn with its medium state.</param>
|
||||
/// <param name="vuMeterHighThreshold">Optional. The level above which a segment of the VU meter is drawn with its high state.</param>
|
||||
/// <param name="vuMeterShowPeak">Optional. Whether the VU meter holds the peak level of each channel after it falls.</param>
|
||||
/// <param name="vuMeterPeakHoldDurationInMilliseconds">Optional. The time a peak of the VU meter is held before it starts falling.</param>
|
||||
/// <param name="vuMeterReleasePerSecond">Optional. The number of level units the display of the VU meter falls per second when the input level drops.</param>
|
||||
/// <param name="vuMeterPeakReleasePerSecond">Optional. The number of level units the peak of the VU meter falls per second after its hold time elapsed.</param>
|
||||
/// <param name="volume">Optional. The last volume the player reported for the user.</param>
|
||||
/// <param name="isMuted">Optional. The last mute state the player reported for the user.</param>
|
||||
/// <returns>The created user settings entity.</returns>
|
||||
public UserSettingsEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null,
|
||||
bool? shouldRenderPdfAsImages = null,
|
||||
bool? shouldPreserveBookStyles = null,
|
||||
bool? shouldKeepDownloadingWhilePaused = null,
|
||||
bool? shouldAutoplay = null,
|
||||
bool? isGaplessPlaybackEnabled = null,
|
||||
ReplayGainMode? replayGainMode = null,
|
||||
PlaybackStreamingQuality? streamingQuality = null,
|
||||
VuMeterOrientation? vuMeterOrientation = null,
|
||||
int? vuMeterSegmentCount = null,
|
||||
int? vuMeterSegmentGap = null,
|
||||
double? vuMeterMediumThreshold = null,
|
||||
double? vuMeterHighThreshold = null,
|
||||
bool? vuMeterShowPeak = null,
|
||||
int? vuMeterPeakHoldDurationInMilliseconds = null,
|
||||
double? vuMeterReleasePerSecond = null,
|
||||
double? vuMeterPeakReleasePerSecond = null,
|
||||
double? volume = null,
|
||||
bool? isMuted = null)
|
||||
{
|
||||
return new Faker<UserSettingsEntity>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
// The high threshold is generated from the medium one, so a randomized entity always describes a valid meter.
|
||||
double mediumThreshold = vuMeterMediumThreshold ?? f.Random.Double(0, 1);
|
||||
return new UserSettingsEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(),
|
||||
ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100),
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(),
|
||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(),
|
||||
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool(),
|
||||
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? f.Random.Bool(),
|
||||
ShouldAutoplay = shouldAutoplay ?? f.Random.Bool(),
|
||||
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? f.Random.Bool(),
|
||||
ReplayGainMode = replayGainMode ?? f.PickRandom<ReplayGainMode>(),
|
||||
StreamingQuality = streamingQuality ?? f.PickRandom<PlaybackStreamingQuality>(),
|
||||
VuMeterOrientation = vuMeterOrientation ?? f.PickRandom<VuMeterOrientation>(),
|
||||
VuMeterSegmentCount = vuMeterSegmentCount ?? f.Random.Int(1, 128),
|
||||
VuMeterSegmentGap = vuMeterSegmentGap ?? f.Random.Int(0, 32),
|
||||
VuMeterMediumThreshold = mediumThreshold,
|
||||
VuMeterHighThreshold = vuMeterHighThreshold ?? f.Random.Double(mediumThreshold, 1),
|
||||
VuMeterShowPeak = vuMeterShowPeak ?? f.Random.Bool(),
|
||||
VuMeterPeakHoldDurationInMilliseconds = vuMeterPeakHoldDurationInMilliseconds ?? f.Random.Int(0, 10000),
|
||||
VuMeterReleasePerSecond = vuMeterReleasePerSecond ?? f.Random.Double(0, 100),
|
||||
VuMeterPeakReleasePerSecond = vuMeterPeakReleasePerSecond ?? f.Random.Double(0, 100),
|
||||
Volume = volume ?? f.Random.Double(0.0, 1.0),
|
||||
IsMuted = isMuted ?? f.Random.Bool()
|
||||
};
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserSettingsEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserSettingsEntity"/> instances.</returns>
|
||||
public List<UserSettingsEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.ConsumptionActivity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Authorization.Policies.ConsumptionActivity;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionActivityAccessPolicyContext"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionActivityAccessPolicyContextFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionActivityAccessPolicyContext"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose consumption activity is being accessed.</param>
|
||||
/// <returns>The created <see cref="ConsumptionActivityAccessPolicyContext"/> instance.</returns>
|
||||
public ConsumptionActivityAccessPolicyContext Create(Guid? targetUserId = null)
|
||||
{
|
||||
return new ConsumptionActivityAccessPolicyContext(targetUserId ?? _faker.Random.Guid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ConsumptionActivityAccessPolicyContext"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionActivityAccessPolicyContext"/> instances.</returns>
|
||||
public List<ConsumptionActivityAccessPolicyContext> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryOwnershipPolicyContext"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryOwnershipPolicyContextFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryOwnershipPolicyContext"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose access is being evaluated.</param>
|
||||
/// <returns>The created <see cref="LibraryOwnershipPolicyContext"/> instance.</returns>
|
||||
public LibraryOwnershipPolicyContext Create(Guid? libraryId = null)
|
||||
{
|
||||
return new LibraryOwnershipPolicyContext(libraryId ?? _faker.Random.Guid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryOwnershipPolicyContext"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryOwnershipPolicyContext"/> instances.</returns>
|
||||
public List<LibraryOwnershipPolicyContext> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaSettingsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaSettingsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaSettingsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="rootDirectory">Optional. The root directory where media files are stored.</param>
|
||||
/// <param name="librariesDirectory">Optional. The directory where media library files are stored.</param>
|
||||
/// <param name="booksDirectory">Optional. The directory where the media item files are stored.</param>
|
||||
/// <param name="musicDirectory">Optional. The directory where the music library item files are stored.</param>
|
||||
/// <returns>The created <see cref="MediaSettingsDto"/>.</returns>
|
||||
public MediaSettingsDto Create(
|
||||
string? rootDirectory = null,
|
||||
string? librariesDirectory = null,
|
||||
string? booksDirectory = null,
|
||||
string? musicDirectory = null)
|
||||
{
|
||||
return new MediaSettingsDto
|
||||
{
|
||||
RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(),
|
||||
LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(),
|
||||
BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath(),
|
||||
MusicDirectory = musicDirectory ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaSettingsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaSettingsDto"/> instances.</returns>
|
||||
public List<MediaSettingsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="HashedFileSystemFileDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HashedFileSystemFileDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="HashedFileSystemFileDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The path of the file system file.</param>
|
||||
/// <param name="size">Optional. The size of the file system file.</param>
|
||||
/// <param name="currentHash">Optional. The current hash obtained by sampling the file system file contents.</param>
|
||||
/// <param name="oldHash">Optional. The old hash of the file system file, stored at the previous scan.</param>
|
||||
/// <param name="ticks">Optional. The time and date when the file system file was last modified, stored in ticks.</param>
|
||||
/// <returns>The created <see cref="HashedFileSystemFileDto"/>.</returns>
|
||||
public HashedFileSystemFileDto Create(
|
||||
string? path = null,
|
||||
long? size = null,
|
||||
ulong? currentHash = null,
|
||||
ulong? oldHash = null,
|
||||
long? ticks = null)
|
||||
{
|
||||
return new HashedFileSystemFileDto
|
||||
{
|
||||
Path = path ?? _faker.System.FilePath(),
|
||||
Size = size ?? _faker.Random.Long(1, 1_000_000),
|
||||
CurrentHash = currentHash ?? _faker.Random.ULong(),
|
||||
OldHash = oldHash ?? _faker.Random.ULong(),
|
||||
Ticks = ticks ?? _faker.Date.Recent().Ticks
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="HashedFileSystemFileDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="HashedFileSystemFileDto"/> instances.</returns>
|
||||
public List<HashedFileSystemFileDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeArchiveDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeArchiveDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeArchiveDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Optional. The bytes of the ZIP archive.</param>
|
||||
/// <param name="fileName">Optional. The file name to expose when downloading the archive.</param>
|
||||
/// <param name="contentType">Optional. The MIME content type of the archive.</param>
|
||||
/// <returns>The created <see cref="ThemeArchiveDto"/>.</returns>
|
||||
public ThemeArchiveDto Create(
|
||||
byte[]? bytes = null,
|
||||
string? fileName = null,
|
||||
string? contentType = null)
|
||||
{
|
||||
return new ThemeArchiveDto(
|
||||
bytes ?? _faker.Random.Bytes(10),
|
||||
fileName ?? _faker.System.FileName(),
|
||||
contentType ?? _faker.System.MimeType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeArchiveDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeArchiveDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Loaded 100 of 6450 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user