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,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
/// <summary>
/// Fixture class for the <see cref="ChangePasswordResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ChangePasswordResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ChangePasswordResponse"/>.
/// </summary>
/// <param name="isPasswordChanged">Optional. Whether the password was changed.</param>
/// <returns>The created <see cref="ChangePasswordResponse"/>.</returns>
public ChangePasswordResponse Create(
bool? isPasswordChanged = null)
{
return new ChangePasswordResponse(isPasswordChanged ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="ChangePasswordResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ChangePasswordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
/// <summary>
/// Fixture class for the <see cref="LoginResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LoginResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LoginResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the authenticated user.</param>
/// <param name="username">Optional. The username of the authenticated user.</param>
/// <param name="token">Optional. The authentication token of the user.</param>
/// <param name="usesTotp">Optional. Whether the user uses two-factor authentication.</param>
/// <returns>The created <see cref="LoginResponse"/>.</returns>
public LoginResponse Create(
Guid? id = null,
string? username = null,
string? token = null,
bool? usesTotp = null)
{
return new LoginResponse(
id ?? Guid.NewGuid(),
username ?? _faker.Internet.UserName(),
token ?? _faker.Random.Hexadecimal(32),
usesTotp ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="LoginResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LoginResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
/// <summary>
/// Fixture class for the <see cref="RecoverPasswordResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RecoverPasswordResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RecoverPasswordResponse"/>.
/// </summary>
/// <param name="isPasswordReset">Optional. Whether the password was reset.</param>
/// <returns>The created <see cref="RecoverPasswordResponse"/>.</returns>
public RecoverPasswordResponse Create(
bool? isPasswordReset = null)
{
return new RecoverPasswordResponse(isPasswordReset ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="RecoverPasswordResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RecoverPasswordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
/// <summary>
/// Fixture class for the <see cref="RegistrationResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RegistrationResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RegistrationResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the registered user.</param>
/// <param name="username">Optional. The username of the registered user.</param>
/// <param name="totpSecret">Optional. The TOTP secret used for two-factor authentication.</param>
/// <returns>The created <see cref="RegistrationResponse"/>.</returns>
public RegistrationResponse Create(
Guid? id = null,
string? username = null,
string? totpSecret = null)
{
return new RegistrationResponse(
id ?? Guid.NewGuid(),
username ?? _faker.Internet.UserName(),
totpSecret ?? _faker.Random.AlphaNumeric(16)
);
}
/// <summary>
/// Creates a list of <see cref="RegistrationResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RegistrationResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authorization;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authorization;
/// <summary>
/// Fixture class for the <see cref="AuthorizationResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AuthorizationResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="AuthorizationResponse"/>.
/// </summary>
/// <param name="userId">Optional. The Id of the user.</param>
/// <param name="role">Optional. The role of the user.</param>
/// <param name="permissions">Optional. The permissions of the user.</param>
/// <returns>The created <see cref="AuthorizationResponse"/>.</returns>
public AuthorizationResponse Create(
Guid? userId = null,
string? role = null,
IReadOnlySet<AuthorizationPermission>? permissions = null)
{
return new AuthorizationResponse(
userId ?? Guid.NewGuid(),
role,
permissions ?? new HashSet<AuthorizationPermission>());
}
/// <summary>
/// Creates a list of <see cref="AuthorizationResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AuthorizationResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authorization;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authorization;
/// <summary>
/// Fixture class for the <see cref="PermissionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PermissionResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PermissionResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the permission.</param>
/// <param name="permissionName">Optional. The name of the permission.</param>
/// <returns>The created <see cref="PermissionResponse"/>.</returns>
public PermissionResponse Create(
Guid? id = null,
AuthorizationPermission? permissionName = null)
{
return new PermissionResponse(
id ?? Guid.NewGuid(),
permissionName ?? _faker.PickRandom<AuthorizationPermission>()
);
}
/// <summary>
/// Creates a list of <see cref="PermissionResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PermissionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Authentication;
using Lumina.Contracts.Fixtures.Core.DTO.Authentication;
using Lumina.Contracts.Responses.Authorization;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authorization;
/// <summary>
/// Fixture class for the <see cref="RolePermissionsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RolePermissionsResponseFixture
{
private readonly RoleDtoFixture _roleDtoFixture = new();
private readonly PermissionDtoFixture _permissionDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="RolePermissionsResponse"/>.
/// </summary>
/// <param name="role">Optional. The authorization role.</param>
/// <param name="permissions">Optional. The permissions of the authorization role.</param>
/// <returns>The created <see cref="RolePermissionsResponse"/>.</returns>
public RolePermissionsResponse Create(
RoleDto? role = null,
IEnumerable<PermissionDto>? permissions = null)
{
return new RolePermissionsResponse(
role ?? _roleDtoFixture.Create(),
(permissions ?? _permissionDtoFixture.CreateMany()).ToArray());
}
/// <summary>
/// Creates a list of <see cref="RolePermissionsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RolePermissionsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Authorization;
/// <summary>
/// Fixture class for the <see cref="RoleResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RoleResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RoleResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the role.</param>
/// <param name="roleName">Optional. The name of the role.</param>
/// <returns>The created <see cref="RoleResponse"/>.</returns>
public RoleResponse Create(
Guid? id = null,
string? roleName = null)
{
return new RoleResponse(id ?? Guid.NewGuid(), roleName ?? _faker.Commerce.Department());
}
/// <summary>
/// Creates a list of <see cref="RoleResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RoleResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,78 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Favorites;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
/// <summary>
/// Fixture class for the <see cref="FavoriteItemResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteItemResponseFixture
{
private readonly Faker _faker = new();
private readonly FavoriteMediaKind[] _supportedMediaKinds =
[
FavoriteMediaKind.MusicArtist,
FavoriteMediaKind.MusicAlbum,
FavoriteMediaKind.MusicTrack,
FavoriteMediaKind.Book
];
/// <summary>
/// Creates a random valid <see cref="FavoriteItemResponse"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
/// <param name="isAvailable">Optional. Whether the media item is available.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="title">Optional. The title of the media item.</param>
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="FavoriteItemResponse"/>.</returns>
public FavoriteItemResponse Create(
FavoriteMediaKind? mediaKind = null,
Guid? mediaItemId = null,
bool? isAvailable = null,
Guid? libraryId = null,
string? title = null,
Guid? collectionId = null,
string? collectionTitle = null,
Guid? creatorId = null,
string? creatorName = null,
string? coverPath = null,
bool includeCoverPath = true)
{
return new FavoriteItemResponse(
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
mediaItemId ?? _faker.Random.Guid(),
isAvailable ?? _faker.Random.Bool(),
libraryId ?? _faker.Random.Guid(),
title ?? _faker.Lorem.Sentence(3),
collectionId ?? _faker.Random.Guid(),
collectionTitle ?? _faker.Lorem.Sentence(3),
creatorId ?? _faker.Random.Guid(),
creatorName ?? _faker.Name.FullName(),
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="FavoriteItemResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteItemResponse"/> instances.</returns>
public List<FavoriteItemResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,58 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Favorites;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
/// <summary>
/// Fixture class for the <see cref="FavoriteResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteResponseFixture
{
private readonly Faker _faker = new();
private readonly FavoriteMediaKind[] _supportedMediaKinds =
[
FavoriteMediaKind.MusicArtist,
FavoriteMediaKind.MusicAlbum,
FavoriteMediaKind.MusicTrack,
FavoriteMediaKind.Book
];
/// <summary>
/// Creates a random valid <see cref="FavoriteResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the favorite.</param>
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
/// <param name="favoritedOnUtc">Optional. The date and time when the media item was favorited. Defaults to a moment in the past.</param>
/// <returns>The created <see cref="FavoriteResponse"/>.</returns>
public FavoriteResponse Create(
Guid? id = null,
FavoriteMediaKind? mediaKind = null,
Guid? mediaItemId = null,
DateTime? favoritedOnUtc = null)
{
return new FavoriteResponse(
id ?? _faker.Random.Guid(),
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
mediaItemId ?? _faker.Random.Guid(),
favoritedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59)));
}
/// <summary>
/// Creates a list of <see cref="FavoriteResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteResponse"/> instances.</returns>
public List<FavoriteResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
/// <summary>
/// Fixture class for the <see cref="FavoriteStatusResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteStatusResponseFixture
{
private const int DEFAULT_FAVORITED_COUNT = 3;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FavoriteStatusResponse"/>.
/// </summary>
/// <param name="favoritedMediaItemIds">Optional. The Ids of the media items that are favorites. Defaults to a bounded list of random Ids.</param>
/// <returns>The created <see cref="FavoriteStatusResponse"/>.</returns>
public FavoriteStatusResponse Create(IReadOnlyList<Guid>? favoritedMediaItemIds = null)
{
return new FavoriteStatusResponse(
favoritedMediaItemIds ?? CreateRandomMediaItemIds());
}
/// <summary>
/// Creates a list of <see cref="FavoriteStatusResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteStatusResponse"/> instances.</returns>
public List<FavoriteStatusResponse> 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_FAVORITED_COUNT).Select(_ => _faker.Random.Guid())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Common;
/// <summary>
/// Fixture class for the <see cref="FileSystemTreeNodeResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemTreeNodeResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a single <see cref="FileSystemTreeNodeResponse"/> with a nested structure.
/// </summary>
/// <param name="currentDepth">The current depth in the tree structure. Default is 0 (root level).</param>
/// <param name="maxDepth">The maximum depth of the tree structure. Default is 2.</param>
/// <param name="maxChildren">The maximum number of children for each node. Default is 3.</param>
/// <param name="isHidden">Optional. Whether the node is hidden. If not provided, a random value is generated.</param>
/// <returns>A <see cref="FileSystemTreeNodeResponse"/> with a nested structure.</returns>
public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3, bool? isHidden = null)
{
FileSystemTreeNodeResponse response = new()
{
Path = _faker.System.FilePath(),
Name = _faker.System.FileName(),
ItemType = FileSystemItemType.Directory,
IsHidden = isHidden ?? _faker.Random.Bool(),
IsExpanded = _faker.Random.Bool(),
ChildrenLoaded = true,
Children = []
};
if (currentDepth < maxDepth)
{
int childCount = _faker.Random.Int(1, maxChildren);
for (int i = 0; i < childCount; i++)
response.Children.Add(Create(currentDepth + 1, maxDepth, maxChildren));
}
return response;
}
/// <summary>
/// Creates a list of <see cref="FileSystemTreeNodeResponse"/> objects, each with a nested structure.
/// </summary>
/// <param name="count">The number of root-level nodes to create. Default is 2.</param>
/// <param name="maxDepth">The maximum depth of the tree structure for each root node. Default is 2.</param>
/// <param name="maxChildren">The maximum number of children for each node. Default is 3.</param>
/// <returns>A list of <see cref="FileSystemTreeNodeResponse"/> objects with nested structures.</returns>
public List<FileSystemTreeNodeResponse> CreateMany(int count = 2, int maxDepth = 2, int maxChildren = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create(0, maxDepth, maxChildren))];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Fixtures.Core.DTO.FileSystemManagement;
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Directories;
/// <summary>
/// Fixture class for the <see cref="DirectoryResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DirectoryResponseFixture
{
private readonly Faker _faker = new();
private readonly FileSystemItemDtoFixture _fileSystemItemDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="DirectoryResponse"/>.
/// </summary>
/// <param name="itemCount">Optional. The number of children elements to create.</param>
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
/// <returns>The created <see cref="DirectoryResponse"/>.</returns>
public DirectoryResponse Create(int itemCount = 3, bool? isHidden = null)
{
return new DirectoryResponse(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent(),
_fileSystemItemDtoFixture.CreateMany(itemCount),
isHidden ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="DirectoryResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <param name="itemCount">The number of children elements to create for each element.</param>
/// <returns>The created list.</returns>
public List<DirectoryResponse> CreateMany(int count = 3, int itemCount = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create(itemCount))];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.FileSystem;
/// <summary>
/// Fixture class for the <see cref="FileSystemTypeResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemTypeResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FileSystemTypeResponse"/>.
/// </summary>
/// <param name="platformType">Optional. The type of the file system platform.</param>
/// <returns>The created <see cref="FileSystemTypeResponse"/>.</returns>
public FileSystemTypeResponse Create(
PlatformType? platformType = null)
{
return new FileSystemTypeResponse(platformType ?? _faker.PickRandom<PlatformType>());
}
/// <summary>
/// Creates a list of <see cref="FileSystemTypeResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<FileSystemTypeResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Files;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Files;
/// <summary>
/// Fixture class for the <see cref="FileResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FileResponse"/>.
/// </summary>
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
/// <returns>The created <see cref="FileResponse"/>.</returns>
public FileResponse Create(bool? isHidden = null)
{
return new FileResponse(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent(),
_faker.Random.Long(),
isHidden ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="FileResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<FileResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="PathExistsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathExistsResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PathExistsResponse"/>.
/// </summary>
/// <param name="exists">Optional. Whether the path exists.</param>
/// <returns>The created <see cref="PathExistsResponse"/>.</returns>
public PathExistsResponse Create(
bool? exists = null)
{
return new PathExistsResponse(exists ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="PathExistsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PathExistsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="PathSegmentResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathSegmentResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PathSegmentResponse"/>.
/// </summary>
/// <param name="path">Optional. The path of the segment.</param>
/// <returns>The created <see cref="PathSegmentResponse"/>.</returns>
public PathSegmentResponse Create(string? path = null)
{
return new PathSegmentResponse(path ?? _faker.System.DirectoryPath());
}
/// <summary>
/// Creates a list of <see cref="PathSegmentResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PathSegmentResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="PathSeparatorResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathSeparatorResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PathSeparatorResponse"/>.
/// </summary>
/// <param name="separator">Optional. The path separator.</param>
/// <returns>The created <see cref="PathSeparatorResponse"/>.</returns>
public PathSeparatorResponse Create(string? separator = null)
{
return new PathSeparatorResponse(separator ?? _faker.System.DirectoryPath());
}
/// <summary>
/// Creates a list of <see cref="PathSeparatorResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PathSeparatorResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="PathValidResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathValidResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PathValidResponse"/>.
/// </summary>
/// <param name="isValid">Optional. Whether the path is valid.</param>
/// <returns>The created <see cref="PathValidResponse"/>.</returns>
public PathValidResponse Create(
bool? isValid = null)
{
return new PathValidResponse(isValid ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="PathValidResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PathValidResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Thumbnails;
/// <summary>
/// Fixture class for the <see cref="ThumbnailResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThumbnailResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThumbnailResponse"/>.
/// </summary>
/// <param name="type">Optional. The thumbnail image type.</param>
/// <param name="bytes">Optional. The thumbnail image bytes.</param>
/// <returns>The created <see cref="ThumbnailResponse"/>.</returns>
public ThumbnailResponse Create(ImageType? type = null, byte[]? bytes = null)
{
return new ThumbnailResponse(
type ?? _faker.PickRandom<ImageType>(),
bytes ?? _faker.Random.Bytes(20)
);
}
/// <summary>
/// Creates a list of <see cref="ThumbnailResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThumbnailResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="AllUsersConsumptionStatisticsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AllUsersConsumptionStatisticsResponseFixture
{
private readonly ConsumptionTotalsResponseFixture _consumptionTotalsResponseFixture = new();
private readonly ConsumptionSummaryResponseFixture _consumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="AllUsersConsumptionStatisticsResponse"/>.
/// </summary>
/// <param name="total">Optional. The combined statistics of every user. Defaults to a random set of totals.</param>
/// <param name="users">Optional. The statistics of each user. Defaults to a single random user summary.</param>
/// <param name="includeUsers">Whether the user summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="AllUsersConsumptionStatisticsResponse"/>.</returns>
public AllUsersConsumptionStatisticsResponse Create(
ConsumptionTotalsResponse? total = null,
IReadOnlyList<ConsumptionSummaryResponse>? users = null,
bool includeUsers = true)
{
IReadOnlyList<ConsumptionSummaryResponse> resolvedUsers = includeUsers
? users ?? [_consumptionSummaryResponseFixture.Create()]
: [];
return new AllUsersConsumptionStatisticsResponse(
total ?? _consumptionTotalsResponseFixture.Create(),
resolvedUsers);
}
/// <summary>
/// Creates a list of <see cref="AllUsersConsumptionStatisticsResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AllUsersConsumptionStatisticsResponse"/> instances.</returns>
public List<AllUsersConsumptionStatisticsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,90 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumedItemResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumedItemResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="ConsumedItemResponse"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of the consumed media item. Defaults to a random supported kind.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="isAvailable">Optional. Whether the media item is still available.</param>
/// <param name="title">Optional. The title of the media item.</param>
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed.</param>
/// <param name="countedSessionCount">Optional. The number of consumption sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of consumption sessions that completed.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed in the media item, in seconds. Defaults to a bounded random duration.</param>
/// <returns>The created <see cref="ConsumedItemResponse"/>.</returns>
public ConsumedItemResponse Create(
MediaKind? mediaKind = null,
Guid? mediaItemId = null,
Guid? libraryId = null,
bool? isAvailable = null,
string? title = null,
string? collectionTitle = null,
string? creatorName = null,
string? coverPath = null,
bool includeCoverPath = true,
DateTime? lastConsumedOnUtc = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
double? consumedDurationInSeconds = null)
{
return new ConsumedItemResponse(
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
mediaItemId ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
isAvailable ?? _faker.Random.Bool(),
title ?? _faker.Commerce.ProductName(),
collectionTitle ?? _faker.Commerce.Department(),
creatorName ?? _faker.Name.FullName(),
includeCoverPath ? coverPath ?? _faker.System.FilePath() : null,
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS));
}
/// <summary>
/// Creates a list of <see cref="ConsumedItemResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumedItemResponse"/> instances.</returns>
public List<ConsumedItemResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,126 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionRecordResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionRecordResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaPositionResponseFixture _mediaPositionResponseFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
private readonly ConsumptionStatus[] _statuses =
[
ConsumptionStatus.InProgress,
ConsumptionStatus.Completed,
ConsumptionStatus.Stopped
];
/// <summary>
/// Creates a random valid <see cref="ConsumptionRecordResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the consumption record.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the consumed media item.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
/// <param name="status">Optional. The state of the consumption session. Defaults to a random valid status.</param>
/// <param name="startedOnUtc">Optional. The date and time when the session started. Defaults to a moment in the past.</param>
/// <param name="lastActivityOnUtc">Optional. The date and time when the session last received activity. Defaults to a moment at or after the start.</param>
/// <param name="endedOnUtc">Optional. The date and time when the session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
/// <param name="includeEndedOnUtc">Whether the end time should be included, or forced to <see langword="null"/>.</param>
/// <param name="consumedDurationInSeconds">Optional. The active duration consumed by the session, in seconds. Defaults to a bounded random duration.</param>
/// <param name="lastPosition">Optional. The last known position. Defaults to a position matching the position kind of the media kind, and to no position for a photo.</param>
/// <param name="includeLastPosition">Whether the last position should be included, or forced to <see langword="null"/>.</param>
/// <param name="lastProgressFraction">Optional. The latest reported progress fraction. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a book, and to zero for every other kind.</param>
/// <returns>The created <see cref="ConsumptionRecordResponse"/>.</returns>
public ConsumptionRecordResponse Create(
Guid? id = null,
Guid? libraryId = null,
Guid? mediaItemId = null,
MediaKind? mediaKind = null,
ConsumptionStatus? status = null,
DateTime? startedOnUtc = null,
DateTime? lastActivityOnUtc = null,
DateTime? endedOnUtc = null,
bool includeEndedOnUtc = true,
double? consumedDurationInSeconds = null,
MediaPositionResponse? lastPosition = null,
bool includeLastPosition = true,
double? lastProgressFraction = null,
int? consecutivePagesRead = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement(_statuses);
DateTime resolvedStartedOnUtc = startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
DateTime? resolvedEndedOnUtc = includeEndedOnUtc
? endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
? null
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60)))
: null;
MediaPositionKind? defaultPositionKind = ResolveDefaultPositionKind(resolvedMediaKind);
MediaPositionResponse? resolvedLastPosition = includeLastPosition && (lastPosition is not null || defaultPositionKind.HasValue)
? lastPosition ?? _mediaPositionResponseFixture.Create(kind: defaultPositionKind)
: null;
return new ConsumptionRecordResponse(
id ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
mediaItemId ?? _faker.Random.Guid(),
resolvedMediaKind,
resolvedStatus,
resolvedStartedOnUtc,
resolvedLastActivityOnUtc,
resolvedEndedOnUtc,
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
resolvedLastPosition,
lastProgressFraction ?? _faker.Random.Double(0, 1),
consecutivePagesRead ?? (resolvedMediaKind == MediaKind.Book ? _faker.Random.Int(0, 100) : 0));
}
/// <summary>
/// Creates a list of <see cref="ConsumptionRecordResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionRecordResponse"/> instances.</returns>
public List<ConsumptionRecordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the default kind of position used by a media kind.
/// </summary>
/// <param name="mediaKind">The kind of media.</param>
/// <returns>The position kind that a session of the media kind reports, or <see langword="null"/> when the kind carries no position.</returns>
private static MediaPositionKind? ResolveDefaultPositionKind(MediaKind mediaKind)
{
if (mediaKind == MediaKind.Photo)
return null;
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionSummaryResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKindConsumptionSummaryResponseFixture _mediaKindConsumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ConsumptionSummaryResponse"/>.
/// </summary>
/// <param name="userId">Optional. The Id of the user the statistics belong to.</param>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="ConsumptionSummaryResponse"/>.</returns>
public ConsumptionSummaryResponse Create(
Guid? userId = null,
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null,
IReadOnlyList<MediaKindConsumptionSummaryResponse>? mediaKindSummaries = null,
bool includeMediaKindSummaries = true)
{
IReadOnlyList<MediaKindConsumptionSummaryResponse> resolvedMediaKindSummaries = includeMediaKindSummaries
? mediaKindSummaries ?? [_mediaKindConsumptionSummaryResponseFixture.Create()]
: [];
return new ConsumptionSummaryResponse(
userId ?? _faker.Random.Guid(),
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1),
resolvedMediaKindSummaries);
}
/// <summary>
/// Creates a list of <see cref="ConsumptionSummaryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionSummaryResponse"/> instances.</returns>
public List<ConsumptionSummaryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ConsumptionTotalsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ConsumptionTotalsResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKindConsumptionSummaryResponseFixture _mediaKindConsumptionSummaryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ConsumptionTotalsResponse"/>.
/// </summary>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="mediaKindSummaries">Optional. The statistics broken down by media kind. Defaults to a single random summary.</param>
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty list.</param>
/// <returns>The created <see cref="ConsumptionTotalsResponse"/>.</returns>
public ConsumptionTotalsResponse Create(
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null,
IReadOnlyList<MediaKindConsumptionSummaryResponse>? mediaKindSummaries = null,
bool includeMediaKindSummaries = true)
{
IReadOnlyList<MediaKindConsumptionSummaryResponse> resolvedMediaKindSummaries = includeMediaKindSummaries
? mediaKindSummaries ?? [_mediaKindConsumptionSummaryResponseFixture.Create()]
: [];
return new ConsumptionTotalsResponse(
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1),
resolvedMediaKindSummaries);
}
/// <summary>
/// Creates a list of <see cref="ConsumptionTotalsResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ConsumptionTotalsResponse"/> instances.</returns>
public List<ConsumptionTotalsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="GenreConsumptionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GenreConsumptionResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GenreConsumptionResponse"/>.
/// </summary>
/// <param name="name">Optional. The lowercase name of the genre. Defaults to a random lowercase word.</param>
/// <param name="consumedItemCount">Optional. The number of distinct consumed media items that carry the genre. Defaults to a bounded random count.</param>
/// <param name="consumedDurationInSeconds">Optional. The consumed duration of the media items that carry the genre, in seconds. Defaults to a bounded random duration.</param>
/// <param name="includeName">Whether the genre name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeConsumedItemCount">Whether the consumed item count should be included, or forced to zero.</param>
/// <param name="includeConsumedDurationInSeconds">Whether the consumed duration should be included, or forced to zero.</param>
/// <returns>The created <see cref="GenreConsumptionResponse"/>.</returns>
public GenreConsumptionResponse Create(
string? name = null,
int? consumedItemCount = null,
double? consumedDurationInSeconds = null,
bool includeName = true,
bool includeConsumedItemCount = true,
bool includeConsumedDurationInSeconds = true)
{
return new GenreConsumptionResponse(
includeName ? name ?? _faker.Lorem.Word().ToLowerInvariant() : null!,
includeConsumedItemCount ? consumedItemCount ?? _faker.Random.Int(0, 1000) : 0,
includeConsumedDurationInSeconds ? consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS) : 0);
}
/// <summary>
/// Creates a list of <see cref="GenreConsumptionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GenreConsumptionResponse"/> instances.</returns>
public List<GenreConsumptionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="MediaKindConsumptionSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaKindConsumptionSummaryResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaKindConsumptionSummaryResponse"/>.
/// </summary>
/// <param name="mediaKind">Optional. The kind of media the statistics belong to. Defaults to a random supported kind.</param>
/// <param name="totalConsumedDurationInSeconds">Optional. The total consumed duration of the media kind, in seconds. Defaults to a bounded random duration.</param>
/// <param name="countedSessionCount">Optional. The number of sessions that count towards statistics.</param>
/// <param name="completedSessionCount">Optional. The number of sessions that completed.</param>
/// <param name="stoppedSessionCount">Optional. The number of sessions that stopped before they completed.</param>
/// <param name="completionRate">Optional. The completion rate. Defaults to a bounded random fraction between zero and one.</param>
/// <returns>The created <see cref="MediaKindConsumptionSummaryResponse"/>.</returns>
public MediaKindConsumptionSummaryResponse Create(
MediaKind? mediaKind = null,
double? totalConsumedDurationInSeconds = null,
int? countedSessionCount = null,
int? completedSessionCount = null,
int? stoppedSessionCount = null,
double? completionRate = null)
{
return new MediaKindConsumptionSummaryResponse(
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
totalConsumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS),
countedSessionCount ?? _faker.Random.Int(0, 100),
completedSessionCount ?? _faker.Random.Int(0, 100),
stoppedSessionCount ?? _faker.Random.Int(0, 100),
completionRate ?? _faker.Random.Double(0, 1));
}
/// <summary>
/// Creates a list of <see cref="MediaKindConsumptionSummaryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaKindConsumptionSummaryResponse"/> instances.</returns>
public List<MediaKindConsumptionSummaryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="MediaPositionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaPositionResponseFixture
{
private const double MAXIMUM_OFFSET_SECONDS = 7_200;
private readonly Faker _faker = new();
private readonly MediaPositionKind[] _positionKinds =
[
MediaPositionKind.TimeOffset,
MediaPositionKind.Location
];
/// <summary>
/// Creates a random valid <see cref="MediaPositionResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of representation used by the position. Defaults to a random valid kind.</param>
/// <param name="timeOffsetSeconds">Optional. The position within the media item, in seconds. Defaults to a bounded random offset for a time offset position.</param>
/// <param name="location">Optional. The opaque locator within the media item. Defaults to a random word for a location position.</param>
/// <param name="includeTimeOffsetSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MediaPositionResponse"/>.</returns>
public MediaPositionResponse Create(
MediaPositionKind? kind = null,
double? timeOffsetSeconds = null,
string? location = null,
bool includeTimeOffsetSeconds = true,
bool includeLocation = true)
{
MediaPositionKind resolvedKind = kind ?? _faker.Random.ArrayElement(_positionKinds);
bool isTimeOffset = resolvedKind == MediaPositionKind.TimeOffset;
double? resolvedTimeOffsetSeconds = includeTimeOffsetSeconds
? timeOffsetSeconds ?? (isTimeOffset ? _faker.Random.Double(0, MAXIMUM_OFFSET_SECONDS) : (double?)null)
: null;
string? resolvedLocation = includeLocation
? location ?? (isTimeOffset ? null : _faker.Lorem.Word())
: null;
return new MediaPositionResponse(resolvedKind, resolvedTimeOffsetSeconds, resolvedLocation);
}
/// <summary>
/// Creates a list of <see cref="MediaPositionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaPositionResponse"/> instances.</returns>
public List<MediaPositionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,84 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="ResumePointResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ResumePointResponseFixture
{
private readonly Faker _faker = new();
private readonly MediaPositionResponseFixture _mediaPositionResponseFixture = new();
private readonly MediaKind[] _resumableMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="ResumePointResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the resume point.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
/// <param name="lastPosition">Optional. The position at which the media item can be resumed. Defaults to a position matching the position kind of the media kind.</param>
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
/// <returns>The created <see cref="ResumePointResponse"/>.</returns>
public ResumePointResponse Create(
Guid? id = null,
Guid? libraryId = null,
Guid? mediaItemId = null,
MediaKind? mediaKind = null,
MediaPositionResponse? lastPosition = null,
double? lastProgressFraction = null,
DateTime? lastConsumedOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
return new ResumePointResponse(
id ?? _faker.Random.Guid(),
libraryId ?? _faker.Random.Guid(),
mediaItemId ?? _faker.Random.Guid(),
resolvedMediaKind,
lastPosition ?? _mediaPositionResponseFixture.Create(kind: ResolveDefaultPositionKind(resolvedMediaKind)),
lastProgressFraction ?? _faker.Random.Double(0, 1),
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)));
}
/// <summary>
/// Creates a list of <see cref="ResumePointResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ResumePointResponse"/> instances.</returns>
public List<ResumePointResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the default kind of position used by a media kind.
/// </summary>
/// <param name="mediaKind">The kind of media.</param>
/// <returns>The position kind that a resume point of the media kind uses.</returns>
private static MediaPositionKind ResolveDefaultPositionKind(MediaKind mediaKind)
{
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaConsumption;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaConsumption;
/// <summary>
/// Fixture class for the <see cref="TagConsumptionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TagConsumptionResponseFixture
{
private const double MAXIMUM_DURATION_SECONDS = 36_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TagConsumptionResponse"/>.
/// </summary>
/// <param name="name">Optional. The lowercase name of the tag.</param>
/// <param name="consumedItemCount">Optional. The number of distinct consumed media items that carry the tag.</param>
/// <param name="consumedDurationInSeconds">Optional. The consumed duration of the media items that carry the tag, in seconds. Defaults to a bounded random duration.</param>
/// <returns>The created <see cref="TagConsumptionResponse"/>.</returns>
public TagConsumptionResponse Create(
string? name = null,
int? consumedItemCount = null,
double? consumedDurationInSeconds = null)
{
return new TagConsumptionResponse(
name ?? _faker.Lorem.Word().ToLowerInvariant(),
consumedItemCount ?? _faker.Random.Int(0, 1000),
consumedDurationInSeconds ?? _faker.Random.Double(0, MAXIMUM_DURATION_SECONDS));
}
/// <summary>
/// Creates a list of <see cref="TagConsumptionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="TagConsumptionResponse"/> instances.</returns>
public List<TagConsumptionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="AlbumLiteResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AlbumLiteResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="AlbumLiteResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the album.</param>
/// <param name="title">Optional. The title of the album.</param>
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
/// <param name="coverPath">Optional. The path of the image representing the album.</param>
/// <param name="releaseYear">Optional. The release year of the album.</param>
/// <param name="releaseTypes">Optional. The set of types of the release.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseYear">Whether the release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseTypes">Whether the release types should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AlbumLiteResponse"/>.</returns>
public AlbumLiteResponse Create(
Guid? id = null,
string? title = null,
int? totalTracks = null,
string? coverPath = null,
int? releaseYear = null,
List<MusicReleaseType>? releaseTypes = null,
bool includeCoverPath = true,
bool includeReleaseYear = true,
bool includeReleaseTypes = true)
{
List<MusicReleaseType>? resolvedReleaseTypes = includeReleaseTypes
? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _faker.PickRandom<MusicReleaseType>())])
: null;
return new AlbumLiteResponse(
id ?? Guid.NewGuid(),
title ?? _faker.Commerce.ProductName(),
totalTracks ?? _faker.Random.Int(1, 30),
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
includeReleaseYear ? (releaseYear ?? _faker.Random.Int(1900, 2026)) : null,
resolvedReleaseTypes);
}
/// <summary>
/// Creates a list of <see cref="AlbumLiteResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AlbumLiteResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,151 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
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.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="AlbumResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AlbumResponseFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
private readonly TrackResponseFixture _trackResponseFixture = new();
private readonly MediaArtworkDtoFixture _mediaArtworkDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="AlbumResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the album.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
/// <param name="artistName">Optional. The name of the artist the album belongs to.</param>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to.</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="createdOnUtc">Optional. The date and time when the album was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the album was updated.</param>
/// <param name="contributors">Optional. The list of contributor references of the album.</param>
/// <param name="ratings">Optional. The list of ratings of the album.</param>
/// <param name="tracks">Optional. The list of tracks of the album.</param>
/// <param name="coverPath">Optional. The path of the image representing the album.</param>
/// <param name="artwork">Optional. The stored artwork of the album, in display order.</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="includeUpdatedOnUtc">Whether the update date 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="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArtwork">Whether the artwork should be included, or forced to an empty collection.</param>
/// <returns>The created <see cref="AlbumResponse"/>.</returns>
public AlbumResponse Create(
Guid? id = null,
Guid? artistId = null,
string? artistName = null,
Guid? libraryId = 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,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<TrackResponse>? tracks = null,
string? coverPath = null,
List<MediaArtworkDto>? artwork = null,
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 includeUpdatedOnUtc = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeTracks = true,
bool includeCoverPath = true,
bool includeArtwork = true)
{
IReadOnlyList<MediaArtworkDto> resolvedArtwork = includeArtwork
? (artwork ?? _mediaArtworkDtoFixture.CreateMany(1))
: [];
return new AlbumResponse(
id ?? Guid.NewGuid(),
artistId ?? Guid.NewGuid(),
artistName ?? _faker.Name.FullName(),
libraryId ?? Guid.NewGuid(),
metadata ?? _musicAlbumMetadataDtoFixture.Create(),
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(10)]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? Guid.NewGuid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? Guid.NewGuid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? Guid.NewGuid()) : null,
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent().ToUniversalTime()) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(1)) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(1)) : null,
includeTracks ? (tracks ?? _trackResponseFixture.CreateMany(1)) : null,
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
resolvedArtwork);
}
/// <summary>
/// Creates a list of <see cref="AlbumResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AlbumResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumCoverResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumCoverResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateAlbumCoverResponse"/>.
/// </summary>
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
/// <returns>The created <see cref="UpdateAlbumCoverResponse"/>.</returns>
public UpdateAlbumCoverResponse Create(string? coverPath = null)
{
return new UpdateAlbumCoverResponse(
coverPath ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumCoverResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateAlbumCoverResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="ArtistLiteResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ArtistLiteResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ArtistLiteResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the artist.</param>
/// <param name="name">Optional. The name of the artist.</param>
/// <param name="coverPath">Optional. The path of the image representing the artist.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ArtistLiteResponse"/>.</returns>
public ArtistLiteResponse Create(
Guid? id = null,
string? name = null,
string? coverPath = null,
bool includeCoverPath = true)
{
return new ArtistLiteResponse(
id ?? Guid.NewGuid(),
name ?? _faker.Name.FullName(),
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null);
}
/// <summary>
/// Creates a list of <see cref="ArtistLiteResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ArtistLiteResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,107 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
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.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="ArtistResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ArtistResponseFixture
{
private readonly Faker _faker = new();
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
private readonly AlbumResponseFixture _albumResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ArtistResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the artist.</param>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to.</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 list of contributor references of the artist.</param>
/// <param name="ratings">Optional. The list of ratings of the artist.</param>
/// <param name="albums">Optional. The list of albums of the artist.</param>
/// <param name="createdOnUtc">Optional. The date and time when the artist was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the artist was updated.</param>
/// <param name="coverPath">Optional. The path of the image representing the artist.</param>
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist Id 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="includeUpdatedOnUtc">Whether the update date 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>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ArtistResponse"/>.</returns>
public ArtistResponse Create(
Guid? id = null,
Guid? 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<AlbumResponse>? albums = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
string? coverPath = null,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeUpdatedOnUtc = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeAlbums = true,
bool includeCoverPath = true)
{
return new ArtistResponse(
id ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
metadata ?? _musicArtistMetadataDtoFixture.Create(),
includeWebsite ? (website ?? _faker.Internet.Url()) : null,
includeMusicBrainzArtistId ? (musicBrainzArtistId ?? Guid.NewGuid()) : 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,
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent().ToUniversalTime()) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(1)) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(1)) : null,
includeAlbums ? (albums ?? _albumResponseFixture.CreateMany(1)) : null,
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null);
}
/// <summary>
/// Creates a list of <see cref="ArtistResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ArtistResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistCoverResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistCoverResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateArtistCoverResponse"/>.
/// </summary>
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
/// <returns>The created <see cref="UpdateArtistCoverResponse"/>.</returns>
public UpdateArtistCoverResponse Create(string? coverPath = null)
{
return new UpdateArtistCoverResponse(
coverPath ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistCoverResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistCoverResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,119 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
/// <summary>
/// Fixture class for the <see cref="PlaybackManifestResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaybackManifestResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaybackManifestResponse"/>.
/// </summary>
/// <param name="trackId">Optional. The Id of the track the manifest describes.</param>
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
/// <param name="sourceContainer">Optional. The container of the stored audio file of the track.</param>
/// <param name="sourceCodec">Optional. The codec of the stored audio of the track.</param>
/// <param name="sampleRate">Optional. The sample rate of the stored audio, in Hz.</param>
/// <param name="channels">Optional. The number of audio channels of the track.</param>
/// <param name="bitDepth">Optional. The bit depth of the stored audio of the track.</param>
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain of the track, in decibels.</param>
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak of the track.</param>
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain of the track, in decibels.</param>
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak of the track.</param>
/// <param name="isDirectPlay">Whether the stored audio is delivered as it is.</param>
/// <param name="deliveryContainer">Optional. The container of the delivered audio.</param>
/// <param name="deliveryCodec">Optional. The codec of the delivered audio.</param>
/// <param name="deliveryShape">Optional. The shape the delivered audio is addressed by.</param>
/// <param name="segmentDurationSeconds">Optional. The duration of each segment of the delivered audio, in seconds.</param>
/// <param name="isSeekable">Whether the delivered audio can be seeked by the player.</param>
/// <param name="streamPath">Optional. The relative path of the track stream.</param>
/// <param name="deliveryId">Optional. The opaque handle of the normalized delivery.</param>
/// <param name="segmentStreamPathTemplate">Optional. The relative path template of the segment route.</param>
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReplayGain">Whether the ReplayGain values should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDeliveryContainer">Whether the delivery container should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDeliveryCodec">Whether the delivery codec should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDeliveryShape">Whether the delivery shape should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSegmentDurationSeconds">Whether the segment duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDeliveryId">Whether the delivery handle should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSegmentStreamPathTemplate">Whether the segment path template should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaybackManifestResponse"/>.</returns>
public PlaybackManifestResponse Create(
Guid? trackId = null,
int? durationInSeconds = null,
string? sourceContainer = null,
string? sourceCodec = null,
int? sampleRate = null,
int? channels = null,
int? bitDepth = null,
decimal? replayGainTrackGain = null,
decimal? replayGainTrackPeak = null,
decimal? replayGainAlbumGain = null,
decimal? replayGainAlbumPeak = null,
bool isDirectPlay = false,
string? deliveryContainer = null,
string? deliveryCodec = null,
PlaybackDeliveryShape? deliveryShape = null,
int? segmentDurationSeconds = null,
bool isSeekable = true,
string? streamPath = null,
string? deliveryId = null,
string? segmentStreamPathTemplate = null,
bool includeBitDepth = true,
bool includeReplayGain = true,
bool includeDeliveryContainer = true,
bool includeDeliveryCodec = true,
bool includeDeliveryShape = true,
bool includeSegmentDurationSeconds = true,
bool includeDeliveryId = true,
bool includeSegmentStreamPathTemplate = true)
{
Guid resolvedTrackId = trackId ?? _faker.Random.Guid();
string resolvedDeliveryId = deliveryId ?? Guid.NewGuid().ToString("N");
return new PlaybackManifestResponse(
resolvedTrackId,
durationInSeconds ?? _faker.Random.Int(1, 3600),
sourceContainer ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV"),
sourceCodec ?? _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC", "OPUS", "PCM"),
sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
channels ?? _faker.PickRandom(1, 2, 6),
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
includeReplayGain ? (replayGainTrackGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
includeReplayGain ? (replayGainTrackPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null,
includeReplayGain ? (replayGainAlbumGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
includeReplayGain ? (replayGainAlbumPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null,
isDirectPlay,
includeDeliveryContainer ? (deliveryContainer ?? "MP3") : null,
includeDeliveryCodec ? (deliveryCodec ?? "MP3") : null,
includeDeliveryShape ? (deliveryShape ?? PlaybackDeliveryShape.TimeAddressedSegments) : null,
includeSegmentDurationSeconds ? (segmentDurationSeconds ?? 6) : null,
isSeekable,
streamPath ?? $"/libraries/{Guid.NewGuid():N}/artists/{Guid.NewGuid():N}/albums/{Guid.NewGuid():N}/tracks/{resolvedTrackId:N}/stream",
includeDeliveryId ? resolvedDeliveryId : null,
includeSegmentStreamPathTemplate
? (segmentStreamPathTemplate ?? $"/libraries/{Guid.NewGuid():N}/artists/{Guid.NewGuid():N}/albums/{Guid.NewGuid():N}/tracks/{resolvedTrackId:N}/stream/deliveries/{{deliveryId}}/segments/{{segmentIndex}}")
: null);
}
/// <summary>
/// Creates a list of <see cref="PlaybackManifestResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaybackManifestResponse"/> instances.</returns>
public List<PlaybackManifestResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="ShuffleTrackResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ShuffleTrackResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ShuffleTrackResponse"/>.
/// </summary>
/// <param name="trackId">Optional. The Id of the track.</param>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="albumTitle">Optional. The title of the album the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
/// <param name="coverPath">Optional. The path of the cover of the album.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ShuffleTrackResponse"/>.</returns>
public ShuffleTrackResponse Create(
Guid? trackId = null,
string? title = null,
int? durationInSeconds = null,
Guid? albumId = null,
string? albumTitle = null,
Guid? artistId = null,
string? coverPath = null,
bool includeCoverPath = true)
{
return new ShuffleTrackResponse(
trackId ?? _faker.Random.Guid(),
title ?? _faker.Lorem.Sentence(),
durationInSeconds ?? _faker.Random.Int(1, 7200),
albumId ?? _faker.Random.Guid(),
albumTitle ?? _faker.Lorem.Sentence(),
artistId ?? _faker.Random.Guid(),
includeCoverPath ? (coverPath ?? _faker.System.FileName("jpg")) : null);
}
/// <summary>
/// Creates a list of <see cref="ShuffleTrackResponse"/> records with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ShuffleTrackResponse"/> records.</returns>
public List<ShuffleTrackResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="TrackLiteResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TrackLiteResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TrackLiteResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the track.</param>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
/// <returns>The created <see cref="TrackLiteResponse"/>.</returns>
public TrackLiteResponse Create(
Guid? id = null,
string? title = null,
int? trackNumber = null,
int? discNumber = null,
bool includeDiscNumber = true,
int? durationInSeconds = null)
{
return new TrackLiteResponse(
id ?? _faker.Random.Guid(),
title ?? _faker.Lorem.Sentence(),
trackNumber ?? _faker.Random.Int(1, 30),
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
durationInSeconds ?? _faker.Random.Int(1, 600));
}
/// <summary>
/// Creates a list of <see cref="TrackLiteResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<TrackLiteResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,119 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
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.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="TrackResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TrackResponseFixture
{
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 <see cref="TrackResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the track.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="libraryId">Optional. The Id of the media library this track belongs to.</param>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="container">Optional. The container of the audio file 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 recording Id of the track.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz track Id of the track.</param>
/// <param name="createdOnUtc">Optional. The date and time when the track was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the track was updated.</param>
/// <param name="moods">Optional. The list of moods of the track.</param>
/// <param name="isrcs">Optional. The list of ISRCs of the track.</param>
/// <param name="contributors">Optional. The list of contributor references of the track.</param>
/// <param name="ratings">Optional. The list of ratings of the track.</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="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="TrackResponse"/>.</returns>
public TrackResponse Create(
Guid? id = null,
Guid? albumId = null,
Guid? libraryId = 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,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeContainer = true,
string? container = null)
{
return new TrackResponse(
id ?? Guid.NewGuid(),
albumId ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
metadata ?? _musicTrackMetadataDtoFixture.Create(),
trackNumber ?? _faker.Random.Int(1, 30),
discNumber ?? (_faker.Random.Bool() ? _faker.Random.Int(1, 3) : null),
script ?? (_faker.Random.Bool() ? _faker.Random.AlphaNumeric(4) : null),
key ?? (_faker.Random.Bool() ? _faker.PickRandom<MusicKey>() : null),
bpm ?? (_faker.Random.Bool() ? _faker.Random.Int(40, 220) : null),
work ?? _musicWorkDtoFixture.Create(),
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? Guid.NewGuid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? Guid.NewGuid()) : null,
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
updatedOnUtc ?? (_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : null),
moods ?? _moodDtoFixture.CreateMany(1),
isrcs ?? _isrcDtoFixture.CreateMany(1),
contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(1),
ratings ?? _audioRatingDtoFixture.CreateMany(1),
includeContainer ? (container ?? _faker.Random.ArrayElement(["MP3", "FLAC", "OGG", "MP4", "AAC", "WAV"])) : null);
}
/// <summary>
/// Creates a list of <see cref="TrackResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<TrackResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathPartDefinitionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathPartDefinitionResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryPathPartDefinitionResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="valueType">Optional. The value type captured by the path part.</param>
/// <param name="defaultRepresentation">Optional. The default representation of the path part.</param>
/// <param name="isOptionalByDefault">Whether the path part is optional by default.</param>
/// <returns>The created <see cref="LibraryPathPartDefinitionResponse"/>.</returns>
public LibraryPathPartDefinitionResponse Create(
string? kind = null,
string? valueType = null,
string? defaultRepresentation = null,
bool isOptionalByDefault = false)
{
return new LibraryPathPartDefinitionResponse(
kind ?? "Artist",
valueType ?? "Text",
defaultRepresentation ?? "{0}",
isOptionalByDefault);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathPartDefinitionResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathPartDefinitionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplateCatalogResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplateCatalogResponseFixture
{
private readonly LibraryPathPartDefinitionResponseFixture _libraryPathPartDefinitionResponseFixture = new();
private readonly LibraryPathTemplatePartResponseFixture _libraryPathTemplatePartResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplateCatalogResponse"/>.
/// </summary>
/// <param name="parts">Optional. The path parts that can be used in the path template of the library type.</param>
/// <param name="defaultTemplateParts">Optional. The ordered parts of the default path template of the library type.</param>
/// <param name="includeParts">Whether the catalog should carry selectable path parts. When <see langword="false"/>, no parts are created.</param>
/// <param name="includeDefaultTemplateParts">Whether the catalog should carry default template parts. When <see langword="false"/>, no default template parts are created.</param>
/// <returns>The created <see cref="LibraryPathTemplateCatalogResponse"/>.</returns>
public LibraryPathTemplateCatalogResponse Create(
List<LibraryPathPartDefinitionResponse>? parts = null,
List<LibraryPathTemplatePartResponse>? defaultTemplateParts = null,
bool includeParts = true,
bool includeDefaultTemplateParts = true)
{
return new LibraryPathTemplateCatalogResponse(
includeParts ? (parts ?? _libraryPathPartDefinitionResponseFixture.CreateMany(2)) : [],
includeDefaultTemplateParts ? (defaultTemplateParts ?? _libraryPathTemplatePartResponseFixture.CreateMany(2)) : []);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathTemplateCatalogResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathTemplateCatalogResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplatePartResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplatePartResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplatePartResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="representation">Optional. The literal text or the value mask of the path part.</param>
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
/// <returns>The created <see cref="LibraryPathTemplatePartResponse"/>.</returns>
public LibraryPathTemplatePartResponse Create(
string? kind = null,
string? representation = null,
bool isOptional = false)
{
return new LibraryPathTemplatePartResponse(
kind ?? "Artist",
representation ?? "{0}",
isOptional);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathTemplatePartResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathTemplatePartResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,96 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LibraryResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the media library.</param>
/// <param name="userId">Optional. The Id of the user owning 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 file system paths of the media library content directories.</param>
/// <param name="coverImage">Optional. The path of the image file used as the cover of the library.</param>
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Optional. Whether hidden files and directories should be skipped during scan.</param>
/// <param name="isContentOnSsd">Optional. 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 is tracked.</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="createdOnUtc">Optional. The date and time when the library was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the library was updated.</param>
/// <returns>The created <see cref="LibraryResponse"/>.</returns>
public LibraryResponse Create(
Guid? id = null,
Guid? userId = null,
string? title = null,
LibraryType? libraryType = null,
List<string>? contentLocations = null,
string? coverImage = null,
bool? isEnabled = null,
bool? isLocked = null,
bool? canDownloadMetadataFromWeb = null,
bool? shouldSaveMetadataInMediaDirectories = null,
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null,
bool? isContentOnSsd = null,
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
List<LibraryPathTemplatePartResponse>? pathTemplateParts = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null)
{
bool resolvedShouldTrackConsumptionProgress = shouldTrackConsumptionProgress ?? _faker.Random.Bool();
int? resolvedCompletionThresholdPercentage = completionThresholdPercentage ?? (resolvedShouldTrackConsumptionProgress ? _faker.Random.Int(0, 100) : null);
return new LibraryResponse(
id ?? Guid.NewGuid(),
userId ?? Guid.NewGuid(),
title ?? _faker.Commerce.Department(),
libraryType ?? _faker.PickRandom<LibraryType>(),
contentLocations ?? [_faker.System.DirectoryPath(), _faker.System.DirectoryPath()],
coverImage,
isEnabled ?? _faker.Random.Bool(),
isLocked ?? _faker.Random.Bool(),
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
shouldSkipHiddenFilesAndDirectoriesDuringScan ?? _faker.Random.Bool(),
isContentOnSsd ?? false,
resolvedShouldTrackConsumptionProgress,
resolvedCompletionThresholdPercentage,
pathTemplateParts ?? [],
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
updatedOnUtc
);
}
/// <summary>
/// Creates a list of <see cref="LibraryResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanJobProgressResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanJobProgressResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanJobProgressResponse"/>.
/// </summary>
/// <param name="completedItems">Optional. The number of processed scan job items.</param>
/// <param name="totalItems">Optional. The total number of scan job items.</param>
/// <param name="currentOperation">Optional. The current processing operation in the scan job.</param>
/// <param name="progressPercentage">Optional. The progress percentage of the scan job.</param>
/// <returns>The created <see cref="MediaLibraryScanJobProgressResponse"/>.</returns>
public MediaLibraryScanJobProgressResponse Create(
int? completedItems = null,
int? totalItems = null,
string? currentOperation = null,
decimal? progressPercentage = null)
{
return new MediaLibraryScanJobProgressResponse(
completedItems ?? _faker.Random.Int(0, 100),
totalItems ?? _faker.Random.Int(100, 1000),
currentOperation ?? _faker.Lorem.Word(),
progressPercentage ?? _faker.Random.Decimal(0m, 100m)
);
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanJobProgressResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaLibraryScanJobProgressResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanProgressResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanProgressResponseFixture
{
private readonly Faker _faker = new();
private readonly MediaLibraryScanJobProgressResponseFixture _mediaLibraryScanJobProgressResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanProgressResponse"/>.
/// </summary>
/// <param name="scanId">Optional. The Id of the media library scan.</param>
/// <param name="userId">Optional. The Id of the user initiating the media library scan.</param>
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
/// <param name="totalJobs">Optional. The total number of jobs to be processed by the scan.</param>
/// <param name="completedJobs">Optional. The number of jobs that have been processed.</param>
/// <param name="currentJobProgress">Optional. The progress of the currently processing job.</param>
/// <param name="status">Optional. The status of the scan.</param>
/// <param name="overallProgressPercentage">Optional. The overall progress percentage of the scan.</param>
/// <returns>The created <see cref="MediaLibraryScanProgressResponse"/>.</returns>
public MediaLibraryScanProgressResponse Create(
Guid? scanId = null,
Guid? userId = null,
Guid? libraryId = null,
int? totalJobs = null,
int? completedJobs = null,
MediaLibraryScanJobProgressResponse? currentJobProgress = null,
string? status = null,
decimal? overallProgressPercentage = null)
{
return new MediaLibraryScanProgressResponse(
scanId ?? Guid.NewGuid(),
userId ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
totalJobs ?? _faker.Random.Int(1, 10),
completedJobs ?? _faker.Random.Int(0, 10),
currentJobProgress ?? _mediaLibraryScanJobProgressResponseFixture.Create(),
status ?? _faker.Lorem.Word(),
overallProgressPercentage ?? _faker.Random.Decimal(0m, 100m)
);
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanProgressResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaLibraryScanProgressResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanResponse"/>.
/// </summary>
/// <param name="scanId">Optional. The Id of the media library scan.</param>
/// <param name="libraryId">Optional. The Id of the media library the scan belongs to.</param>
/// <returns>The created <see cref="MediaLibraryScanResponse"/>.</returns>
public MediaLibraryScanResponse Create(
Guid? scanId = null,
Guid? libraryId = null)
{
return new MediaLibraryScanResponse(scanId ?? Guid.NewGuid(), libraryId ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaLibraryScanResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="BookLiteResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookLiteResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BookLiteResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the book.</param>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="releaseYear">Optional. The release year of the book.</param>
/// <param name="coverPath">Optional. The path of the image representing the cover of the book.</param>
/// <param name="includeReleaseYear">Whether the release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookLiteResponse"/>.</returns>
public BookLiteResponse Create(
Guid? id = null,
string? title = null,
int? releaseYear = null,
string? coverPath = null,
bool includeReleaseYear = true,
bool includeCoverPath = true)
{
return new BookLiteResponse(
id ?? Guid.NewGuid(),
title ?? _faker.Commerce.ProductName(),
includeReleaseYear ? (releaseYear ?? _faker.Random.Int(1900, 2024)) : null,
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
);
}
/// <summary>
/// Creates a list of <see cref="BookLiteResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookLiteResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,94 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
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.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="BookResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookResponseFixture
{
private readonly Faker _faker = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
private readonly IsbnDtoFixture _isbnDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
private readonly BookSeriesDtoFixture _bookSeriesDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="BookResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the book.</param>
/// <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="metadataStatus">Optional. The metadata enrichment status of the book.</param>
/// <param name="createdOnUtc">Optional. The date and time when the book was created.</param>
/// <param name="coverPath">Optional. The file system path of the cover image of the book.</param>
/// <returns>The created <see cref="BookResponse"/>.</returns>
public BookResponse Create(
Guid? id = null,
Guid? libraryId = null,
string? path = null,
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
MetadataStatus? metadataStatus = null,
DateTime? createdOnUtc = null,
string? coverPath = null)
{
DateTime resolvedCreatedOnUtc = createdOnUtc ?? _faker.Date.Past().ToUniversalTime();
return new BookResponse(
id ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
metadata ?? _writtenContentMetadataDtoFixture.Create(),
format ?? _faker.PickRandom<BookFormat>(),
_faker.Lorem.Word(),
_faker.Random.Int(1, 10),
_bookSeriesDtoFixture.Create(),
_faker.Random.AlphaNumeric(10),
_faker.Random.AlphaNumeric(5),
_faker.Random.AlphaNumeric(8),
_faker.Random.AlphaNumeric(10),
_faker.Random.AlphaNumeric(7),
_faker.Random.AlphaNumeric(7),
_faker.Random.AlphaNumeric(6),
_faker.Random.AlphaNumeric(10),
_faker.Random.AlphaNumeric(8),
_isbnDtoFixture.CreateMany(1),
_mediaContributorReferenceDtoFixture.CreateMany(1),
_bookRatingDtoFixture.CreateMany(1),
metadataStatus ?? _faker.PickRandom<MetadataStatus>(),
_faker.Date.Recent().ToUniversalTime(),
_faker.Company.CompanyName(),
resolvedCreatedOnUtc,
_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : null,
coverPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)
);
}
/// <summary>
/// Creates a list of <see cref="BookResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingAvailabilityResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingAvailabilityResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingAvailabilityResponse"/>.
/// </summary>
/// <param name="bookId">Optional. The Id of the book whose reading availability is reported.</param>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
/// <param name="isAvailable">Optional. Whether the book can be opened for reading.</param>
/// <param name="errorCode">Optional. The code of the error preventing the book from being read, when it cannot be read.</param>
/// <returns>The created <see cref="ReadingAvailabilityResponse"/>.</returns>
public ReadingAvailabilityResponse Create(
Guid? bookId = null,
Guid? libraryId = null,
bool? isAvailable = null,
string? errorCode = null)
{
return new ReadingAvailabilityResponse(
bookId ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
isAvailable ?? true,
errorCode
);
}
/// <summary>
/// Creates a list of <see cref="ReadingAvailabilityResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingAvailabilityResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingManifestResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingManifestResponseFixture
{
private readonly ReadingTocEntryResponseFixture _readingTocEntryResponseFixture = new();
private readonly ReadingSpineItemResponseFixture _readingSpineItemResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ReadingManifestResponse"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="author">Optional. The author of the book, if known.</param>
/// <param name="coverResourceKey">Optional. The resource key of the cover image of the book, if applicable.</param>
/// <param name="tableOfContents">Optional. The hierarchical table of contents of the book.</param>
/// <param name="spine">Optional. The ordered spine of the reading sections of the book.</param>
/// <param name="resourceKeys">Optional. The resource keys of the resources of the book.</param>
/// <param name="hasTextContent">Optional. Whether the book has extractable text content.</param>
/// <returns>The created <see cref="ReadingManifestResponse"/>.</returns>
public ReadingManifestResponse Create(
string? title = null,
string? author = null,
string? coverResourceKey = null,
IReadOnlyList<ReadingTocEntryResponse>? tableOfContents = null,
IReadOnlyList<ReadingSpineItemResponse>? spine = null,
IReadOnlyList<string>? resourceKeys = null,
bool? hasTextContent = null)
{
return new ReadingManifestResponse(
title ?? $"Book {Guid.NewGuid():N}",
author,
coverResourceKey,
tableOfContents ?? [.. _readingTocEntryResponseFixture.CreateMany(2)],
spine ?? [.. _readingSpineItemResponseFixture.CreateMany(2)],
resourceKeys ?? [.. Enumerable.Range(0, 2).Select(_ => $"resource-{Guid.NewGuid():N}")],
hasTextContent ?? true
);
}
/// <summary>
/// Creates a list of <see cref="ReadingManifestResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingManifestResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingSpineItemResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingSpineItemResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingSpineItemResponse"/>.
/// </summary>
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
/// <param name="title">Optional. The title of the reading section, if known.</param>
/// <returns>The created <see cref="ReadingSpineItemResponse"/>.</returns>
public ReadingSpineItemResponse Create(
string? locationRef = null,
string? title = null)
{
return new ReadingSpineItemResponse(locationRef ?? $"section-{Guid.NewGuid():N}", title);
}
/// <summary>
/// Creates a list of <see cref="ReadingSpineItemResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingSpineItemResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingTocEntryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingTocEntryResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingTocEntryResponse"/>.
/// </summary>
/// <param name="label">Optional. The label of the table of contents entry.</param>
/// <param name="locationRef">Optional. The opaque location reference of the reading section the entry points to.</param>
/// <param name="children">Optional. The child entries of the table of contents entry.</param>
/// <returns>The created <see cref="ReadingTocEntryResponse"/>.</returns>
public ReadingTocEntryResponse Create(
string? label = null,
string? locationRef = null,
IReadOnlyList<ReadingTocEntryResponse>? children = null)
{
return new ReadingTocEntryResponse(
label ?? $"Chapter {Guid.NewGuid():N}",
locationRef ?? $"section-{Guid.NewGuid():N}",
children ?? []
);
}
/// <summary>
/// Creates a list of <see cref="ReadingTocEntryResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingTocEntryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="UpdateBookCoverResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateBookCoverResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateBookCoverResponse"/>.
/// </summary>
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
/// <returns>The created <see cref="UpdateBookCoverResponse"/>.</returns>
public UpdateBookCoverResponse Create(string? coverPath = null)
{
return new UpdateBookCoverResponse(
coverPath ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="UpdateBookCoverResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateBookCoverResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,58 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistDetailsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistDetailsResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistDetailsResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the playlist.</param>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="description">Optional. The description of the playlist.</param>
/// <param name="type">Optional. The kind of media the playlist holds.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistDetailsResponse"/>.</returns>
public PlaylistDetailsResponse Create(
Guid? id = null,
string? name = null,
string? description = null,
PlaylistType? type = null,
DateTime? updatedOnUtc = null,
bool includeDescription = true,
bool includeUpdatedOnUtc = true)
{
return new PlaylistDetailsResponse(
id ?? _faker.Random.Guid(),
name ?? _faker.Lorem.Sentence(3),
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
type ?? PlaylistType.Music,
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistDetailsResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistDetailsResponse"/> instances.</returns>
public List<PlaylistDetailsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntriesAddedResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntriesAddedResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntriesAddedResponse"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist the entries were added to.</param>
/// <param name="addedCount">Optional. The number of entries that were appended.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistEntriesAddedResponse"/>.</returns>
public PlaylistEntriesAddedResponse Create(
Guid? playlistId = null,
int? addedCount = null,
DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = true)
{
return new PlaylistEntriesAddedResponse(
playlistId ?? _faker.Random.Guid(),
addedCount ?? _faker.Random.Int(0, 1_000),
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntriesAddedResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntriesAddedResponse"/> instances.</returns>
public List<PlaylistEntriesAddedResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntryAddedResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryAddedResponseFixture
{
private readonly Faker _faker = new();
private readonly PlaylistEntryResponseFixture _playlistEntryResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntryAddedResponse"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist the entry was added to.</param>
/// <param name="entry">Optional. The added entry.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistEntryAddedResponse"/>.</returns>
public PlaylistEntryAddedResponse Create(
Guid? playlistId = null,
PlaylistEntryResponse? entry = null,
DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = true)
{
return new PlaylistEntryAddedResponse(
playlistId ?? _faker.Random.Guid(),
entry ?? _playlistEntryResponseFixture.Create(),
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntryAddedResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntryAddedResponse"/> instances.</returns>
public List<PlaylistEntryAddedResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntryMovedResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryMovedResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntryMovedResponse"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist whose entry was moved.</param>
/// <param name="entryId">Optional. The Id of the moved entry.</param>
/// <param name="position">Optional. The new zero based position of the entry.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistEntryMovedResponse"/>.</returns>
public PlaylistEntryMovedResponse Create(
Guid? playlistId = null,
Guid? entryId = null,
int? position = null,
DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = true)
{
return new PlaylistEntryMovedResponse(
playlistId ?? _faker.Random.Guid(),
entryId ?? _faker.Random.Guid(),
position ?? _faker.Random.Int(0, 1_000),
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntryMovedResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntryMovedResponse"/> instances.</returns>
public List<PlaylistEntryMovedResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntryRemovedResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryRemovedResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntryRemovedResponse"/>.
/// </summary>
/// <param name="playlistId">Optional. The Id of the playlist the entry was removed from.</param>
/// <param name="removedEntryId">Optional. The Id of the removed entry.</param>
/// <param name="repositionedCount">Optional. The number of entries that were repositioned, which the contract always reports as zero.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistEntryRemovedResponse"/>.</returns>
public PlaylistEntryRemovedResponse Create(
Guid? playlistId = null,
Guid? removedEntryId = null,
int? repositionedCount = null,
DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = true)
{
return new PlaylistEntryRemovedResponse(
playlistId ?? _faker.Random.Guid(),
removedEntryId ?? _faker.Random.Guid(),
repositionedCount ?? 0,
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntryRemovedResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntryRemovedResponse"/> instances.</returns>
public List<PlaylistEntryRemovedResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,77 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntryResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the entry.</param>
/// <param name="mediaItemId">Optional. The Id of the media item referenced by the entry.</param>
/// <param name="mediaItemType">Optional. The kind of media item referenced by the entry.</param>
/// <param name="position">Optional. The zero based position of the entry in the playlist.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
/// <param name="mediaItemTitle">Optional. The title of the media item.</param>
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
/// <param name="durationInSeconds">Optional. The duration of the media item in seconds.</param>
/// <param name="coverPath">Optional. The path of the cover art of the collection.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistEntryResponse"/>.</returns>
public PlaylistEntryResponse Create(
Guid? id = null,
Guid? mediaItemId = null,
PlaylistMediaItemType? mediaItemType = null,
int? position = null,
Guid? libraryId = null,
Guid? collectionId = null,
Guid? creatorId = null,
string? mediaItemTitle = null,
string? collectionTitle = null,
string? creatorName = null,
int? durationInSeconds = null,
string? coverPath = null,
bool includeCoverPath = true)
{
return new PlaylistEntryResponse(
id ?? _faker.Random.Guid(),
mediaItemId ?? _faker.Random.Guid(),
mediaItemType ?? _faker.PickRandom<PlaylistMediaItemType>(),
position ?? _faker.Random.Int(0, 1_000),
libraryId ?? _faker.Random.Guid(),
collectionId ?? _faker.Random.Guid(),
creatorId ?? _faker.Random.Guid(),
mediaItemTitle ?? _faker.Lorem.Sentence(3),
collectionTitle ?? _faker.Lorem.Sentence(2),
creatorName ?? _faker.Name.FullName(),
durationInSeconds ?? _faker.Random.Int(1, 3_600),
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntryResponse"/> instances.</returns>
public List<PlaylistEntryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,83 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Fixtures.Responses.Common;
using Lumina.Contracts.Responses.Common;
using Lumina.Contracts.Responses.Playlists;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistResponseFixture
{
private const int DEFAULT_ENTRY_COUNT = 3;
private readonly Faker _faker = new();
private readonly PlaylistEntryResponseFixture _playlistEntryResponseFixture = new();
private readonly PaginatedResponseFixture<PlaylistEntryResponse> _paginatedResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the playlist.</param>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="description">Optional. The description of the playlist.</param>
/// <param name="type">Optional. The kind of media the playlist holds.</param>
/// <param name="entries">Optional. The page of entries of the playlist.</param>
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistResponse"/>.</returns>
public PlaylistResponse Create(
Guid? id = null,
string? name = null,
string? description = null,
PlaylistType? type = null,
PaginatedResponse<PlaylistEntryResponse>? entries = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
bool includeDescription = true,
bool includeUpdatedOnUtc = true)
{
return new PlaylistResponse(
id ?? _faker.Random.Guid(),
name ?? _faker.Lorem.Sentence(3),
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
type ?? PlaylistType.Music,
entries ?? CreateEntriesPage(),
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)),
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistResponse"/> instances.</returns>
public List<PlaylistResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a page of random playlist entries.
/// </summary>
/// <returns>The created page of playlist entries.</returns>
private PaginatedResponse<PlaylistEntryResponse> CreateEntriesPage()
{
List<PlaylistEntryResponse> entries = [];
for (int index = 0; index < DEFAULT_ENTRY_COUNT; index++)
entries.Add(_playlistEntryResponseFixture.Create(position: index));
return _paginatedResponseFixture.Create(data: entries, currentPage: 1, perPage: DEFAULT_ENTRY_COUNT, count: DEFAULT_ENTRY_COUNT, numberOfPages: 1);
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Playlists;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
/// <summary>
/// Fixture class for the <see cref="PlaylistSummaryResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistSummaryResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistSummaryResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the playlist.</param>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="description">Optional. The description of the playlist.</param>
/// <param name="type">Optional. The kind of media the playlist holds.</param>
/// <param name="entryCount">Optional. The number of entries of the playlist.</param>
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="PlaylistSummaryResponse"/>.</returns>
public PlaylistSummaryResponse Create(
Guid? id = null,
string? name = null,
string? description = null,
PlaylistType? type = null,
int? entryCount = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
bool includeDescription = true,
bool includeUpdatedOnUtc = true)
{
return new PlaylistSummaryResponse(
id ?? _faker.Random.Guid(),
name ?? _faker.Lorem.Sentence(3),
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
type ?? PlaylistType.Music,
entryCount ?? _faker.Random.Int(0, 1_000),
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)),
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
}
/// <summary>
/// Creates a list of <see cref="PlaylistSummaryResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistSummaryResponse"/> instances.</returns>
public List<PlaylistSummaryResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="LibraryArtworkProviderResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryArtworkProviderResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LibraryArtworkProviderResponse"/>.
/// </summary>
/// <param name="pluginId">Optional. The Id of the plugin providing the artwork.</param>
/// <param name="name">Optional. The display name of the artwork provider.</param>
/// <param name="isEnabled">Optional. Whether the artwork provider is enabled for the media library.</param>
/// <param name="rank">Optional. The rank of the artwork provider.</param>
/// <returns>The created <see cref="LibraryArtworkProviderResponse"/>.</returns>
public LibraryArtworkProviderResponse Create(
Guid? pluginId = null,
string? name = null,
bool? isEnabled = null,
int? rank = null)
{
return new LibraryArtworkProviderResponse(
pluginId ?? Guid.NewGuid(),
name ?? _faker.Company.CompanyName(),
isEnabled ?? _faker.Random.Bool(),
rank ?? _faker.Random.Int(1, 100));
}
/// <summary>
/// Creates a list of <see cref="LibraryArtworkProviderResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryArtworkProviderResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="LibraryBookReaderResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryBookReaderResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryBookReaderResponse"/>.
/// </summary>
/// <param name="pluginId">Optional. The unique identifier of the plugin providing the book reader.</param>
/// <param name="name">Optional. The display name of the book reader.</param>
/// <param name="supportedExtensions">Optional. The file extensions supported by the book reader.</param>
/// <param name="isEnabled">Optional. Whether the book reader is enabled for the media library.</param>
/// <returns>The created <see cref="LibraryBookReaderResponse"/>.</returns>
public LibraryBookReaderResponse Create(
Guid? pluginId = null,
string? name = null,
IReadOnlyList<string>? supportedExtensions = null,
bool? isEnabled = null)
{
return new LibraryBookReaderResponse(
pluginId ?? Guid.NewGuid(),
name ?? $"Reader {Guid.NewGuid():N}",
supportedExtensions ?? [".epub", ".pdf"],
isEnabled ?? true
);
}
/// <summary>
/// Creates a list of <see cref="LibraryBookReaderResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryBookReaderResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="LibraryMetadataProviderResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryMetadataProviderResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LibraryMetadataProviderResponse"/>.
/// </summary>
/// <param name="pluginId">Optional. The Id of the plugin providing the metadata.</param>
/// <param name="name">Optional. The display name of the metadata provider.</param>
/// <param name="isEnabled">Optional. Whether the metadata provider is enabled for the media library.</param>
/// <param name="rank">Optional. The rank of the metadata provider.</param>
/// <returns>The created <see cref="LibraryMetadataProviderResponse"/>.</returns>
public LibraryMetadataProviderResponse Create(
Guid? pluginId = null,
string? name = null,
bool? isEnabled = null,
int? rank = null)
{
return new LibraryMetadataProviderResponse(
pluginId ?? Guid.NewGuid(),
name ?? _faker.Company.CompanyName(),
isEnabled ?? _faker.Random.Bool(),
rank ?? _faker.Random.Int(1, 100));
}
/// <summary>
/// Creates a list of <see cref="LibraryMetadataProviderResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryMetadataProviderResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PluginResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the plugin.</param>
/// <param name="name">Optional. The display name of the plugin.</param>
/// <param name="author">Optional. The author of the plugin.</param>
/// <param name="version">Optional. The version of the plugin.</param>
/// <param name="description">Optional. The description of the plugin.</param>
/// <param name="loadStatus">Optional. The load status of the plugin.</param>
/// <param name="loadError">Optional. The error message when the plugin failed to load.</param>
/// <param name="settings">Optional. The settings of the plugin.</param>
/// <returns>The created <see cref="PluginResponse"/>.</returns>
public PluginResponse Create(
Guid? id = null,
string? name = null,
string? author = null,
string? version = null,
string? description = null,
PluginLoadStatus? loadStatus = null,
string? loadError = null,
IReadOnlyDictionary<string, string>? settings = null)
{
return new PluginResponse(
id ?? Guid.NewGuid(),
name ?? _faker.Commerce.ProductName(),
author ?? _faker.Company.CompanyName(),
version ?? _faker.System.Semver(),
description ?? _faker.Lorem.Sentence(),
loadStatus ?? _faker.PickRandom<PluginLoadStatus>(),
loadError,
settings ?? new Dictionary<string, string>
{
[_faker.Lorem.Word()] = _faker.Lorem.Word()
}
);
}
/// <summary>
/// Creates a list of <see cref="PluginResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginSettingDescriptorResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingDescriptorResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PluginSettingDescriptorResponse"/>.
/// </summary>
/// <param name="key">Optional. The unique key of the setting.</param>
/// <param name="label">Optional. The display label of the setting.</param>
/// <param name="type">Optional. The type of the setting.</param>
/// <param name="defaultValue">Optional. The default value of the setting.</param>
/// <param name="allowedValues">Optional. The list of allowed values, when the setting is a selection.</param>
/// <returns>The created <see cref="PluginSettingDescriptorResponse"/>.</returns>
public PluginSettingDescriptorResponse Create(
string? key = null,
string? label = null,
PluginSettingType? type = null,
string? defaultValue = null,
IReadOnlyList<string>? allowedValues = null)
{
return new PluginSettingDescriptorResponse(
key ?? _faker.Lorem.Word(),
label ?? _faker.Lorem.Word(),
type ?? _faker.PickRandom<PluginSettingType>(),
defaultValue,
allowedValues ?? [_faker.Lorem.Word(), _faker.Lorem.Word()]
);
}
/// <summary>
/// Creates a list of <see cref="PluginSettingDescriptorResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginSettingDescriptorResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginSettingsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingsResponseFixture
{
private readonly Faker _faker = new();
private readonly PluginSettingDescriptorResponseFixture _pluginSettingDescriptorResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="PluginSettingsResponse"/>.
/// </summary>
/// <param name="pluginId">Optional. The Id of the plugin.</param>
/// <param name="schema">Optional. The schema of the plugin settings.</param>
/// <param name="settings">Optional. The current values of the plugin settings.</param>
/// <returns>The created <see cref="PluginSettingsResponse"/>.</returns>
public PluginSettingsResponse Create(
Guid? pluginId = null,
IReadOnlyList<PluginSettingDescriptorResponse>? schema = null,
IReadOnlyDictionary<string, string>? settings = null)
{
return new PluginSettingsResponse(
pluginId ?? Guid.NewGuid(),
schema ?? _pluginSettingDescriptorResponseFixture.CreateMany(3),
settings ?? new Dictionary<string, string>
{
[_faker.Lorem.Word()] = _faker.Lorem.Word()
}
);
}
/// <summary>
/// Creates a list of <see cref="PluginSettingsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginSettingsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobExecutionResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="ScheduledJobExecutionResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the execution.</param>
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task was executed.</param>
/// <param name="taskType">Optional. The type of the task that was executed.</param>
/// <param name="isCycleRun">Optional. Whether the execution was a cycle run.</param>
/// <param name="startedOnUtc">Optional. The start time of the execution.</param>
/// <param name="completedOnUtc">Optional. The completion time of the execution.</param>
/// <returns>The created <see cref="ScheduledJobExecutionResponse"/>.</returns>
public ScheduledJobExecutionResponse Create(
Guid? id = null,
Guid? scheduledJobId = null,
ScheduledTaskType? taskType = null,
bool? isCycleRun = null,
DateTime? startedOnUtc = null,
DateTime? completedOnUtc = null)
{
return new Faker<ScheduledJobExecutionResponse>()
.CustomInstantiator(f => new ScheduledJobExecutionResponse(
id ?? Guid.NewGuid(),
scheduledJobId ?? Guid.NewGuid(),
taskType ?? f.PickRandom<ScheduledTaskType>(),
isCycleRun ?? f.Random.Bool(),
startedOnUtc ?? DateTime.UtcNow,
completedOnUtc))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="ScheduledJobExecutionResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ScheduledJobExecutionResponse"/> instances.</returns>
public List<ScheduledJobExecutionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,87 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="ScheduledJobResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the scheduled job.</param>
/// <param name="name">Optional. The name of the scheduled job.</param>
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
/// <param name="hour">Optional. The hour of the schedule.</param>
/// <param name="minute">Optional. The minute of the schedule.</param>
/// <param name="status">Optional. The status of the scheduled job.</param>
/// <param name="lastStartedOnUtc">Optional. The last start time of the scheduled job.</param>
/// <param name="lastCompletedOnUtc">Optional. The last completion time of the scheduled job.</param>
/// <returns>The created <see cref="ScheduledJobResponse"/>.</returns>
public ScheduledJobResponse Create(
Guid? id = null,
string? name = null,
ScheduledTaskType? taskType = null,
ScheduleType? scheduleType = null,
int? intervalMinutes = null,
int? hour = null,
int? minute = null,
ScheduledJobStatus? status = null,
DateTime? lastStartedOnUtc = null,
DateTime? lastCompletedOnUtc = null)
{
return new Faker<ScheduledJobResponse>()
.CustomInstantiator(f =>
{
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
{
return new ScheduledJobResponse(
id ?? Guid.NewGuid(),
name ?? f.Commerce.ProductName(),
taskType ?? f.PickRandom<ScheduledTaskType>(),
resolvedScheduleType,
intervalMinutes ?? f.Random.Int(1, 1440),
null,
null,
status ?? f.PickRandom<ScheduledJobStatus>(),
lastStartedOnUtc,
lastCompletedOnUtc);
}
return new ScheduledJobResponse(
id ?? Guid.NewGuid(),
name ?? f.Commerce.ProductName(),
taskType ?? f.PickRandom<ScheduledTaskType>(),
resolvedScheduleType,
null,
hour ?? f.Random.Int(0, 23),
minute ?? f.Random.Int(0, 59),
status ?? f.PickRandom<ScheduledJobStatus>(),
lastStartedOnUtc,
lastCompletedOnUtc);
})
.Generate();
}
/// <summary>
/// Creates a list of <see cref="ScheduledJobResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ScheduledJobResponse"/> instances.</returns>
public List<ScheduledJobResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
/// <summary>
/// Fixture class for the <see cref="SchedulerDisplayPreferencesResponse"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class SchedulerDisplayPreferencesResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="SchedulerDisplayPreferencesResponse"/>.
/// </summary>
/// <param name="userId">Optional. The Id of the user that owns the display preferences.</param>
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
/// <returns>The created <see cref="SchedulerDisplayPreferencesResponse"/>.</returns>
public SchedulerDisplayPreferencesResponse Create(
Guid? userId = null,
ScheduledTaskType? jobTypeFilter = null,
int? displayTimeSpan = null,
SchedulerDisplayTimeUnit? displayTimeUnit = null)
{
return new Faker<SchedulerDisplayPreferencesResponse>()
.CustomInstantiator(f => new SchedulerDisplayPreferencesResponse(
userId ?? Guid.NewGuid(),
jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
displayTimeSpan ?? f.Random.Int(1, 24 * 60),
displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="SchedulerDisplayPreferencesResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="SchedulerDisplayPreferencesResponse"/> instances.</returns>
public List<SchedulerDisplayPreferencesResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Themes;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeArchiveResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeArchiveResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeArchiveResponse"/>.
/// </summary>
/// <param name="bytes">Optional. The bytes of the ZIP archive.</param>
/// <param name="fileName">Optional. The file name to expose when downloading the archive.</param>
/// <param name="contentType">Optional. The MIME content type of the archive.</param>
/// <returns>The created <see cref="ThemeArchiveResponse"/>.</returns>
public ThemeArchiveResponse Create(byte[]? bytes = null, string? fileName = null, string? contentType = null)
{
return new ThemeArchiveResponse(
bytes ?? Encoding.UTF8.GetBytes(_faker.Lorem.Paragraph()),
fileName ?? $"{_faker.Lorem.Word()}.zip",
contentType ?? _faker.System.MimeType());
}
/// <summary>
/// Creates a list of <see cref="ThemeArchiveResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeArchiveResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Themes;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeAssetResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeAssetResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeAssetResponse"/>.
/// </summary>
/// <param name="bytes">Optional. The bytes of the asset file.</param>
/// <param name="contentType">Optional. The MIME content type of the asset file.</param>
/// <returns>The created <see cref="ThemeAssetResponse"/>.</returns>
public ThemeAssetResponse Create(byte[]? bytes = null, string? contentType = null)
{
return new ThemeAssetResponse(
bytes ?? Encoding.UTF8.GetBytes(_faker.Lorem.Paragraph()),
contentType ?? _faker.System.MimeType());
}
/// <summary>
/// Creates a list of <see cref="ThemeAssetResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeAssetResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,76 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Themes;
using Lumina.Domain.SharedKernel.Common.Enums.Themes;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the theme.</param>
/// <param name="themeId">Optional. The manifest id of the theme.</param>
/// <param name="name">Optional. The display name of the theme.</param>
/// <param name="description">Optional. The description of the theme.</param>
/// <param name="author">Optional. The author of the theme.</param>
/// <param name="version">Optional. The version of the theme.</param>
/// <param name="previewPath">Optional. The preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
/// <param name="installSource">Optional. The source the theme was installed from.</param>
/// <param name="isCurrent">Optional. Whether the theme is the currently active one.</param>
/// <param name="installedAtUtc">Optional. The UTC timestamp when the theme was installed.</param>
/// <param name="isDeleted">Optional. Whether the theme was deleted by the user.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ThemeResponse"/>.</returns>
public ThemeResponse Create(
Guid? id = null,
string? themeId = null,
string? name = null,
string? description = null,
string? author = null,
string? version = null,
string? previewPath = null,
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
DateTime? installedAtUtc = null,
bool? isDeleted = null,
bool includePreviewPath = false,
bool includeIsCurrent = false)
{
return new ThemeResponse(
id ?? Guid.NewGuid(),
themeId ?? _faker.Lorem.Slug(2),
name ?? _faker.Commerce.ProductName(),
description ?? _faker.Lorem.Sentence(),
author ?? _faker.Name.FullName(),
version ?? _faker.System.Semver(),
includePreviewPath ? (previewPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)) : null,
installSource ?? _faker.PickRandom<ThemeInstallSource>(),
includeIsCurrent ? (isCurrent ?? (_faker.Random.Bool() ? true : null)) : null,
installedAtUtc ?? _faker.Date.Recent().ToUniversalTime(),
isDeleted ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="ThemeResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeSettingsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeSettingsResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeSettingsResponse"/>.
/// </summary>
/// <param name="maxArchiveBytes">Optional. The maximum allowed size of a theme archive, in bytes.</param>
/// <param name="defaultThemeId">Optional. The identifier of the default theme.</param>
/// <returns>The created <see cref="ThemeSettingsResponse"/>.</returns>
public ThemeSettingsResponse Create(
long? maxArchiveBytes = null,
string? defaultThemeId = null)
{
return new ThemeSettingsResponse(
maxArchiveBytes ?? _faker.Random.Long(1_000_000, 100_000_000),
defaultThemeId ?? _faker.Lorem.Slug(2));
}
/// <summary>
/// Creates a list of <see cref="ThemeSettingsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeSettingsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeTemplateResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeTemplateResponseFixture
{
private readonly Faker _faker = new();
private readonly ThemeResponseFixture _themeResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="ThemeTemplateResponse"/>.
/// </summary>
/// <param name="theme">Optional. The theme the template belongs to.</param>
/// <param name="template">Optional. The sanitized content of the template.</param>
/// <returns>The created <see cref="ThemeTemplateResponse"/>.</returns>
public ThemeTemplateResponse Create(ThemeResponse? theme = null, string? template = null)
{
return new ThemeTemplateResponse(
theme ?? _themeResponseFixture.Create(),
template ?? _faker.Lorem.Paragraph());
}
/// <summary>
/// Creates a list of <see cref="ThemeTemplateResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeTemplateResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement;
/// <summary>
/// Fixture class for the <see cref="InitializationResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class InitializationResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="InitializationResponse"/>.
/// </summary>
/// <param name="isInitialized">Optional. Whether the application is initialized.</param>
/// <returns>The created <see cref="InitializationResponse"/>.</returns>
public InitializationResponse Create(
bool? isInitialized = null)
{
return new InitializationResponse(isInitialized ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="InitializationResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<InitializationResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement.Settings;
/// <summary>
/// Fixture class for the <see cref="PlaybackStateResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaybackStateResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PlaybackStateResponse"/>.
/// </summary>
/// <param name="volume">Optional. The last volume the player reported, as a value between 0 and 1.</param>
/// <param name="isMuted">Optional. The last mute state the player reported.</param>
/// <returns>The created <see cref="PlaybackStateResponse"/>.</returns>
public PlaybackStateResponse Create(
double? volume = null,
bool? isMuted = null)
{
return new PlaybackStateResponse(
volume ?? _faker.Random.Double(0, 1),
isMuted ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="PlaybackStateResponse"/> instances.
/// </summary>
/// <param name="count">Number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PlaybackStateResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,111 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement.Settings;
/// <summary>
/// Fixture class for the <see cref="UserSettingsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserSettingsResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UserSettingsResponse"/>.
/// </summary>
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user.</param>
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker.</param>
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached.</param>
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="vuMeterOrientation">Optional. The direction in which each channel of the VU meter of the audio player grows.</param>
/// <param name="vuMeterSegmentCount">Optional. The number of segments each channel of the VU meter is divided into.</param>
/// <param name="vuMeterSegmentGap">Optional. The gap, in pixels, between the segments and the channels of the VU meter.</param>
/// <param name="vuMeterMediumThreshold">Optional. The level above which a segment of the VU meter is drawn with its medium state.</param>
/// <param name="vuMeterHighThreshold">Optional. The level above which a segment of the VU meter is drawn with its high state.</param>
/// <param name="vuMeterShowPeak">Optional. Whether the VU meter holds the peak level of each channel after it falls.</param>
/// <param name="vuMeterPeakHoldDurationInMilliseconds">Optional. The time a peak of the VU meter is held before it starts falling.</param>
/// <param name="vuMeterReleasePerSecond">Optional. The number of level units the display of the VU meter falls per second when the input level drops.</param>
/// <param name="vuMeterPeakReleasePerSecond">Optional. The number of level units the peak of the VU meter falls per second after its hold time elapsed.</param>
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
public UserSettingsResponse Create(
Guid? userId = null,
bool? isPaginationEnabled = null,
int? itemsPerPage = null,
bool? shouldIgnoreThePrefixForAlphaPicker = null,
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null,
VuMeterOrientation? vuMeterOrientation = null,
int? vuMeterSegmentCount = null,
int? vuMeterSegmentGap = null,
double? vuMeterMediumThreshold = null,
double? vuMeterHighThreshold = null,
bool? vuMeterShowPeak = null,
int? vuMeterPeakHoldDurationInMilliseconds = null,
double? vuMeterReleasePerSecond = null,
double? vuMeterPeakReleasePerSecond = null)
{
// The high threshold is generated from the medium one, so a randomized response always describes a valid meter.
double mediumThreshold = vuMeterMediumThreshold ?? _faker.Random.Double(0, 1);
double highThreshold = vuMeterHighThreshold ?? _faker.Random.Double(mediumThreshold, 1);
return new UserSettingsResponse(
userId ?? Guid.NewGuid(),
isPaginationEnabled ?? _faker.Random.Bool(),
itemsPerPage ?? _faker.Random.Int(1, 100),
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
isThemeCachingEnabled ?? _faker.Random.Bool(),
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
shouldPreserveBookStyles ?? _faker.Random.Bool(),
shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
shouldAutoplay ?? _faker.Random.Bool(),
isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>(),
vuMeterOrientation ?? _faker.PickRandom<VuMeterOrientation>(),
vuMeterSegmentCount ?? _faker.Random.Int(1, 128),
vuMeterSegmentGap ?? _faker.Random.Int(0, 32),
mediumThreshold,
highThreshold,
vuMeterShowPeak ?? _faker.Random.Bool(),
vuMeterPeakHoldDurationInMilliseconds ?? _faker.Random.Int(0, 10000),
vuMeterReleasePerSecond ?? _faker.Random.Double(0, 100),
vuMeterPeakReleasePerSecond ?? _faker.Random.Double(0, 100));
}
/// <summary>
/// Creates a list of <see cref="UserSettingsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UserSettingsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement.Users;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement.Users;
/// <summary>
/// Fixture class for the <see cref="UserResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UserResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the user.</param>
/// <param name="username">Optional. The username of the user.</param>
/// <param name="createdOnUtc">Optional. The date and time when the user was created.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the user was updated.</param>
/// <returns>The created <see cref="UserResponse"/>.</returns>
public UserResponse Create(
Guid? id = null,
string? username = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null)
{
return new UserResponse(
id ?? Guid.NewGuid(),
username ?? _faker.Internet.UserName(),
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
updatedOnUtc
);
}
/// <summary>
/// Creates a list of <see cref="UserResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UserResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}