Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
/// <summary>
/// Fixture class for the <see cref="GetPermissionsQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPermissionsQueryFixture
{
/// <summary>
/// Creates a random valid query to get permissions.
/// </summary>
/// <returns>The created query.</returns>
public GetPermissionsQuery Create()
{
return new GetPermissionsQuery();
}
/// <summary>
/// Creates a list of <see cref="GetPermissionsQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetPermissionsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.AddRole;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Commands.AddRole;
/// <summary>
/// Fixture class for the <see cref="AddRoleCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddRoleCommandFixture
{
/// <summary>
/// Creates a random valid command to add a role.
/// </summary>
/// <param name="roleName">Optional. The role name.</param>
/// <param name="permissions">Optional. The permission Ids to assign.</param>
/// <param name="permissionCount">The number of permissions to generate when none are provided.</param>
/// <returns>The created command to add a role.</returns>
public AddRoleCommand Create(
string? roleName = null,
IEnumerable<Guid>? permissions = null,
int permissionCount = 3)
{
Faker<AddRoleCommand> faker = new Faker<AddRoleCommand>()
.CustomInstantiator(f => new AddRoleCommand(
default!,
default!))
.RuleFor(x => x.RoleName, f => roleName ?? f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.Permissions, f => [.. permissions ?? Enumerable.Range(0, permissionCount).Select(_ => Guid.NewGuid())]);
return faker.Generate();
}
/// <summary>
/// Creates a list of <see cref="AddRoleCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddRoleCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Commands.DeleteRole;
/// <summary>
/// Fixture class for the <see cref="DeleteRoleCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteRoleCommandFixture
{
/// <summary>
/// Creates a random valid command to delete a role.
/// </summary>
/// <param name="roleId">Optional. The role Id.</param>
/// <returns>The created command.</returns>
public DeleteRoleCommand Create(Guid? roleId = null)
{
return new Faker<DeleteRoleCommand>()
.CustomInstantiator(f => new DeleteRoleCommand(
roleId ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="DeleteRoleCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<DeleteRoleCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.UpdateRole;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Commands.UpdateRole;
/// <summary>
/// Fixture class for the <see cref="UpdateRoleCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateRoleCommandFixture
{
/// <summary>
/// Creates a random valid command to update a role.
/// </summary>
/// <param name="roleId">Optional. The role Id.</param>
/// <param name="roleName">Optional. The role name.</param>
/// <param name="permissions">Optional. The permission Ids to assign.</param>
/// <param name="permissionCount">The number of permissions to generate when none are provided.</param>
/// <returns>The created command to update a role.</returns>
public UpdateRoleCommand Create(
Guid? roleId = null,
string? roleName = null,
IEnumerable<Guid>? permissions = null,
int permissionCount = 3)
{
return new Faker<UpdateRoleCommand>()
.CustomInstantiator(f => new UpdateRoleCommand(
default,
default!,
default!))
.RuleFor(x => x.RoleId, f => roleId ?? Guid.NewGuid())
.RuleFor(x => x.RoleName, f => roleName ?? f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.Permissions, f => [.. permissions ?? Enumerable.Range(0, permissionCount).Select(_ => Guid.NewGuid())])
.Generate();
}
/// <summary>
/// Creates a list of <see cref="UpdateRoleCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateRoleCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
/// <summary>
/// Fixture class for the <see cref="GetRolePermissionsQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRolePermissionsQueryFixture
{
/// <summary>
/// Creates a random valid query to get role permissions.
/// </summary>
/// <param name="roleId">Optional. The role Id.</param>
/// <returns>The created query.</returns>
public GetRolePermissionsQuery Create(Guid? roleId = null)
{
return new Faker<GetRolePermissionsQuery>()
.CustomInstantiator(f => new GetRolePermissionsQuery(
roleId ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="GetRolePermissionsQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetRolePermissionsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRoles;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Queries.GetRoles;
/// <summary>
/// Fixture class for the <see cref="GetRolesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRolesQueryFixture
{
/// <summary>
/// Creates a random valid query to get roles.
/// </summary>
/// <returns>The created query.</returns>
public GetRolesQuery Create()
{
return new GetRolesQuery();
}
/// <summary>
/// Creates a list of <see cref="GetRolesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetRolesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Favorites.Commands.AddFavorite;
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.Core.Favorites.Commands.AddFavorite;
/// <summary>
/// Fixture class for the <see cref="AddFavoriteCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddFavoriteCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="AddFavoriteCommand"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of the media item to favorite. Defaults to a supported kind.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the media item to favorite.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AddFavoriteCommand"/>.</returns>
public AddFavoriteCommand Create(
FavoriteMediaKind? mediaKind = null,
Guid? mediaItemId = null,
bool includeMediaKind = true,
bool includeMediaItemId = true)
{
return new AddFavoriteCommand(
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid()) : null);
}
/// <summary>
/// Creates a list of <see cref="AddFavoriteCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AddFavoriteCommand"/> instances.</returns>
public List<AddFavoriteCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Favorites.Commands.RemoveFavorite;
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.Core.Favorites.Commands.RemoveFavorite;
/// <summary>
/// Fixture class for the <see cref="RemoveFavoriteCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RemoveFavoriteCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RemoveFavoriteCommand"/>.
/// </summary>
/// <param name="mediaKind">Optional. The name of the kind of the favorited media item. Defaults to the name of a supported kind.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the favorited media item.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="RemoveFavoriteCommand"/>.</returns>
public RemoveFavoriteCommand Create(
string? mediaKind = null,
string? mediaItemId = null,
bool includeMediaKind = true,
bool includeMediaItemId = true)
{
return new RemoveFavoriteCommand(
includeMediaKind ? (mediaKind ?? nameof(FavoriteMediaKind.MusicTrack)) : null,
includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="RemoveFavoriteCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RemoveFavoriteCommand"/> instances.</returns>
public List<RemoveFavoriteCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Favorites.Queries.GetFavoriteStatus;
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.Core.Favorites.Queries.GetFavoriteStatus;
/// <summary>
/// Fixture class for the <see cref="GetFavoriteStatusQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetFavoriteStatusQueryFixture
{
private const int DEFAULT_MEDIA_ITEM_COUNT = 3;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GetFavoriteStatusQuery"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of the media items to check. Defaults to a supported kind.</param>
/// <param name="mediaItemIds">Optional. The unique identifiers of the media items to check. Defaults to a bounded list of random Ids.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemIds">Whether the media item Ids should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetFavoriteStatusQuery"/>.</returns>
public GetFavoriteStatusQuery Create(
FavoriteMediaKind? mediaKind = null,
IReadOnlyList<Guid>? mediaItemIds = null,
bool includeMediaKind = true,
bool includeMediaItemIds = true)
{
return new GetFavoriteStatusQuery(
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
includeMediaItemIds ? (mediaItemIds ?? CreateRandomMediaItemIds()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetFavoriteStatusQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetFavoriteStatusQuery"/> instances.</returns>
public List<GetFavoriteStatusQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a bounded list of random media item Ids.
/// </summary>
/// <returns>The created list of media item Ids.</returns>
private List<Guid> CreateRandomMediaItemIds()
{
return [.. Enumerable.Range(0, DEFAULT_MEDIA_ITEM_COUNT).Select(_ => _faker.Random.Guid())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.Favorites.Queries.GetFavorites;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Favorites.Queries.GetFavorites;
/// <summary>
/// Fixture class for the <see cref="GetFavoritesQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetFavoritesQueryFixture
{
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="GetFavoritesQuery"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of media item to restrict the favorites to. Defaults to a supported kind.</param>
/// <param name="paginationData">Optional. The object containing the requested pagination data. Defaults to a random page.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetFavoritesQuery"/>.</returns>
public GetFavoritesQuery Create(
FavoriteMediaKind? mediaKind = null,
PaginationDataDto? paginationData = null,
bool includeMediaKind = true,
bool includePaginationData = true)
{
return new GetFavoritesQuery(
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetFavoritesQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetFavoritesQuery"/> instances.</returns>
public List<GetFavoritesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Directories.Queries.GetDirectories;
/// <summary>
/// Fixture class for the <see cref="GetDirectoriesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDirectoriesQueryFixture
{
/// <summary>
/// Creates a random valid query to get directories.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="shouldIncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <returns>The created query to get directories.</returns>
public GetDirectoriesQuery Create(string? path = null, bool shouldIncludeHiddenElements = false)
{
return new Faker<GetDirectoriesQuery>()
.CustomInstantiator(f => new GetDirectoriesQuery(
default!,
default
))
.RuleFor(x => x.Path, f => path ?? f.System.DirectoryPath())
.RuleFor(x => x.ShouldIncludeHiddenElements, f => shouldIncludeHiddenElements);
}
/// <summary>
/// Creates a list of <see cref="GetDirectoriesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetDirectoriesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Drives.Queries.GetDrives;
/// <summary>
/// Fixture class for the <see cref="GetDrivesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDrivesQueryFixture
{
/// <summary>
/// Creates a random valid query to get drives.
/// </summary>
/// <returns>The created query.</returns>
public GetDrivesQuery Create()
{
return new GetDrivesQuery();
}
/// <summary>
/// Creates a list of <see cref="GetDrivesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetDrivesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
/// <summary>
/// Fixture class for the <see cref="GetFileSystemQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetFileSystemQueryFixture
{
/// <summary>
/// Creates a random valid query to get the file system.
/// </summary>
/// <returns>The created query.</returns>
public GetFileSystemQuery Create()
{
return new GetFileSystemQuery();
}
/// <summary>
/// Creates a list of <see cref="GetFileSystemQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetFileSystemQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Files.Queries.GetFiles;
/// <summary>
/// Fixture class for the <see cref="GetFilesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetFilesQueryFixture
{
/// <summary>
/// Creates a random valid query to get files.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="shouldIncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <returns>The created query to get files.</returns>
public GetFilesQuery Create(string? path = null, bool shouldIncludeHiddenElements = false)
{
return new Faker<GetFilesQuery>()
.CustomInstantiator(f => new GetFilesQuery(
default!,
default
))
.RuleFor(x => x.Path, f => path ?? f.System.FilePath())
.RuleFor(x => x.ShouldIncludeHiddenElements, f => shouldIncludeHiddenElements);
}
/// <summary>
/// Creates a list of <see cref="GetFilesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetFilesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
/// <summary>
/// Fixture class for the <see cref="GetTreeFilesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTreeFilesQueryFixture
{
/// <summary>
/// Creates a random valid query to get tree files.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="shouldIncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <returns>The created query to get tree files.</returns>
public GetTreeFilesQuery Create(string? path = null, bool shouldIncludeHiddenElements = false)
{
return new Faker<GetTreeFilesQuery>()
.CustomInstantiator(f => new GetTreeFilesQuery(
default!,
default
))
.RuleFor(x => x.Path, f => path ?? f.System.FilePath())
.RuleFor(x => x.ShouldIncludeHiddenElements, f => shouldIncludeHiddenElements);
}
/// <summary>
/// Creates a list of <see cref="GetTreeFilesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetTreeFilesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Commands.CombinePath;
/// <summary>
/// Fixture class for the <see cref="CombinePathCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CombinePathCommandFixture
{
/// <summary>
/// Creates a random valid command to combine paths.
/// </summary>
/// <param name="originalPath">Optional. The original path.</param>
/// <param name="newPath">Optional. The new path to combine.</param>
/// <returns>The created command.</returns>
public CombinePathCommand Create(string? originalPath = null, string? newPath = null)
{
return new Faker<CombinePathCommand>()
.CustomInstantiator(f => new CombinePathCommand(
default!,
default!))
.RuleFor(x => x.OriginalPath, f => originalPath ?? f.System.FilePath())
.RuleFor(x => x.NewPath, f => newPath ?? f.System.FilePath());
}
/// <summary>
/// Creates a list of <see cref="CombinePathCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CombinePathCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Commands.SplitPath;
/// <summary>
/// Fixture class for the <see cref="SplitPathCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class SplitPathCommandFixture
{
/// <summary>
/// Creates a random valid command for splitting paths.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <returns>The created command.</returns>
public SplitPathCommand Create(string? path = null)
{
return new Faker<SplitPathCommand>()
.CustomInstantiator(f => new SplitPathCommand(
default!))
.RuleFor(x => x.Path, f => path ?? f.System.FilePath());
}
/// <summary>
/// Creates a list of <see cref="SplitPathCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<SplitPathCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
/// <summary>
/// Fixture class for the <see cref="CheckPathExistsQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CheckPathExistsQueryFixture
{
/// <summary>
/// Creates a random valid query to check if paths exist.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="shouldIncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created query.</returns>
public CheckPathExistsQuery Create(string? path = null, bool shouldIncludeHiddenElements = true, bool includePath = true)
{
return new Faker<CheckPathExistsQuery>()
.CustomInstantiator(f => new CheckPathExistsQuery(
default!,
default
))
.RuleFor(x => x.Path, f => includePath ? (path ?? f.System.FilePath()) : null)
.RuleFor(x => x.ShouldIncludeHiddenElements, shouldIncludeHiddenElements);
}
/// <summary>
/// Creates a list of <see cref="CheckPathExistsQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CheckPathExistsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Queries.GetPathParent;
/// <summary>
/// Fixture class for the <see cref="GetPathParentQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPathParentQueryFixture
{
/// <summary>
/// Creates a random valid query to get the parent of a path.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <returns>The created query.</returns>
public GetPathParentQuery Create(string? path = null)
{
return new Faker<GetPathParentQuery>()
.CustomInstantiator(f => new GetPathParentQuery(
default!))
.RuleFor(x => x.Path, f => path ?? f.System.FilePath());
}
/// <summary>
/// Creates a list of <see cref="GetPathParentQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetPathParentQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
/// <summary>
/// Fixture class for the <see cref="GetPathRootQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPathRootQueryFixture
{
/// <summary>
/// Creates a random valid query to get the root of a path.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <returns>The created query.</returns>
public GetPathRootQuery Create(string? path = null)
{
return new Faker<GetPathRootQuery>()
.CustomInstantiator(f => new GetPathRootQuery(
default!))
.RuleFor(x => x.Path, f => path ?? f.System.FilePath());
}
/// <summary>
/// Creates a list of <see cref="GetPathRootQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetPathRootQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Paths.Queries.ValidatePath;
/// <summary>
/// Fixture class for the <see cref="ValidatePathQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ValidatePathQueryFixture
{
/// <summary>
/// Creates a random valid query to validate a path.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created query.</returns>
public ValidatePathQuery Create(string? path = null, bool includePath = true)
{
return new Faker<ValidatePathQuery>()
.CustomInstantiator(f => new ValidatePathQuery(
default!))
.RuleFor(x => x.Path, f => includePath ? (path ?? f.System.FilePath()) : null);
}
/// <summary>
/// Creates a list of <see cref="ValidatePathQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ValidatePathQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
/// <summary>
/// Fixture class for the <see cref="GetThumbnailQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetThumbnailQueryFixture
{
/// <summary>
/// Creates a random valid query to get a thumbnail.
/// </summary>
/// <param name="path">Optional. The file system path.</param>
/// <param name="quality">Optional. The thumbnail quality.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created query.</returns>
public GetThumbnailQuery Create(string? path = null, int? quality = null, bool includePath = true)
{
return new Faker<GetThumbnailQuery>()
.CustomInstantiator(f => new GetThumbnailQuery(
default!,
default
))
.RuleFor(x => x.Path, f => includePath ? (path ?? f.System.FilePath()) : null)
.RuleFor(x => x.Quality, f => quality ?? f.Random.Int());
}
/// <summary>
/// Creates a list of <see cref="GetThumbnailQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetThumbnailQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
/// <summary>
/// Fixture class for the <see cref="SetupApplicationCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class SetupApplicationCommandFixture
{
/// <summary>
/// Creates a random valid command for the application setup.
/// </summary>
/// <param name="username">Optional. The admin username.</param>
/// <param name="password">Optional. The admin password.</param>
/// <param name="passwordConfirm">Optional. The admin password confirmation.</param>
/// <param name="use2fa">Whether to use two-factor authentication.</param>
/// <returns>The created command.</returns>
public SetupApplicationCommand Create(
string? username = null,
string? password = null,
string? passwordConfirm = null,
bool use2fa = true)
{
string resolvedPassword = password ?? "Abcd123$";
return new Faker<SetupApplicationCommand>()
.CustomInstantiator(f => new SetupApplicationCommand(
default!,
default!,
default!,
true
))
.RuleFor(x => x.Username, f => username ?? f.Internet.UserName())
.RuleFor(x => x.Password, resolvedPassword)
.RuleFor(x => x.PasswordConfirm, passwordConfirm ?? resolvedPassword)
.RuleFor(x => x.Use2fa, use2fa)
.Generate();
}
/// <summary>
/// Creates a list of <see cref="SetupApplicationCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<SetupApplicationCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
/// <summary>
/// Fixture class for the <see cref="CheckInitializationQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CheckInitializationQueryFixture
{
/// <summary>
/// Creates a <see cref="CheckInitializationQuery"/>.
/// </summary>
/// <returns>The created <see cref="CheckInitializationQuery"/>.</returns>
public CheckInitializationQuery Create()
{
return new CheckInitializationQuery();
}
/// <summary>
/// Creates a list of <see cref="CheckInitializationQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CheckInitializationQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.ClearConsumptionHistory;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearConsumptionHistory;
/// <summary>
/// Fixture class for the <see cref="ClearConsumptionHistoryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ClearConsumptionHistoryCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ClearConsumptionHistoryCommand"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose consumption history is cleared. Defaults to a random user Id.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
/// <returns>The created <see cref="ClearConsumptionHistoryCommand"/>.</returns>
public ClearConsumptionHistoryCommand Create(
string? targetUserId = null,
bool includeTargetUserId = true)
{
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
return new ClearConsumptionHistoryCommand(resolvedTargetUserId);
}
/// <summary>
/// Creates a list of <see cref="ClearConsumptionHistoryCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ClearConsumptionHistoryCommand"/> instances.</returns>
public List<ClearConsumptionHistoryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.ClearResumePoints;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearResumePoints;
/// <summary>
/// Fixture class for the <see cref="ClearResumePointsCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ClearResumePointsCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ClearResumePointsCommand"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose resume points are cleared. Defaults to a random user Id.</param>
/// <param name="libraryId">Optional. The Id of the media library the deletion is restricted to. Defaults to a random library Id.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/> so that every library is cleared.</param>
/// <returns>The created <see cref="ClearResumePointsCommand"/>.</returns>
public ClearResumePointsCommand Create(
string? targetUserId = null,
string? libraryId = null,
bool includeTargetUserId = true,
bool includeLibraryId = true)
{
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
string? resolvedLibraryId = includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null;
return new ClearResumePointsCommand(resolvedTargetUserId, resolvedLibraryId);
}
/// <summary>
/// Creates a list of <see cref="ClearResumePointsCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ClearResumePointsCommand"/> instances.</returns>
public List<ClearResumePointsCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,91 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.CompleteConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.CompleteConsumption;
/// <summary>
/// Fixture class for the <see cref="CompleteConsumptionCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CompleteConsumptionCommandFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="CompleteConsumptionCommand"/>.
/// </summary>
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
/// <param name="positionKind">Optional. The name of the kind of the final position. Defaults to a time offset.</param>
/// <param name="positionTimeOffsetInSeconds">Optional. The final position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
/// <param name="positionLocation">Optional. The final opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
/// <param name="progressFraction">Optional. The final progress fraction. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to no value.</param>
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsecutivePagesRead">Whether the consecutive pages count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="CompleteConsumptionCommand"/>.</returns>
public CompleteConsumptionCommand Create(
string? consumptionRecordId = null,
string? positionKind = null,
double? positionTimeOffsetInSeconds = null,
string? positionLocation = null,
double? progressFraction = null,
double? consumedDurationInSeconds = null,
int? consecutivePagesRead = null,
bool includeConsumptionRecordId = true,
bool includePositionKind = true,
bool includePositionTimeOffsetInSeconds = true,
bool includePositionLocation = true,
bool includeProgressFraction = true,
bool includeConsumedDurationInSeconds = true,
bool includeConsecutivePagesRead = true)
{
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedPositionLocation = includePositionLocation
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
: null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
int? resolvedConsecutivePagesRead = includeConsecutivePagesRead ? consecutivePagesRead : null;
return new CompleteConsumptionCommand(
resolvedConsumptionRecordId,
resolvedPositionKind,
resolvedPositionTimeOffsetInSeconds,
resolvedPositionLocation,
resolvedProgressFraction,
resolvedConsumedDurationInSeconds,
resolvedConsecutivePagesRead);
}
/// <summary>
/// Creates a list of <see cref="CompleteConsumptionCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="CompleteConsumptionCommand"/> instances.</returns>
public List<CompleteConsumptionCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.DeleteConsumptionItemHistory;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.DeleteConsumptionItemHistory;
/// <summary>
/// Fixture class for the <see cref="DeleteConsumptionItemHistoryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteConsumptionItemHistoryCommandFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="DeleteConsumptionItemHistoryCommand"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user the records must belong to. Defaults to a random user Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of the consumed media item. Defaults to the name of a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item. Defaults to a random Id.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteConsumptionItemHistoryCommand"/>.</returns>
public DeleteConsumptionItemHistoryCommand Create(
string? targetUserId = null,
string? mediaKind = null,
string? mediaItemId = null,
string? libraryId = null,
bool includeTargetUserId = true,
bool includeMediaKind = true,
bool includeMediaItemId = true,
bool includeLibraryId = true)
{
return new DeleteConsumptionItemHistoryCommand(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteConsumptionItemHistoryCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteConsumptionItemHistoryCommand"/> instances.</returns>
public List<DeleteConsumptionItemHistoryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
/// <summary>
/// Fixture class for the <see cref="DeleteConsumptionRecordCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteConsumptionRecordCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="DeleteConsumptionRecordCommand"/>.
/// </summary>
/// <param name="consumptionRecordId">Optional. The Id of the consumption record to delete, taken from the route. Defaults to a random Id.</param>
/// <param name="targetUserId">Optional. The Id of the user the record must belong to. Defaults to a random user Id.</param>
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
/// <returns>The created <see cref="DeleteConsumptionRecordCommand"/>.</returns>
public DeleteConsumptionRecordCommand Create(
string? consumptionRecordId = null,
string? targetUserId = null,
bool includeConsumptionRecordId = true,
bool includeTargetUserId = true)
{
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
return new DeleteConsumptionRecordCommand(resolvedConsumptionRecordId, resolvedTargetUserId);
}
/// <summary>
/// Creates a list of <see cref="DeleteConsumptionRecordCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteConsumptionRecordCommand"/> instances.</returns>
public List<DeleteConsumptionRecordCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,88 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.ReportConsumptionProgress;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ReportConsumptionProgress;
/// <summary>
/// Fixture class for the <see cref="ReportConsumptionProgressCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReportConsumptionProgressCommandFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ReportConsumptionProgressCommand"/>.
/// </summary>
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
/// <param name="positionKind">Optional. The name of the kind of the reported position. Defaults to a time offset.</param>
/// <param name="positionTimeOffsetInSeconds">Optional. The reported position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
/// <param name="positionLocation">Optional. The reported opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
/// <param name="progressFraction">Optional. The reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the current session. Defaults to zero.</param>
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ReportConsumptionProgressCommand"/>.</returns>
public ReportConsumptionProgressCommand Create(
string? consumptionRecordId = null,
string? positionKind = null,
double? positionTimeOffsetInSeconds = null,
string? positionLocation = null,
double? progressFraction = null,
double? consumedDurationInSeconds = null,
int consecutivePagesRead = 0,
bool includeConsumptionRecordId = true,
bool includePositionKind = true,
bool includePositionTimeOffsetInSeconds = true,
bool includePositionLocation = true,
bool includeProgressFraction = true,
bool includeConsumedDurationInSeconds = true)
{
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedPositionLocation = includePositionLocation
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
: null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
return new ReportConsumptionProgressCommand(
resolvedConsumptionRecordId,
resolvedPositionKind,
resolvedPositionTimeOffsetInSeconds,
resolvedPositionLocation,
resolvedProgressFraction,
resolvedConsumedDurationInSeconds,
consecutivePagesRead);
}
/// <summary>
/// Creates a list of <see cref="ReportConsumptionProgressCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ReportConsumptionProgressCommand"/> instances.</returns>
public List<ReportConsumptionProgressCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.StartConsumption;
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.Core.MediaConsumption.Commands.StartConsumption;
/// <summary>
/// Fixture class for the <see cref="StartConsumptionCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class StartConsumptionCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="StartConsumptionCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item, taken from the route.</param>
/// <param name="mediaKind">Optional. The kind of media that is consumed, taken from the route. Defaults to the name of a kind supported by the current catalogues.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="StartConsumptionCommand"/>.</returns>
public StartConsumptionCommand Create(
string? libraryId = null,
string? mediaKind = null,
string? mediaItemId = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeMediaItemId = true)
{
string? resolvedLibraryId = includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null;
string? resolvedMediaKind = includeMediaKind ? mediaKind ?? nameof(MediaKind.MusicTrack) : null;
string? resolvedMediaItemId = includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null;
return new StartConsumptionCommand(resolvedLibraryId, resolvedMediaKind, resolvedMediaItemId);
}
/// <summary>
/// Creates a list of <see cref="StartConsumptionCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="StartConsumptionCommand"/> instances.</returns>
public List<StartConsumptionCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,91 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Commands.StopConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.StopConsumption;
/// <summary>
/// Fixture class for the <see cref="StopConsumptionCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class StopConsumptionCommandFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="StopConsumptionCommand"/>.
/// </summary>
/// <param name="consumptionRecordId">Optional. The Id of the consumption record, taken from the route.</param>
/// <param name="positionKind">Optional. The name of the kind of the final position. Defaults to a time offset.</param>
/// <param name="positionTimeOffsetInSeconds">Optional. The final position, in seconds, when it is a time offset. Defaults to a bounded non-negative offset for a time offset position.</param>
/// <param name="positionLocation">Optional. The final opaque locator, when the position is not a time offset. Defaults to a random word for a location position.</param>
/// <param name="progressFraction">Optional. The final progress fraction. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to no value.</param>
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionKind">Whether the position kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionTimeOffsetInSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePositionLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeProgressFraction">Whether the progress fraction should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsecutivePagesRead">Whether the consecutive pages count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="StopConsumptionCommand"/>.</returns>
public StopConsumptionCommand Create(
string? consumptionRecordId = null,
string? positionKind = null,
double? positionTimeOffsetInSeconds = null,
string? positionLocation = null,
double? progressFraction = null,
double? consumedDurationInSeconds = null,
int? consecutivePagesRead = null,
bool includeConsumptionRecordId = true,
bool includePositionKind = true,
bool includePositionTimeOffsetInSeconds = true,
bool includePositionLocation = true,
bool includeProgressFraction = true,
bool includeConsumedDurationInSeconds = true,
bool includeConsecutivePagesRead = true)
{
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
string? resolvedPositionKind = includePositionKind ? positionKind ?? nameof(MediaPositionKind.TimeOffset) : null;
bool isTimeOffset = resolvedPositionKind == nameof(MediaPositionKind.TimeOffset);
bool isLocation = resolvedPositionKind == nameof(MediaPositionKind.Location);
double? resolvedPositionTimeOffsetInSeconds = includePositionTimeOffsetInSeconds
? positionTimeOffsetInSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedPositionLocation = includePositionLocation
? positionLocation ?? (isLocation ? _faker.Lorem.Word() : (string?)null)
: null;
double? resolvedProgressFraction = includeProgressFraction ? progressFraction ?? _faker.Random.Double(0, 1) : null;
double? resolvedConsumedDurationInSeconds = includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : null;
int? resolvedConsecutivePagesRead = includeConsecutivePagesRead ? consecutivePagesRead : null;
return new StopConsumptionCommand(
resolvedConsumptionRecordId,
resolvedPositionKind,
resolvedPositionTimeOffsetInSeconds,
resolvedPositionLocation,
resolvedProgressFraction,
resolvedConsumedDurationInSeconds,
resolvedConsecutivePagesRead);
}
/// <summary>
/// Creates a list of <see cref="StopConsumptionCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="StopConsumptionCommand"/> instances.</returns>
public List<StopConsumptionCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetAllUsersConsumptionStatistics;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetAllUsersConsumptionStatistics;
/// <summary>
/// Fixture class for the <see cref="GetAllUsersConsumptionStatisticsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAllUsersConsumptionStatisticsQueryFixture
{
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="GetAllUsersConsumptionStatisticsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAllUsersConsumptionStatisticsQuery"/>.</returns>
public GetAllUsersConsumptionStatisticsQuery Create(
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetAllUsersConsumptionStatisticsQuery(
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetAllUsersConsumptionStatisticsQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAllUsersConsumptionStatisticsQuery"/> instances.</returns>
public List<GetAllUsersConsumptionStatisticsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetConsumptionRecord;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetConsumptionRecord;
/// <summary>
/// Fixture class for the <see cref="GetConsumptionRecordQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetConsumptionRecordQueryFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GetConsumptionRecordQuery"/>.
/// </summary>
/// <param name="consumptionRecordId">Optional. The Id of the consumption record to read, taken from the route. Defaults to a random Id.</param>
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetConsumptionRecordQuery"/>.</returns>
public GetConsumptionRecordQuery Create(
string? consumptionRecordId = null,
bool includeConsumptionRecordId = true)
{
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
return new GetConsumptionRecordQuery(resolvedConsumptionRecordId);
}
/// <summary>
/// Creates a list of <see cref="GetConsumptionRecordQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetConsumptionRecordQuery"/> instances.</returns>
public List<GetConsumptionRecordQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetConsumptionStatistics;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetConsumptionStatistics;
/// <summary>
/// Fixture class for the <see cref="GetConsumptionStatisticsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetConsumptionStatisticsQueryFixture
{
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="GetConsumptionStatisticsQuery"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetConsumptionStatisticsQuery"/>.</returns>
public GetConsumptionStatisticsQuery Create(
string? targetUserId = null,
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetConsumptionStatisticsQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetConsumptionStatisticsQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetConsumptionStatisticsQuery"/> instances.</returns>
public List<GetConsumptionStatisticsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetGenreConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetGenreConsumption;
/// <summary>
/// Fixture class for the <see cref="GetGenreConsumptionQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetGenreConsumptionQueryFixture
{
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="GetGenreConsumptionQuery"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment in the future, as a text value.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetGenreConsumptionQuery"/>.</returns>
public GetGenreConsumptionQuery Create(
string? targetUserId = null,
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetGenreConsumptionQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetGenreConsumptionQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetGenreConsumptionQuery"/> instances.</returns>
public List<GetGenreConsumptionQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,87 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaConsumption.Queries.GetMostConsumed;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetMostConsumed;
/// <summary>
/// Fixture class for the <see cref="GetMostConsumedQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetMostConsumedQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = 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="GetMostConsumedQuery"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetMostConsumedQuery"/>.</returns>
public GetMostConsumedQuery Create(
string? targetUserId = null,
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
PaginationDataDto? paginationData = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true,
bool includePaginationData = false)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetMostConsumedQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null,
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
}
/// <summary>
/// Creates a list of <see cref="GetMostConsumedQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetMostConsumedQuery"/> instances.</returns>
public List<GetMostConsumedQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,87 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaConsumption.Queries.GetRecentlyConsumed;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetRecentlyConsumed;
/// <summary>
/// Fixture class for the <see cref="GetRecentlyConsumedQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRecentlyConsumedQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = 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="GetRecentlyConsumedQuery"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose history is retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the history to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the history to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="paginationData">Optional. The requested pagination data. Defaults to a random page when it is included.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetRecentlyConsumedQuery"/>.</returns>
public GetRecentlyConsumedQuery Create(
string? targetUserId = null,
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
PaginationDataDto? paginationData = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true,
bool includePaginationData = false)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetRecentlyConsumedQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null,
includePaginationData ? paginationData ?? _paginationDataDtoFixture.Create() : null);
}
/// <summary>
/// Creates a list of <see cref="GetRecentlyConsumedQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetRecentlyConsumedQuery"/> instances.</returns>
public List<GetRecentlyConsumedQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetResumePoint;
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.Core.MediaConsumption.Queries.GetResumePoint;
/// <summary>
/// Fixture class for the <see cref="GetResumePointQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetResumePointQueryFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GetResumePointQuery"/>.
/// </summary>
/// <param name="mediaKind">Optional. The name of the kind of media to resume, taken from the route. Defaults to a resumable kind supported by the current catalogues.</param>
/// <param name="mediaItemId">Optional. The Id of the media item to resume, taken from the route. Defaults to a random Id.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetResumePointQuery"/>.</returns>
public GetResumePointQuery Create(
string? mediaKind = null,
string? mediaItemId = null,
bool includeMediaKind = true,
bool includeMediaItemId = true)
{
string? resolvedMediaKind = includeMediaKind ? mediaKind ?? nameof(MediaKind.MusicTrack) : null;
string? resolvedMediaItemId = includeMediaItemId ? mediaItemId ?? _faker.Random.Guid().ToString() : null;
return new GetResumePointQuery(resolvedMediaKind, resolvedMediaItemId);
}
/// <summary>
/// Creates a list of <see cref="GetResumePointQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetResumePointQuery"/> instances.</returns>
public List<GetResumePointQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaConsumption.Queries.GetTagConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Queries.GetTagConsumption;
/// <summary>
/// Fixture class for the <see cref="GetTagConsumptionQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTagConsumptionQueryFixture
{
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="GetTagConsumptionQuery"/>.
/// </summary>
/// <param name="targetUserId">Optional. The Id of the user whose statistics are retrieved. Defaults to a random Id.</param>
/// <param name="libraryId">Optional. The Id of the media library to restrict the statistics to. Defaults to a random Id.</param>
/// <param name="mediaKind">Optional. The name of the kind of media to restrict the statistics to. Defaults to the name of a random supported kind.</param>
/// <param name="fromUtc">Optional. The inclusive start of the date range. Defaults to a bounded UTC moment in the past, as a text value.</param>
/// <param name="toUtc">Optional. The inclusive end of the date range. Defaults to a bounded UTC moment, as a text value.</param>
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFromUtc">Whether the start of the date range should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeToUtc">Whether the end of the date range should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetTagConsumptionQuery"/>.</returns>
public GetTagConsumptionQuery Create(
string? targetUserId = null,
string? libraryId = null,
string? mediaKind = null,
string? fromUtc = null,
string? toUtc = null,
bool includeTargetUserId = true,
bool includeLibraryId = true,
bool includeMediaKind = true,
bool includeFromUtc = true,
bool includeToUtc = true)
{
string resolvedFromUtc = fromUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
string resolvedToUtc = toUtc ?? DateTime.UtcNow.AddDays(_faker.Random.Int(1, 30)).ToString("o", CultureInfo.InvariantCulture);
return new GetTagConsumptionQuery(
includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null,
includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null,
includeMediaKind ? mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds).ToString() : null,
includeFromUtc ? resolvedFromUtc : null,
includeToUtc ? resolvedToUtc : null);
}
/// <summary>
/// Creates a list of <see cref="GetTagConsumptionQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetTagConsumptionQuery"/> instances.</returns>
public List<GetTagConsumptionQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,145 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.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.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
/// <summary>
/// Fixture class for the <see cref="AddAlbumCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddAlbumCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
private readonly AddTrackCommandFixture _addTrackCommandFixture = new();
/// <summary>
/// Creates a random valid command to add an album.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="contributors">Optional. The media contributors that performed on the album.</param>
/// <param name="ratings">Optional. The ratings of the album.</param>
/// <param name="tracks">Optional. The tracks of the album.</param>
/// <param name="albumId">Optional. The Id of the album, when it already exists.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata 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="includePackaging">Whether the packaging 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="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTracks">Whether the tracks should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add an album.</returns>
public AddAlbumCommand Create(
string? libraryId = null,
string? artistId = null,
MusicAlbumMetadataDto? metadata = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<AddTrackCommand>? tracks = null,
Guid? albumId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeMetadata = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeBarcode = true,
bool includeCatalogNumbers = true,
bool includeLabel = true,
bool includeAsin = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseArtistId = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeTracks = true,
bool includeAlbumId = true)
{
string? resolvedLibraryId = includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null;
string? resolvedArtistId = includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null;
return new AddAlbumCommand(
resolvedLibraryId,
resolvedArtistId,
includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(_faker.Random.Int(12, 13), "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeTracks ? (tracks ?? GenerateTracks(resolvedLibraryId, resolvedArtistId)) : null,
includeAlbumId ? (albumId ?? _faker.Random.Guid()) : null);
}
/// <summary>
/// Creates a list of <see cref="AddAlbumCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddAlbumCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates the tracks of the album, tied to the album's library and artist identifiers.
/// </summary>
/// <param name="libraryId">The Id of the media library the tracks belong to.</param>
/// <param name="artistId">The Id of the artist the tracks belong to.</param>
/// <returns>The generated tracks.</returns>
private List<AddTrackCommand> GenerateTracks(string? libraryId, string? artistId)
{
return [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _addTrackCommandFixture.Create(libraryId: libraryId, artistId: artistId))];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.DeleteAlbum;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.DeleteAlbum;
/// <summary>
/// Fixture class for the <see cref="DeleteAlbumCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteAlbumCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="DeleteAlbumCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album to delete, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteAlbumCommand"/>.</returns>
public DeleteAlbumCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true)
{
return new DeleteAlbumCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteAlbumCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteAlbumCommand"/> instances.</returns>
public List<DeleteAlbumCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.RestoreAlbum;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.RestoreAlbum;
/// <summary>
/// Fixture class for the <see cref="RestoreAlbumCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreAlbumCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="RestoreAlbumCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the deleted album to restore, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="RestoreAlbumCommand"/>.</returns>
public RestoreAlbumCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true)
{
return new RestoreAlbumCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="RestoreAlbumCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RestoreAlbumCommand"/> instances.</returns>
public List<RestoreAlbumCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,123 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbum;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.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.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbum;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid command to update an album.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album to update, taken from the route.</param>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="contributors">Optional. The media contributors that performed on the album.</param>
/// <param name="ratings">Optional. The ratings of the album.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata 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="includePackaging">Whether the packaging 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="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to update an album.</returns>
public UpdateAlbumCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
MusicAlbumMetadataDto? metadata = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeMetadata = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeBarcode = true,
bool includeCatalogNumbers = true,
bool includeLabel = true,
bool includeAsin = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseArtistId = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new UpdateAlbumCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(_faker.Random.Int(12, 13), "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateAlbumCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,72 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbumCover;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbumCover;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumCoverCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumCoverCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="UpdateAlbumCoverCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
/// <param name="albumId">Optional. The Id of the album whose cover is updated.</param>
/// <param name="cover">Optional. The stream of the uploaded cover image file.</param>
/// <param name="fileName">Optional. The name of the uploaded cover image file.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCover">Whether the cover stream should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFileName">Whether the file name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="UpdateAlbumCoverCommand"/>.</returns>
public UpdateAlbumCoverCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
Stream? cover = null,
string? fileName = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeCover = true,
bool includeFileName = true)
{
return new UpdateAlbumCoverCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeCover ? (cover ?? CreateCoverStream()) : null,
includeFileName ? (fileName ?? "cover.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumCoverCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateAlbumCoverCommand"/> instances.</returns>
public List<UpdateAlbumCoverCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates an in-memory stream carrying a minimal file payload.
/// </summary>
/// <returns>A non-empty in-memory stream.</returns>
private static Stream CreateCoverStream()
{
byte[] payload = Encoding.UTF8.GetBytes("fake cover payload");
return new MemoryStream(payload);
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbum;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbum;
/// <summary>
/// Fixture class for the <see cref="GetAlbumQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAlbumQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetAlbumQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album to get, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAlbumQuery"/>.</returns>
public GetAlbumQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true)
{
return new GetAlbumQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetAlbumQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAlbumQuery"/> instances.</returns>
public List<GetAlbumQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracks;
/// <summary>
/// Fixture class for the <see cref="GetAlbumTracksQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAlbumTracksQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetAlbumTracksQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album whose tracks are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAlbumTracksQuery"/>.</returns>
public GetAlbumTracksQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true)
{
return new GetAlbumTracksQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetAlbumTracksQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAlbumTracksQuery"/> instances.</returns>
public List<GetAlbumTracksQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracksLite;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracksLite;
/// <summary>
/// Fixture class for the <see cref="GetAlbumTracksLiteQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAlbumTracksLiteQueryFixture
{
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="GetAlbumTracksLiteQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album whose tracks are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAlbumTracksLiteQuery"/>.</returns>
public GetAlbumTracksLiteQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
PaginationDataDto? paginationData = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includePaginationData = true)
{
return new GetAlbumTracksLiteQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetAlbumTracksLiteQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAlbumTracksLiteQuery"/> instances.</returns>
public List<GetAlbumTracksLiteQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetDeletedAlbums;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetDeletedAlbums;
/// <summary>
/// Fixture class for the <see cref="GetDeletedAlbumsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDeletedAlbumsQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetDeletedAlbumsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose deleted albums are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetDeletedAlbumsQuery"/>.</returns>
public GetDeletedAlbumsQuery Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new GetDeletedAlbumsQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetDeletedAlbumsQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetDeletedAlbumsQuery"/> instances.</returns>
public List<GetDeletedAlbumsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,107 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist;
using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist;
/// <summary>
/// Fixture class for the <see cref="AddArtistCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddArtistCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid command to add an artist.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="metadata">Optional. The metadata 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="ipis">Optional. The IPI codes of the artist.</param>
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
/// <param name="ratings">Optional. The ratings of the artist.</param>
/// <param name="albums">Optional. The albums of the artist, each with its own tracks.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</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="includeIpis">Whether the IPI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsnis">Whether the ISNI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbums">Whether the albums should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add an artist.</returns>
public AddArtistCommand Create(
string? libraryId = null,
MusicArtistMetadataDto? metadata = null,
string? website = null,
Guid? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<AddAlbumCommand>? albums = null,
bool includeLibraryId = true,
bool includeMetadata = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeAlbums = true)
{
string? resolvedLibraryId = includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null;
return new AddArtistCommand(
resolvedLibraryId,
includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null,
includeWebsite ? (website ?? _faker.Internet.Url()) : null,
includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null,
includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null,
includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeAlbums ? (albums ?? GenerateAlbums(resolvedLibraryId)) : null);
}
/// <summary>
/// Creates a list of <see cref="AddArtistCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddArtistCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates the albums of the artist, tied to the artist's library identifier.
/// </summary>
/// <param name="libraryId">The Id of the media library the albums belong to.</param>
/// <returns>The generated albums.</returns>
private List<AddAlbumCommand> GenerateAlbums(string? libraryId)
{
return [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _addAlbumCommandFixture.Create(libraryId: libraryId))];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.DeleteArtist;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.DeleteArtist;
/// <summary>
/// Fixture class for the <see cref="DeleteArtistCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteArtistCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="DeleteArtistCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist to delete, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteArtistCommand"/>.</returns>
public DeleteArtistCommand Create(
string? libraryId = null,
string? artistId = null,
bool includeLibraryId = true,
bool includeArtistId = true)
{
return new DeleteArtistCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteArtistCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteArtistCommand"/> instances.</returns>
public List<DeleteArtistCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.RestoreArtist;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.RestoreArtist;
/// <summary>
/// Fixture class for the <see cref="RestoreArtistCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreArtistCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="RestoreArtistCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the deleted artist to restore, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="RestoreArtistCommand"/>.</returns>
public RestoreArtistCommand Create(
string? libraryId = null,
string? artistId = null,
bool includeLibraryId = true,
bool includeArtistId = true)
{
return new RestoreArtistCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="RestoreArtistCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RestoreArtistCommand"/> instances.</returns>
public List<RestoreArtistCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,112 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist;
using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid command to update an artist.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist, taken from the route.</param>
/// <param name="metadata">Optional. The metadata 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="ipis">Optional. The IPI codes of the artist.</param>
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
/// <param name="ratings">Optional. The ratings of the artist.</param>
/// <param name="albums">Optional. The albums of the artist, each with its own tracks.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</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="includeIpis">Whether the IPI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsnis">Whether the ISNI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbums">Whether the albums should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to update an artist.</returns>
public UpdateArtistCommand Create(
string? libraryId = null,
string? artistId = null,
MusicArtistMetadataDto? metadata = null,
string? website = null,
Guid? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<AddAlbumCommand>? albums = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeMetadata = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeAlbums = true)
{
string? resolvedLibraryId = includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null;
return new UpdateArtistCommand(
resolvedLibraryId,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null,
includeWebsite ? (website ?? _faker.Internet.Url()) : null,
includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null,
includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null,
includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeAlbums ? (albums ?? GenerateAlbums(resolvedLibraryId)) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates the albums of the artist, tied to the artist's library identifier.
/// </summary>
/// <param name="libraryId">The Id of the media library the albums belong to.</param>
/// <returns>The generated albums.</returns>
private List<AddAlbumCommand> GenerateAlbums(string? libraryId)
{
return [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _addAlbumCommandFixture.Create(libraryId: libraryId))];
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtistCover;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtistCover;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistCoverCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistCoverCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="UpdateArtistCoverCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist whose cover is updated.</param>
/// <param name="cover">Optional. The stream of the uploaded cover image file.</param>
/// <param name="fileName">Optional. The name of the uploaded cover image file.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCover">Whether the cover stream should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFileName">Whether the file name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="UpdateArtistCoverCommand"/>.</returns>
public UpdateArtistCoverCommand Create(
string? libraryId = null,
string? artistId = null,
Stream? cover = null,
string? fileName = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeCover = true,
bool includeFileName = true)
{
return new UpdateArtistCoverCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeCover ? (cover ?? CreateCoverStream()) : null,
includeFileName ? (fileName ?? "cover.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistCoverCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateArtistCoverCommand"/> instances.</returns>
public List<UpdateArtistCoverCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates an in-memory stream carrying a minimal file payload.
/// </summary>
/// <returns>A non-empty in-memory stream.</returns>
private static Stream CreateCoverStream()
{
byte[] payload = Encoding.UTF8.GetBytes("fake cover payload");
return new MemoryStream(payload);
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtist;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtist;
/// <summary>
/// Fixture class for the <see cref="GetArtistQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetArtistQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist to get, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetArtistQuery"/>.</returns>
public GetArtistQuery Create(
string? libraryId = null,
string? artistId = null,
bool includeLibraryId = true,
bool includeArtistId = true)
{
return new GetArtistQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetArtistQuery"/> instances.</returns>
public List<GetArtistQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbums;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbums;
/// <summary>
/// Fixture class for the <see cref="GetArtistAlbumsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistAlbumsQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetArtistAlbumsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist whose albums are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetArtistAlbumsQuery"/>.</returns>
public GetArtistAlbumsQuery Create(
string? libraryId = null,
string? artistId = null,
bool includeLibraryId = true,
bool includeArtistId = true)
{
return new GetArtistAlbumsQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistAlbumsQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetArtistAlbumsQuery"/> instances.</returns>
public List<GetArtistAlbumsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbumsLite;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbumsLite;
/// <summary>
/// Fixture class for the <see cref="GetArtistAlbumsLiteQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistAlbumsLiteQueryFixture
{
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="GetArtistAlbumsLiteQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist whose albums are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetArtistAlbumsLiteQuery"/>.</returns>
public GetArtistAlbumsLiteQuery Create(
string? libraryId = null,
string? artistId = null,
PaginationDataDto? paginationData = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includePaginationData = true)
{
return new GetArtistAlbumsLiteQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistAlbumsLiteQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetArtistAlbumsLiteQuery"/> instances.</returns>
public List<GetArtistAlbumsLiteQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtists;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtists;
/// <summary>
/// Fixture class for the <see cref="GetArtistsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistsQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="GetArtistsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose artists are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="searchTerm">Optional. The search term used to filter the artists by name.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSearchTerm">Whether the search term should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetArtistsQuery"/>.</returns>
public GetArtistsQuery Create(
string? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
bool includeLibraryId = true,
bool includePaginationData = true,
bool includeSearchTerm = true)
{
return new GetArtistsQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null,
includeSearchTerm ? (searchTerm ?? _faker.Name.FullName()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistsQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetArtistsQuery"/> instances.</returns>
public List<GetArtistsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistsLite;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
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.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistsLite;
/// <summary>
/// Fixture class for the <see cref="GetArtistsLiteQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistsLiteQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="GetArtistsLiteQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose artists are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="searchTerm">Optional. The search term used to filter the artists by name.</param>
/// <param name="filterAlphaKey">Optional. The alpha key used to filter the results by the first character of their name, for the alpha picker.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the leading "The " prefix of a name should be ignored when computing the alpha key, or not.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSearchTerm">Whether the search term should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetArtistsLiteQuery"/>.</returns>
public GetArtistsLiteQuery Create(
string? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
string? filterAlphaKey = null,
bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeLibraryId = true,
bool includePaginationData = true,
bool includeSearchTerm = true)
{
return new GetArtistsLiteQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null,
includeSearchTerm ? (searchTerm ?? _faker.Name.FullName()) : null,
filterAlphaKey,
shouldIgnoreThePrefixForAlphaPicker,
sortBy ?? _faker.Lorem.Word(),
sortOrder ?? _faker.PickRandom<SortOrder>());
}
/// <summary>
/// Creates a list of <see cref="GetArtistsLiteQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetArtistsLiteQuery"/> instances.</returns>
public List<GetArtistsLiteQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetDeletedArtists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetDeletedArtists;
/// <summary>
/// Fixture class for the <see cref="GetDeletedArtistsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDeletedArtistsQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetDeletedArtistsQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose deleted artists are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetDeletedArtistsQuery"/>.</returns>
public GetDeletedArtistsQuery Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new GetDeletedArtistsQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetDeletedArtistsQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetDeletedArtistsQuery"/> instances.</returns>
public List<GetDeletedArtistsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,142 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
/// <summary>
/// Fixture class for the <see cref="AddTrackCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddTrackCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid command to add a track.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the track belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to, taken from the route.</param>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="metadata">Optional. The audio metadata 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="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="work">Optional. The work the track is a recording of.</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="moods">Optional. The list of moods of the track.</param>
/// <param name="isrcs">Optional. The list of ISRC of the track.</param>
/// <param name="contributors">Optional. The list of media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The list of ratings for this track.</param>
/// <param name="trackId">Optional. The Id of the track, when it already exists.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add a track.</returns>
public AddTrackCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? path = null,
MusicTrackMetadataDto? metadata = null,
int? trackNumber = null,
int? discNumber = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
MusicWorkDto? work = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
Guid? trackId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includePath = true,
bool includeMetadata = true,
bool includeTrackNumber = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new AddTrackCommand(
includeLibraryId ? libraryId ?? Guid.NewGuid().ToString() : null,
includeArtistId ? artistId ?? Guid.NewGuid().ToString() : null,
includeAlbumId ? albumId ?? Guid.NewGuid().ToString() : null,
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _musicTrackMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeWork ? work ?? _musicWorkDtoFixture.Create() : null,
includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeIsrcs ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
trackId);
}
/// <summary>
/// Creates a list of <see cref="AddTrackCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddTrackCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.DeleteTrack;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.DeleteTrack;
/// <summary>
/// Fixture class for the <see cref="DeleteTrackCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteTrackCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="DeleteTrackCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track to delete.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteTrackCommand"/>.</returns>
public DeleteTrackCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true)
{
return new DeleteTrackCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteTrackCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<DeleteTrackCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.RestoreTrack;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.RestoreTrack;
/// <summary>
/// Fixture class for the <see cref="RestoreTrackCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreTrackCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="RestoreTrackCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to, taken from the route.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to, taken from the route.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to, taken from the route.</param>
/// <param name="trackId">Optional. The Id of the deleted track to restore, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="RestoreTrackCommand"/>.</returns>
public RestoreTrackCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true)
{
return new RestoreTrackCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="RestoreTrackCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RestoreTrackCommand"/> instances.</returns>
public List<RestoreTrackCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,138 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.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.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
/// <summary>
/// Fixture class for the <see cref="UpdateTrackCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateTrackCommandFixture
{
private readonly Faker _faker = new();
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid command to update a track.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track to update.</param>
/// <param name="metadata">Optional. The audio metadata 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="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="work">Optional. The work the track is a recording of.</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="moods">Optional. The moods of the track.</param>
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to update a track.</returns>
public UpdateTrackCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
MusicTrackMetadataDto? metadata = null,
int? trackNumber = null,
int? discNumber = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
MusicWorkDto? work = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeMetadata = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true,
bool includeTrackNumber = true)
{
return new UpdateTrackCommand(
includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
includeArtistId ? (artistId ?? _faker.Random.Guid().ToString()) : null,
includeAlbumId ? (albumId ?? _faker.Random.Guid().ToString()) : null,
includeTrackId ? (trackId ?? _faker.Random.Guid().ToString()) : null,
includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateTrackCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateTrackCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetDeletedTracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetDeletedTracks;
/// <summary>
/// Fixture class for the <see cref="GetDeletedTracksQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDeletedTracksQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetDeletedTracksQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose deleted tracks are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetDeletedTracksQuery"/>.</returns>
public GetDeletedTracksQuery Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new GetDeletedTracksQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetDeletedTracksQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetDeletedTracksQuery"/> instances.</returns>
public List<GetDeletedTracksQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetPlaybackManifest;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetPlaybackManifest;
/// <summary>
/// Fixture class for the <see cref="GetPlaybackManifestQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPlaybackManifestQueryFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid query to get the playback manifest of a track.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track whose playback manifest is retrieved.</param>
/// <param name="capabilities">Optional. The container and codec pairs the player advertises it can demux and decode directly.</param>
/// <param name="streamPath">Optional. The path of the track stream, relative to the API.</param>
/// <param name="segmentStreamPathTemplate">Optional. The path template of the segment route, relative to the API.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCapabilities">Whether the capabilities should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetPlaybackManifestQuery"/>.</returns>
public GetPlaybackManifestQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
string? capabilities = null,
string? streamPath = null,
string? segmentStreamPathTemplate = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true,
bool includeCapabilities = true)
{
return new GetPlaybackManifestQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null,
includeCapabilities ? (capabilities ?? "mp3/mp3,flac/flac") : null,
streamPath ?? "/api/v1/music/libraries/" + _faker.Random.AlphaNumeric(8) + "/tracks/" + _faker.Random.AlphaNumeric(8) + "/stream",
segmentStreamPathTemplate ?? "/api/v1/music/libraries/" + _faker.Random.AlphaNumeric(8) + "/tracks/" + _faker.Random.AlphaNumeric(8) + "/stream/segments/{deliveryId}/{segmentIndex}");
}
/// <summary>
/// Creates a list of <see cref="GetPlaybackManifestQuery"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetPlaybackManifestQuery"/> instances.</returns>
public List<GetPlaybackManifestQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrack;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrack;
/// <summary>
/// Fixture class for the <see cref="GetTrackQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTrackQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetTrackQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track to get.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetTrackQuery"/>.</returns>
public GetTrackQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true)
{
return new GetTrackQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetTrackQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetTrackQuery"/> instances.</returns>
public List<GetTrackQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackSegment;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackSegment;
/// <summary>
/// Fixture class for the <see cref="GetTrackSegmentQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTrackSegmentQueryFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid query to get a single segment of the normalized audio of a track.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track whose normalized audio is streamed.</param>
/// <param name="deliveryId">Optional. The opaque handle of the normalized delivery the segment belongs to.</param>
/// <param name="segmentIndex">Optional. The zero based index of the segment of the normalized audio.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDeliveryId">Whether the delivery Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSegmentIndex">Whether the segment index should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetTrackSegmentQuery"/>.</returns>
public GetTrackSegmentQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
string? deliveryId = null,
string? segmentIndex = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true,
bool includeDeliveryId = true,
bool includeSegmentIndex = true)
{
return new GetTrackSegmentQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null,
includeDeliveryId ? (deliveryId ?? Guid.NewGuid().ToString("N")) : null,
includeSegmentIndex ? (segmentIndex ?? _faker.Random.Int(0, 1000).ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetTrackSegmentQuery"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetTrackSegmentQuery"/> instances.</returns>
public List<GetTrackSegmentQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackStream;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackStream;
/// <summary>
/// Fixture class for the <see cref="GetTrackStreamQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTrackStreamQueryFixture
{
/// <summary>
/// Creates a random valid query to get the audio file of a track, for streaming.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="trackId">Optional. The Id of the track whose audio file is streamed.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetTrackStreamQuery"/>.</returns>
public GetTrackStreamQuery Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
string? trackId = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeTrackId = true)
{
return new GetTrackStreamQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetTrackStreamQuery"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetTrackStreamQuery"/> instances.</returns>
public List<GetTrackStreamQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.ShuffleTracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.ShuffleTracks;
/// <summary>
/// Fixture class for the <see cref="ShuffleTracksQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ShuffleTracksQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="ShuffleTracksQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the tracks are sampled from, taken from the route.</param>
/// <param name="count">Optional. The maximum number of tracks to return.</param>
/// <param name="artistId">Optional. The Id of the artist whose tracks are sampled.</param>
/// <param name="albumId">Optional. The Id of the album whose tracks are sampled.</param>
/// <param name="excludedTrackIds">Optional. The tracks that must not be returned.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeExcludedTrackIds">Whether the excluded track Ids should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ShuffleTracksQuery"/>.</returns>
public ShuffleTracksQuery Create(
string? libraryId = null,
int? count = null,
Guid? artistId = null,
Guid? albumId = null,
IReadOnlyList<Guid>? excludedTrackIds = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeExcludedTrackIds = true)
{
return new ShuffleTracksQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
count ?? Random.Shared.Next(1, 501),
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null,
includeExcludedTrackIds
? (excludedTrackIds ?? [.. Enumerable.Range(0, Random.Shared.Next(0, 3)).Select(_ => Guid.NewGuid())])
: null);
}
/// <summary>
/// Creates a list of <see cref="ShuffleTracksQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ShuffleTracksQuery"/> instances.</returns>
public List<ShuffleTracksQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,106 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.AddLibrary;
/// <summary>
/// Fixture class for the <see cref="AddLibraryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddLibraryCommandFixture
{
/// <summary>
/// Creates a random valid command to add a media library.
/// </summary>
/// <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">Optional. Whether hidden files and directories should be skipped during a scan or not. When absent, the default is off.</param>
/// <param name="isContentOnSsd">Whether the content of the media library is stored on a solid state drive.</param>
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
/// <param name="metadataProviders">Optional. The choices made for the metadata providers of the media library.</param>
/// <param name="artworkProviders">Optional. The choices made for the artwork providers of the media library.</param>
/// <param name="bookReaders">Optional. The choices made for the book readers of the media library.</param>
/// <returns>The created command.</returns>
public AddLibraryCommand Create(
string? title = null,
string? libraryType = null,
string[]? contentLocations = null,
string? coverImage = null,
bool isEnabled = true,
bool isLocked = false,
bool canDownloadMetadataFromWeb = true,
bool shouldSaveMetadataInMediaDirectories = true,
bool shouldSkipUnchangedDirectoriesDuringScan = false,
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null,
bool isContentOnSsd = false,
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
LibraryPathTemplatePartDto[]? pathTemplateParts = null,
LibraryProviderSelectionDto[]? metadataProviders = null,
LibraryProviderSelectionDto[]? artworkProviders = null,
LibraryProviderSelectionDto[]? bookReaders = null)
{
return new Faker<AddLibraryCommand>()
.CustomInstantiator(f => new AddLibraryCommand(
default!,
default!,
default!,
default!,
true,
false,
true,
true,
false,
null,
false,
shouldTrackConsumptionProgress,
completionThresholdPercentage,
null,
null,
null,
null
))
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
.RuleFor(x => x.LibraryType, f => libraryType ?? f.Random.Enum<LibraryType>().ToString())
.RuleFor(x => x.ContentLocations, f => contentLocations ?? [f.System.DirectoryPath(), f.System.DirectoryPath(), f.System.DirectoryPath()])
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
.RuleFor(x => x.IsEnabled, isEnabled)
.RuleFor(x => x.IsLocked, isLocked)
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
.RuleFor(x => x.ShouldSkipHiddenFilesAndDirectoriesDuringScan, shouldSkipHiddenFilesAndDirectoriesDuringScan)
.RuleFor(x => x.IsContentOnSsd, isContentOnSsd)
.RuleFor(x => x.PathTemplateParts, pathTemplateParts)
.RuleFor(x => x.MetadataProviders, metadataProviders)
.RuleFor(x => x.ArtworkProviders, artworkProviders)
.RuleFor(x => x.BookReaders, bookReaders)
.Generate();
}
/// <summary>
/// Creates a list of <see cref="AddLibraryCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddLibraryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
/// <summary>
/// Fixture class for the <see cref="CancelLibrariesScanCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CancelLibrariesScanCommandFixture
{
/// <summary>
/// Creates a <see cref="CancelLibrariesScanCommand"/>.
/// </summary>
/// <returns>The created <see cref="CancelLibrariesScanCommand"/>.</returns>
public CancelLibrariesScanCommand Create()
{
return new CancelLibrariesScanCommand();
}
/// <summary>
/// Creates a list of <see cref="CancelLibrariesScanCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CancelLibrariesScanCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
/// <summary>
/// Fixture class for the <see cref="CancelLibraryScanCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CancelLibraryScanCommandFixture
{
/// <summary>
/// Creates a random valid command to cancel a media library scan.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose scan is cancelled.</param>
/// <param name="scanId">Optional. The Id of the scan to cancel.</param>
/// <returns>The created command.</returns>
public CancelLibraryScanCommand Create(Guid? libraryId = null, Guid? scanId = null)
{
return new Faker<CancelLibraryScanCommand>()
.CustomInstantiator(f => new CancelLibraryScanCommand(
libraryId ?? Guid.NewGuid(),
scanId ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="CancelLibraryScanCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CancelLibraryScanCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.DeleteLibrary;
/// <summary>
/// Fixture class for the <see cref="DeleteLibraryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteLibraryCommandFixture
{
/// <summary>
/// Creates a random valid command to delete a media library.
/// </summary>
/// <param name="id">Optional. The Id of the media library to delete.</param>
/// <returns>The created command.</returns>
public DeleteLibraryCommand Create(Guid? id = null)
{
return new Faker<DeleteLibraryCommand>()
.CustomInstantiator(f => new DeleteLibraryCommand(
id ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="DeleteLibraryCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<DeleteLibraryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.ScanLibraries;
/// <summary>
/// Fixture class for the <see cref="ScanLibrariesCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScanLibrariesCommandFixture
{
/// <summary>
/// Creates a <see cref="ScanLibrariesCommand"/>.
/// </summary>
/// <returns>The created <see cref="ScanLibrariesCommand"/>.</returns>
public ScanLibrariesCommand Create()
{
return new ScanLibrariesCommand();
}
/// <summary>
/// Creates a list of <see cref="ScanLibrariesCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ScanLibrariesCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.ScanLibrary;
/// <summary>
/// Fixture class for the <see cref="ScanLibraryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScanLibraryCommandFixture
{
/// <summary>
/// Creates a random valid command to scan a media library.
/// </summary>
/// <param name="id">Optional. The Id of the media library to scan.</param>
/// <returns>The created command.</returns>
public ScanLibraryCommand Create(Guid? id = null)
{
return new Faker<ScanLibraryCommand>()
.CustomInstantiator(f => new ScanLibraryCommand(
id ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="ScanLibraryCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ScanLibraryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,111 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
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.Core.MediaLibrary.Management.Commands.UpdateLibrary;
/// <summary>
/// Fixture class for the <see cref="UpdateLibraryCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateLibraryCommandFixture
{
/// <summary>
/// Creates a random valid command to update a media library.
/// </summary>
/// <param name="id">Optional. The Id of 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">Optional. Whether hidden files and directories should be skipped during a scan or not. When absent, the stored value is kept.</param>
/// <param name="isContentOnSsd">Whether the content of the media library is stored on a solid state drive.</param>
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
/// <param name="metadataProviders">Optional. The choices made for the metadata providers of the media library.</param>
/// <param name="artworkProviders">Optional. The choices made for the artwork providers of the media library.</param>
/// <param name="bookReaders">Optional. The choices made for the book readers of the media library.</param>
/// <returns>The created command.</returns>
public UpdateLibraryCommand Create(
Guid? id = null,
string? title = null,
string? libraryType = null,
string[]? contentLocations = null,
string? coverImage = null,
bool isEnabled = true,
bool isLocked = false,
bool canDownloadMetadataFromWeb = true,
bool shouldSaveMetadataInMediaDirectories = true,
bool shouldSkipUnchangedDirectoriesDuringScan = false,
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null,
bool isContentOnSsd = false,
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
LibraryPathTemplatePartDto[]? pathTemplateParts = null,
LibraryProviderSelectionDto[]? metadataProviders = null,
LibraryProviderSelectionDto[]? artworkProviders = null,
LibraryProviderSelectionDto[]? bookReaders = null)
{
return new Faker<UpdateLibraryCommand>()
.CustomInstantiator(f => new UpdateLibraryCommand(
default,
default!,
default!,
default!,
default!,
true,
false,
true,
true,
false,
null,
false,
shouldTrackConsumptionProgress,
completionThresholdPercentage,
null,
null,
null,
null
))
.RuleFor(x => x.Id, id ?? Guid.NewGuid())
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
.RuleFor(x => x.LibraryType, f => libraryType ?? f.Random.Enum<LibraryType>().ToString())
.RuleFor(x => x.ContentLocations, f => contentLocations ?? [f.System.DirectoryPath(), f.System.DirectoryPath(), f.System.DirectoryPath()])
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
.RuleFor(x => x.IsEnabled, isEnabled)
.RuleFor(x => x.IsLocked, isLocked)
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
.RuleFor(x => x.ShouldSkipHiddenFilesAndDirectoriesDuringScan, shouldSkipHiddenFilesAndDirectoriesDuringScan)
.RuleFor(x => x.IsContentOnSsd, isContentOnSsd)
.RuleFor(x => x.PathTemplateParts, pathTemplateParts)
.RuleFor(x => x.MetadataProviders, metadataProviders)
.RuleFor(x => x.ArtworkProviders, artworkProviders)
.RuleFor(x => x.BookReaders, bookReaders)
.Generate();
}
/// <summary>
/// Creates a list of <see cref="UpdateLibraryCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateLibraryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
/// <summary>
/// Fixture class for the <see cref="GetEnabledLibrariesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetEnabledLibrariesQueryFixture
{
/// <summary>
/// Creates a <see cref="GetEnabledLibrariesQuery"/>.
/// </summary>
/// <returns>The created <see cref="GetEnabledLibrariesQuery"/>.</returns>
public GetEnabledLibrariesQuery Create()
{
return new GetEnabledLibrariesQuery();
}
/// <summary>
/// Creates a list of <see cref="GetEnabledLibrariesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetEnabledLibrariesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraries;
/// <summary>
/// Fixture class for the <see cref="GetLibrariesQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibrariesQueryFixture
{
/// <summary>
/// Creates a <see cref="GetLibrariesQuery"/>.
/// </summary>
/// <returns>The created <see cref="GetLibrariesQuery"/>.</returns>
public GetLibrariesQuery Create()
{
return new GetLibrariesQuery();
}
/// <summary>
/// Creates a list of <see cref="GetLibrariesQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibrariesQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibrary;
/// <summary>
/// Fixture class for the <see cref="GetLibraryQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryQueryFixture
{
/// <summary>
/// Creates a random valid query to get a media library.
/// </summary>
/// <param name="id">Optional. The Id of the media library to get.</param>
/// <returns>The created query.</returns>
public GetLibraryQuery Create(Guid? id = null)
{
return new Faker<GetLibraryQuery>()
.CustomInstantiator(f => new GetLibraryQuery(
id ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="GetLibraryQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,35 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
/// <summary>
/// Fixture class for the <see cref="GetLibraryPathTemplatePartsQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryPathTemplatePartsQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetLibraryPathTemplatePartsQuery"/>.
/// </summary>
/// <param name="libraryType">Optional. The media library type whose available path parts are retrieved.</param>
/// <returns>The created <see cref="GetLibraryPathTemplatePartsQuery"/>.</returns>
public GetLibraryPathTemplatePartsQuery Create(string? libraryType = null)
{
return new GetLibraryPathTemplatePartsQuery(libraryType ?? "Music");
}
/// <summary>
/// Creates a list of <see cref="GetLibraryPathTemplatePartsQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryPathTemplatePartsQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
/// <summary>
/// Fixture class for the <see cref="GetLibraryScanProgressQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryScanProgressQueryFixture
{
/// <summary>
/// Creates a random valid query to get the progress of a media library scan.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose scan progress is requested.</param>
/// <param name="scanId">Optional. The Id of the media library scan whose progress is requested.</param>
/// <returns>The created query.</returns>
public GetLibraryScanProgressQuery Create(Guid? libraryId = null, Guid? scanId = null)
{
return new Faker<GetLibraryScanProgressQuery>()
.CustomInstantiator(f => new GetLibraryScanProgressQuery(
libraryId ?? Guid.NewGuid(),
scanId ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="GetLibraryScanProgressQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryScanProgressQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
/// <summary>
/// Fixture class for the <see cref="GetRunningLibraryScansQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRunningLibraryScansQueryFixture
{
/// <summary>
/// Creates a <see cref="GetRunningLibraryScansQuery"/>.
/// </summary>
/// <returns>The created <see cref="GetRunningLibraryScansQuery"/>.</returns>
public GetRunningLibraryScansQuery Create()
{
return new GetRunningLibraryScansQuery();
}
/// <summary>
/// Creates a list of <see cref="GetRunningLibraryScansQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetRunningLibraryScansQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,226 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.AddBook;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.AddBook;
/// <summary>
/// Fixture class for the <see cref="AddBookCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddBookCommandFixture
{
private readonly IsbnDtoFixture _isbnDtoFixture = new();
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
/// <summary>
/// Creates a random valid command to add a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
/// <param name="path">Optional. The file system path of the book.</param>
/// <param name="metadata">Optional. The written content metadata of the book.</param>
/// <param name="format">Optional. The format of the book.</param>
/// <param name="edition">Optional. The edition of the book.</param>
/// <param name="volumeNumber">Optional. The volume or book number in the series.</param>
/// <param name="series">Optional. The series the book is part of.</param>
/// <param name="asin">Optional. The ASIN of the book.</param>
/// <param name="goodreadsId">Optional. The Goodreads Id of the book.</param>
/// <param name="lccn">Optional. The LCCN of the book.</param>
/// <param name="oclcNumber">Optional. The OCLC number of the book.</param>
/// <param name="openLibraryId">Optional. The Open Library Id of the book.</param>
/// <param name="libraryThingId">Optional. The LibraryThing Id of the book.</param>
/// <param name="googleBooksId">Optional. The Google Books Id of the book.</param>
/// <param name="barnesAndNobleId">Optional. The Barnes and Noble Id of the book.</param>
/// <param name="appleBooksId">Optional. The Apple Books Id of the book.</param>
/// <param name="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeMetadata">Whether the metadata 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>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add a book.</returns>
public AddBookCommand Create(
string? libraryId = null,
string? path = null,
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
string? edition = null,
float? volumeNumber = null,
BookSeriesDto? series = null,
string? asin = null,
string? goodreadsId = null,
string? lccn = null,
string? oclcNumber = null,
string? openLibraryId = null,
string? libraryThingId = null,
string? googleBooksId = null,
string? barnesAndNobleId = null,
string? appleBooksId = null,
List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeMetadata = true,
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<AddBookCommand>()
.CustomInstantiator(f => new AddBookCommand(
default,
default!,
default!,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default!,
default!,
default!,
default!
))
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
/// Creates a list of <see cref="AddBookCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddBookCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates a random LCCN (Library of Congress Control Number).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated LCCN.</returns>
private static string CreateLccn(Faker faker)
{
string letters = new([.. Enumerable.Range(0, faker.Random.Number(0, 3)).Select(_ => faker.Random.Char('a', 'z'))]);
string digits = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return letters + digits;
}
/// <summary>
/// Generates a random OCLC number (WorldCat identifier).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated OCLC number.</returns>
private static string CreateOclcNumber(Faker faker)
{
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
string prefix = faker.Random.ArrayElement(prefixes);
string number;
switch (prefix)
{
case "ocm":
number = faker.Random.String2(8, "0123456789");
break;
case "ocn":
number = faker.Random.String2(faker.Random.Number(9, 11), "0123456789");
break;
case "on":
number = faker.Random.String2(10, "0123456789");
break;
case "(OCoLC)":
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
break;
default:
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return number;
}
return prefix + number;
}
/// <summary>
/// Generates a random Open Library Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Open Library Id.</returns>
private static string CreateOpenLibraryId(Faker faker)
{
int firstDigit = faker.Random.Number(1, 9);
string remainingDigits = faker.Random.String2(faker.Random.Number(0, 6), "0123456789");
char suffix = faker.Random.ArrayElement(['A', 'M', 'W']);
return $"OL{firstDigit}{remainingDigits}{suffix}";
}
/// <summary>
/// Generates a random Google Books Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Google Books Id.</returns>
private static string CreateGoogleBooksId(Faker faker)
{
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[faker.Random.Number(VALID_CHARS.Length - 1)])]);
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.DeleteBook;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.DeleteBook;
/// <summary>
/// Fixture class for the <see cref="DeleteBookCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteBookCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="DeleteBookCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to, taken from the route.</param>
/// <param name="bookId">Optional. The Id of the book to delete, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBookId">Whether the book Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="DeleteBookCommand"/>.</returns>
public DeleteBookCommand Create(
string? libraryId = null,
string? bookId = null,
bool includeLibraryId = true,
bool includeBookId = true)
{
return new DeleteBookCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeBookId ? (bookId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="DeleteBookCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteBookCommand"/> instances.</returns>
public List<DeleteBookCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.RestoreBook;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.RestoreBook;
/// <summary>
/// Fixture class for the <see cref="RestoreBookCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreBookCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="RestoreBookCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to, taken from the route.</param>
/// <param name="bookId">Optional. The Id of the deleted book to restore, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBookId">Whether the book Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="RestoreBookCommand"/>.</returns>
public RestoreBookCommand Create(
string? libraryId = null,
string? bookId = null,
bool includeLibraryId = true,
bool includeBookId = true)
{
return new RestoreBookCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeBookId ? (bookId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="RestoreBookCommand"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RestoreBookCommand"/> instances.</returns>
public List<RestoreBookCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,226 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBook;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.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.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBook;
/// <summary>
/// Fixture class for the <see cref="UpdateBookCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateBookCommandFixture
{
private readonly IsbnDtoFixture _isbnDtoFixture = new();
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
/// <summary>
/// Creates a random valid command to update a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book to update.</param>
/// <param name="metadata">Optional. The written content metadata of the book.</param>
/// <param name="format">Optional. The format of the book.</param>
/// <param name="edition">Optional. The edition of the book.</param>
/// <param name="volumeNumber">Optional. The volume or book number in the series.</param>
/// <param name="series">Optional. The series the book is part of.</param>
/// <param name="asin">Optional. The ASIN of the book.</param>
/// <param name="goodreadsId">Optional. The Goodreads Id of the book.</param>
/// <param name="lccn">Optional. The LCCN of the book.</param>
/// <param name="oclcNumber">Optional. The OCLC number of the book.</param>
/// <param name="openLibraryId">Optional. The Open Library Id of the book.</param>
/// <param name="libraryThingId">Optional. The LibraryThing Id of the book.</param>
/// <param name="googleBooksId">Optional. The Google Books Id of the book.</param>
/// <param name="barnesAndNobleId">Optional. The Barnes and Noble Id of the book.</param>
/// <param name="appleBooksId">Optional. The Apple Books Id of the book.</param>
/// <param name="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeMetadata">Whether the metadata 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>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to update a book.</returns>
public UpdateBookCommand Create(
string? libraryId = null,
string? bookId = null,
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
string? edition = null,
float? volumeNumber = null,
BookSeriesDto? series = null,
string? asin = null,
string? goodreadsId = null,
string? lccn = null,
string? oclcNumber = null,
string? openLibraryId = null,
string? libraryThingId = null,
string? googleBooksId = null,
string? barnesAndNobleId = null,
string? appleBooksId = null,
List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeMetadata = true,
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<UpdateBookCommand>()
.CustomInstantiator(f => new UpdateBookCommand(
default,
default,
default!,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default!,
default!,
default!,
default!
))
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.BookId, bookId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
/// Creates a list of <see cref="UpdateBookCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateBookCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates a random LCCN (Library of Congress Control Number).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated LCCN.</returns>
private static string CreateLccn(Faker faker)
{
string letters = new([.. Enumerable.Range(0, faker.Random.Number(0, 3)).Select(_ => faker.Random.Char('a', 'z'))]);
string digits = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return letters + digits;
}
/// <summary>
/// Generates a random OCLC number (WorldCat identifier).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated OCLC number.</returns>
private static string CreateOclcNumber(Faker faker)
{
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
string prefix = faker.Random.ArrayElement(prefixes);
string number;
switch (prefix)
{
case "ocm":
number = faker.Random.String2(8, "0123456789");
break;
case "ocn":
number = faker.Random.String2(faker.Random.Number(9, 11), "0123456789");
break;
case "on":
number = faker.Random.String2(10, "0123456789");
break;
case "(OCoLC)":
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
break;
default:
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return number;
}
return prefix + number;
}
/// <summary>
/// Generates a random Open Library Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Open Library Id.</returns>
private static string CreateOpenLibraryId(Faker faker)
{
int firstDigit = faker.Random.Number(1, 9);
string remainingDigits = faker.Random.String2(faker.Random.Number(0, 6), "0123456789");
char suffix = faker.Random.ArrayElement(['A', 'M', 'W']);
return $"OL{firstDigit}{remainingDigits}{suffix}";
}
/// <summary>
/// Generates a random Google Books Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Google Books Id.</returns>
private static string CreateGoogleBooksId(Faker faker)
{
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[faker.Random.Number(VALID_CHARS.Length - 1)])]);
}
}
@@ -0,0 +1,62 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBookCover;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBookCover;
/// <summary>
/// Fixture class for the <see cref="UpdateBookCoverCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateBookCoverCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="UpdateBookCoverCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book whose cover is updated.</param>
/// <param name="cover">Optional. The stream of the uploaded cover image file.</param>
/// <param name="fileName">Optional. The name of the uploaded cover image file.</param>
/// <param name="includeCover">Whether the cover stream should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="UpdateBookCoverCommand"/>.</returns>
public UpdateBookCoverCommand Create(
string? libraryId = null,
string? bookId = null,
Stream? cover = null,
string? fileName = null,
bool includeCover = true)
{
return new UpdateBookCoverCommand(
libraryId ?? Guid.NewGuid().ToString(),
bookId ?? Guid.NewGuid().ToString(),
includeCover ? (cover ?? CreateCoverStream()) : null,
fileName ?? "cover.jpg"
);
}
/// <summary>
/// Creates a list of <see cref="UpdateBookCoverCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateBookCoverCommand"/> instances.</returns>
public List<UpdateBookCoverCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates an in-memory stream carrying a minimal file payload.
/// </summary>
/// <returns>A non-empty in-memory stream.</returns>
private static Stream CreateCoverStream()
{
byte[] payload = Encoding.UTF8.GetBytes("fake cover payload");
return new MemoryStream(payload);
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBook;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBook;
/// <summary>
/// Fixture class for the <see cref="GetBookQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBookQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetBookQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book to get.</param>
/// <returns>The created <see cref="GetBookQuery"/>.</returns>
public GetBookQuery Create(
string? libraryId = null,
string? bookId = null)
{
return new GetBookQuery(libraryId ?? Guid.NewGuid().ToString(), bookId ?? Guid.NewGuid().ToString());
}
/// <summary>
/// Creates a list of <see cref="GetBookQuery"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetBookQuery"/> instances.</returns>
public List<GetBookQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
/// <summary>
/// Fixture class for the <see cref="GetBooksQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBooksQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid query to get books.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose books are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created query to get books.</returns>
public GetBooksQuery Create(
string? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeLibraryId = true,
bool includePaginationData = true)
{
return new GetBooksQuery(
includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null,
searchTerm,
sortBy,
sortOrder ?? _faker.PickRandom<SortOrder>()
);
}
/// <summary>
/// Creates a list of <see cref="GetBooksQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetBooksQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooksLite;
using Lumina.Application.Fixtures.Common.DTO.Pagination;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooksLite;
/// <summary>
/// Fixture class for the <see cref="GetBooksLiteQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBooksLiteQueryFixture
{
private readonly Faker _faker = new();
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
/// <summary>
/// Creates a random valid query to get the lightweight details of books.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose books are retrieved, taken from the route.</param>
/// <param name="paginationData">Optional. The pagination data of the query.</param>
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
/// <param name="filterAlphaKey">Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created query to get the lightweight details of books.</returns>
public GetBooksLiteQuery Create(
string? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
string? filterAlphaKey = null,
bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeLibraryId = true,
bool includePaginationData = true)
{
return new GetBooksLiteQuery(
includeLibraryId ? (libraryId ?? _faker.Random.Guid().ToString()) : null,
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null,
searchTerm,
filterAlphaKey,
shouldIgnoreThePrefixForAlphaPicker,
sortBy,
sortOrder ?? _faker.PickRandom<SortOrder>()
);
}
/// <summary>
/// Creates a list of <see cref="GetBooksLiteQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetBooksLiteQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetDeletedBooks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetDeletedBooks;
/// <summary>
/// Fixture class for the <see cref="GetDeletedBooksQuery"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDeletedBooksQueryFixture
{
/// <summary>
/// Creates a random valid <see cref="GetDeletedBooksQuery"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose deleted books are retrieved, taken from the route.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetDeletedBooksQuery"/>.</returns>
public GetDeletedBooksQuery Create(
string? libraryId = null,
bool includeLibraryId = true)
{
return new GetDeletedBooksQuery(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetDeletedBooksQuery"/>.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetDeletedBooksQuery"/> instances.</returns>
public List<GetDeletedBooksQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
/// <summary>
/// Fixture class for the <see cref="GetReadingAvailabilityQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetReadingAvailabilityQueryFixture
{
/// <summary>
/// Creates a random valid query to check the reading availability of a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book whose reading availability is checked.</param>
/// <returns>The created <see cref="GetReadingAvailabilityQuery"/>.</returns>
public GetReadingAvailabilityQuery Create(
string? libraryId = null,
string? bookId = null)
{
return new GetReadingAvailabilityQuery(libraryId ?? Guid.NewGuid().ToString(), bookId ?? Guid.NewGuid().ToString());
}
/// <summary>
/// Creates a list of <see cref="GetReadingAvailabilityQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetReadingAvailabilityQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
/// <summary>
/// Fixture class for the <see cref="GetReadingManifestQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetReadingManifestQueryFixture
{
/// <summary>
/// Creates a random valid query to get the reading manifest of a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book whose reading manifest is retrieved.</param>
/// <returns>The created <see cref="GetReadingManifestQuery"/>.</returns>
public GetReadingManifestQuery Create(
string? libraryId = null,
string? bookId = null)
{
return new GetReadingManifestQuery(libraryId ?? Guid.NewGuid().ToString(), bookId ?? Guid.NewGuid().ToString());
}
/// <summary>
/// Creates a list of <see cref="GetReadingManifestQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetReadingManifestQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
/// <summary>
/// Fixture class for the <see cref="GetReadingResourceQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetReadingResourceQueryFixture
{
/// <summary>
/// Creates a random valid query to get a resource of a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book whose resource is retrieved.</param>
/// <param name="resourceKey">Optional. The opaque resource key of the resource.</param>
/// <returns>The created <see cref="GetReadingResourceQuery"/>.</returns>
public GetReadingResourceQuery Create(
string? libraryId = null,
string? bookId = null,
string? resourceKey = null)
{
return new GetReadingResourceQuery(libraryId ?? Guid.NewGuid().ToString(), bookId ?? Guid.NewGuid().ToString(), resourceKey ?? $"resource-{Guid.NewGuid():N}");
}
/// <summary>
/// Creates a list of <see cref="GetReadingResourceQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetReadingResourceQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
/// <summary>
/// Fixture class for the <see cref="GetReadingSectionQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetReadingSectionQueryFixture
{
/// <summary>
/// Creates a random valid query to get the content of a reading section of a book.
/// </summary>
/// <param name="libraryId">Optional. The Id of the library the book belongs to.</param>
/// <param name="bookId">Optional. The Id of the book whose reading section is retrieved.</param>
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
/// <returns>The created <see cref="GetReadingSectionQuery"/>.</returns>
public GetReadingSectionQuery Create(
string? libraryId = null,
string? bookId = null,
string? locationRef = null)
{
return new GetReadingSectionQuery(libraryId ?? Guid.NewGuid().ToString(), bookId ?? Guid.NewGuid().ToString(), locationRef ?? $"section-{Guid.NewGuid():N}");
}
/// <summary>
/// Creates a list of <see cref="GetReadingSectionQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetReadingSectionQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Playlists.Commands.AddPlaylistEntries;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistEntries;
/// <summary>
/// Fixture class for the <see cref="AddPlaylistEntriesCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddPlaylistEntriesCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="AddPlaylistEntriesCommand"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
/// <param name="trackIds">Optional. The Ids of the tracks to add, in order.</param>
/// <param name="trackCount">Optional. The number of random track Ids to generate when <paramref name="trackIds"/> is not supplied.</param>
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackIds">Whether the track Ids should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AddPlaylistEntriesCommand"/>.</returns>
public AddPlaylistEntriesCommand Create(
string? playlistId = null,
List<Guid>? trackIds = null,
int trackCount = 3,
bool includePlaylistId = true,
bool includeTrackIds = true)
{
return new AddPlaylistEntriesCommand(
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
includeTrackIds ? (trackIds ?? CreateRandomTrackIds(trackCount)) : null);
}
/// <summary>
/// Creates a list of <see cref="AddPlaylistEntriesCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AddPlaylistEntriesCommand"/> instances.</returns>
public List<AddPlaylistEntriesCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates the requested number of distinct random track Ids.
/// </summary>
/// <param name="count">The number of track Ids to create.</param>
/// <returns>The created track Ids.</returns>
private static List<Guid> CreateRandomTrackIds(int count)
{
return [.. Enumerable.Range(0, count).Select(_ => Guid.NewGuid())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Playlists.Commands.AddPlaylistEntry;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistEntry;
/// <summary>
/// Fixture class for the <see cref="AddPlaylistEntryCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddPlaylistEntryCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="AddPlaylistEntryCommand"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
/// <param name="trackId">Optional. The Id of the track to add.</param>
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AddPlaylistEntryCommand"/>.</returns>
public AddPlaylistEntryCommand Create(
string? playlistId = null,
Guid? trackId = null,
bool includePlaylistId = true,
bool includeTrackId = true)
{
return new AddPlaylistEntryCommand(
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
includeTrackId ? (trackId ?? Guid.NewGuid()) : null);
}
/// <summary>
/// Creates a list of <see cref="AddPlaylistEntryCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AddPlaylistEntryCommand"/> instances.</returns>
public List<AddPlaylistEntryCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Playlists.Commands.AddPlaylistScopeEntries;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistScopeEntries;
/// <summary>
/// Fixture class for the <see cref="AddPlaylistScopeEntriesCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddPlaylistScopeEntriesCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="AddPlaylistScopeEntriesCommand"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
/// <param name="libraryId">Optional. The Id of the music library the scope belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the scope is limited to.</param>
/// <param name="albumId">Optional. The Id of the album the scope is limited to.</param>
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AddPlaylistScopeEntriesCommand"/>.</returns>
public AddPlaylistScopeEntriesCommand Create(
string? playlistId = null,
Guid? libraryId = null,
Guid? artistId = null,
Guid? albumId = null,
bool includePlaylistId = true,
bool includeLibraryId = true,
bool includeArtistId = false,
bool includeAlbumId = false)
{
return new AddPlaylistScopeEntriesCommand(
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
includeLibraryId ? (libraryId ?? Guid.NewGuid()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null);
}
/// <summary>
/// Creates a list of <see cref="AddPlaylistScopeEntriesCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AddPlaylistScopeEntriesCommand"/> instances.</returns>
public List<AddPlaylistScopeEntriesCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Playlists.Commands.CreatePlaylist;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.CreatePlaylist;
/// <summary>
/// Fixture class for the <see cref="CreatePlaylistCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class CreatePlaylistCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="CreatePlaylistCommand"/>.
/// </summary>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="description">Optional. The optional 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="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the media type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="CreatePlaylistCommand"/>.</returns>
public CreatePlaylistCommand Create(
string? name = null,
string? description = null,
PlaylistType? type = null,
bool includeDescription = true,
bool includeType = true,
bool includeName = true)
{
return new CreatePlaylistCommand(
includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
includeType ? (type ?? PlaylistType.Music) : null);
}
/// <summary>
/// Creates a list of <see cref="CreatePlaylistCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="CreatePlaylistCommand"/> instances.</returns>
public List<CreatePlaylistCommand> 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