Centralizes and standardizes test fixtures.

This commit is contained in:
BinaryAlley committed 2026-08-15 02:58:17 -07:00
1 parent dfc513da4f
commit b648e2f054
294 files changed
+3807 -4437

No files matched your search

@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for the <see cref="FileSystemItemDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemItemDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FileSystemItemDto"/>.
/// </summary>
/// <returns>The created <see cref="FileSystemItemDto"/>.</returns>
public FileSystemItemDto Create()
{
return new FileSystemItemDto(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent()
);
}
/// <summary>
/// Creates a list of <see cref="FileSystemItemDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<FileSystemItemDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookRatingDto"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookRatingDtoFixture
{
private readonly Fixture _fixture;
private readonly Random _random = new();
/// <summary>
/// Initializes a new instance of the <see cref="BookRatingDtoFixture"/> class.
/// </summary>
public BookRatingDtoFixture()
{
_fixture = new Fixture();
}
/// <summary>
/// Creates a <see cref="BookRatingDto"/>.
/// </summary>
/// <param name="value">Optional. The rating value.</param>
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</param>
/// <param name="includeOptionalProperties">Whether the optional source and vote count should be included.</param>
/// <returns>The created <see cref="BookRatingDto"/>.</returns>
public BookRatingDto Create(
decimal? value = null,
decimal? maxValue = null,
BookRatingSource? source = null,
int? voteCount = null,
bool includeOptionalProperties = true)
{
return new BookRatingDto(
value ?? _random.Next(1, 5),
maxValue ?? 5,
includeOptionalProperties ? (source ?? _fixture.Create<BookRatingSource>()) : null,
includeOptionalProperties ? (voteCount ?? _random.Next(1, 1000)) : null
);
}
/// <summary>
/// Creates a list of <see cref="BookRatingDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookRatingDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,77 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="IsbnDto"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public class IsbnDtoFixture
{
private readonly Random _random = new();
/// <summary>
/// Creates an <see cref="IsbnDto"/> with a random or explicitly requested format.
/// </summary>
/// <param name="value">Optional. The ISBN value. If not provided, a valid ISBN is generated.</param>
/// <param name="format">Optional. The ISBN format. If not provided, the format is left unspecified.</param>
/// <returns>The created <see cref="IsbnDto"/>.</returns>
public IsbnDto Create(string? value = null, IsbnFormat? format = null)
{
string resolvedValue = value ?? (format == IsbnFormat.Isbn10 ? GenerateValidIsbn10() : GenerateValidIsbn13());
return new IsbnDto(
resolvedValue,
format
);
}
/// <summary>
/// Creates a list of <see cref="IsbnDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<IsbnDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
private string GenerateValidIsbn10()
{
int[] digits = new int[9];
for (int i = 0; i < 9; i++)
digits[i] = _random.Next(0, 10);
int sum = 0;
for (int i = 0; i < 9; i++)
sum += (10 - i) * digits[i];
int checkDigit = (11 - sum % 11) % 11;
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
}
private string GenerateValidIsbn13()
{
string prefix = _random.Next(2) == 0 ? "978" : "979";
string group = _random.Next(0, 99999).ToString().PadLeft(5, '0');
string publisher = _random.Next(0, 999999).ToString().PadLeft(6, '0');
string title = _random.Next(0, 99).ToString().PadLeft(2, '0');
string isbn = $"{prefix}{group[..1]}{publisher}{title}";
int sum = 0;
for (int i = 0; i < 12; i++)
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
int checkDigit = (10 - sum % 10) % 10;
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="ChangePasswordRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ChangePasswordRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="ChangePasswordRequestFixture"/> class.
/// </summary>
public ChangePasswordRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="ChangePasswordRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for the password change.</param>
/// <param name="currentPassword">Optional. The current password.</param>
/// <param name="newPassword">Optional. The new password.</param>
/// <param name="newPasswordConfirm">Optional. The new password confirmation.</param>
/// <returns>The created <see cref="ChangePasswordRequest"/>.</returns>
public ChangePasswordRequest Create(
string? username = null,
string? currentPassword = null,
string? newPassword = null,
string? newPasswordConfirm = null)
{
string generatedNewPassword = newPassword ?? _faker.Internet.Password();
return new ChangePasswordRequest(
username ?? _faker.Internet.UserName(),
currentPassword ?? _faker.Internet.Password(),
generatedNewPassword,
newPasswordConfirm ?? generatedNewPassword
);
}
/// <summary>
/// Creates a list of <see cref="ChangePasswordRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ChangePasswordRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="LoginRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LoginRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="LoginRequestFixture"/> class.
/// </summary>
public LoginRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="LoginRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for login.</param>
/// <param name="password">Optional. The password for login.</param>
/// <param name="totpCode">Optional. The TOTP code for two-factor authentication.</param>
/// <returns>The created <see cref="LoginRequest"/>.</returns>
public LoginRequest Create(
string? username = null,
string? password = null,
string? totpCode = null)
{
return new LoginRequest(
username ?? _faker.Internet.UserName(),
password ?? _faker.Internet.Password(),
totpCode ?? _faker.Random.Number(100000, 999999).ToString()
);
}
/// <summary>
/// Creates a list of <see cref="LoginRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LoginRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="RecoverPasswordRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RecoverPasswordRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="RecoverPasswordRequestFixture"/> class.
/// </summary>
public RecoverPasswordRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="RecoverPasswordRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for password recovery.</param>
/// <param name="totpCode">Optional. The TOTP code for verification.</param>
/// <returns>The created <see cref="RecoverPasswordRequest"/>.</returns>
public RecoverPasswordRequest Create(
string? username = null,
string? totpCode = null)
{
return new RecoverPasswordRequest(
username ?? _faker.Internet.UserName(),
totpCode ?? _faker.Random.Number(100000, 999999).ToString()
);
}
/// <summary>
/// Creates a list of <see cref="RecoverPasswordRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RecoverPasswordRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="RegistrationRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RegistrationRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="RegistrationRequestFixture"/> class.
/// </summary>
public RegistrationRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="RegistrationRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for registration.</param>
/// <param name="password">Optional. The password for registration.</param>
/// <param name="passwordConfirm">Optional. The password confirmation.</param>
/// <param name="use2fa">Optional. Whether to use two-factor authentication.</param>
/// <returns>The created <see cref="RegistrationRequest"/>.</returns>
public RegistrationRequest Create(
string? username = null,
string? password = null,
string? passwordConfirm = null,
bool? use2fa = null)
{
string generatedPassword = password ?? _faker.Internet.Password();
return new RegistrationRequest(
username ?? _faker.Internet.UserName(),
generatedPassword,
passwordConfirm ?? generatedPassword,
use2fa ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="RegistrationRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RegistrationRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
/// <summary>
/// Fixture class for the <see cref="GetAuthorizationRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAuthorizationRequestFixture
{
/// <summary>
/// Creates a <see cref="GetAuthorizationRequest"/> with default or specified values.
/// </summary>
/// <param name="userId">Optional. The user Id to use.</param>
/// <returns>The created <see cref="GetAuthorizationRequest"/>.</returns>
public GetAuthorizationRequest Create(Guid? userId = null)
{
return new GetAuthorizationRequest(
UserId: userId ?? Guid.NewGuid()
);
}
/// <summary>
/// Creates a list of <see cref="GetAuthorizationRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetAuthorizationRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Directories;
/// <summary>
/// Fixture class for the <see cref="GetDirectoriesRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDirectoriesRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetDirectoriesRequest"/> with default or random values.
/// </summary>
/// <param name="path">Optional. The file system path for which to get the directories.</param>
/// <param name="includeHiddenElements">Optional. Whether to include hidden file system elements.</param>
/// <returns>The created <see cref="GetDirectoriesRequest"/>.</returns>
public GetDirectoriesRequest Create(string? path = null, bool? includeHiddenElements = null)
{
return new GetDirectoriesRequest(
Path: path ?? _faker.System.FilePath(),
IncludeHiddenElements: includeHiddenElements ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="GetDirectoriesRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetDirectoriesRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
/// <summary>
/// Fixture class for the <see cref="GetFilesRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetFilesRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetFilesRequest"/> with default or random values.
/// </summary>
/// <param name="path">Optional. The file system path for which to get the files.</param>
/// <param name="includeHiddenElements">Optional. Whether to include hidden file system elements.</param>
/// <returns>The created <see cref="GetFilesRequest"/>.</returns>
public GetFilesRequest Create(string? path = null, bool? includeHiddenElements = null)
{
return new GetFilesRequest(
Path: path ?? _faker.System.FilePath(),
IncludeHiddenElements: includeHiddenElements ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="GetFilesRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetFilesRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
/// <summary>
/// Fixture class for the <see cref="GetTreeFilesRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTreeFilesRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetTreeFilesRequest"/> with default or random values.
/// </summary>
/// <param name="path">Optional. The file system path for which to get the tree files.</param>
/// <param name="includeHiddenElements">Optional. Whether to include hidden file system elements.</param>
/// <returns>The created <see cref="GetTreeFilesRequest"/>.</returns>
public GetTreeFilesRequest Create(string? path = null, bool? includeHiddenElements = null)
{
return new GetTreeFilesRequest(
Path: path ?? _faker.System.FilePath(),
IncludeHiddenElements: includeHiddenElements ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="GetTreeFilesRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetTreeFilesRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="CheckPathExistsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class CheckPathExistsRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="CheckPathExistsRequest"/> with default or random values.
/// </summary>
/// <param name="path">Optional. The path to check.</param>
/// <param name="includeHiddenElements">Optional. Whether to include hidden elements.</param>
/// <returns>The created <see cref="CheckPathExistsRequest"/>.</returns>
public CheckPathExistsRequest Create(string? path = null, bool? includeHiddenElements = null)
{
return new CheckPathExistsRequest(
Path: path ?? _faker.System.FilePath(),
IncludeHiddenElements: includeHiddenElements ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="CheckPathExistsRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CheckPathExistsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="CombinePathRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class CombinePathRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="CombinePathRequest"/> with default or random values.
/// </summary>
/// <param name="originalPath">Optional. The original path.</param>
/// <param name="newPath">Optional. The new path to combine.</param>
/// <returns>The created <see cref="CombinePathRequest"/>.</returns>
public CombinePathRequest Create(string? originalPath = null, string? newPath = null)
{
return new CombinePathRequest(
OriginalPath: originalPath ?? _faker.System.DirectoryPath(),
NewPath: newPath ?? _faker.System.FileName()
);
}
/// <summary>
/// Creates a list of <see cref="CombinePathRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CombinePathRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="GetPathParentRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPathParentRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetPathParentRequest"/> with a default or random value.
/// </summary>
/// <param name="path">Optional. The path to get the parent of.</param>
/// <returns>The created <see cref="GetPathParentRequest"/>.</returns>
public GetPathParentRequest Create(string? path = null)
{
return new GetPathParentRequest(
Path: path ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="GetPathParentRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetPathParentRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="GetPathRootRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPathRootRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetPathRootRequest"/> with a default or random value.
/// </summary>
/// <param name="path">Optional. The path to get the root of.</param>
/// <returns>The created <see cref="GetPathRootRequest"/>.</returns>
public GetPathRootRequest Create(string? path = null)
{
return new GetPathRootRequest(
Path: path ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="GetPathRootRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetPathRootRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="SplitPathRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class SplitPathRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="SplitPathRequest"/> with a default or random value.
/// </summary>
/// <param name="path">Optional. The path to split.</param>
/// <returns>The created <see cref="SplitPathRequest"/>.</returns>
public SplitPathRequest Create(string? path = null)
{
return new SplitPathRequest(
Path: path ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="SplitPathRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<SplitPathRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
/// <summary>
/// Fixture class for the <see cref="ValidatePathRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ValidatePathRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="ValidatePathRequest"/> with a default or random value.
/// </summary>
/// <param name="path">Optional. The path to validate.</param>
/// <returns>The created <see cref="ValidatePathRequest"/>.</returns>
public ValidatePathRequest Create(string? path = null)
{
return new ValidatePathRequest(
Path: path ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="ValidatePathRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ValidatePathRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Thumbnails;
/// <summary>
/// Fixture class for the <see cref="GetThumbnailRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetThumbnailRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetThumbnailRequest"/> with default or random values.
/// </summary>
/// <param name="path">Optional. The path of the file to get the thumbnail for.</param>
/// <param name="quality">Optional. The quality of the thumbnail.</param>
/// <returns>The created <see cref="GetThumbnailRequest"/>.</returns>
public GetThumbnailRequest Create(string? path = null, int? quality = null)
{
return new GetThumbnailRequest(
Path: path ?? _faker.System.FilePath(),
Quality: quality ?? _faker.Random.Int(1, 100)
);
}
/// <summary>
/// Creates a list of <see cref="GetThumbnailRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetThumbnailRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,273 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Common.Setup;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="AddBookRequest"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddBookRequestFixture
{
private readonly Fixture _fixture;
private readonly Random _random = new();
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="AddBookRequestFixture"/> class.
/// </summary>
public AddBookRequestFixture()
{
_fixture = new Fixture();
_fixture.Customizations.Add(new DateOnlySpecimenBuilder());
_fixture.Customizations.Add(new NullableDateOnlySpecimenBuilder());
_faker = new Faker();
}
/// <summary>
/// Creates a random valid request to add a book.
/// </summary>
/// <returns>The created request to add a book.</returns>
public AddBookRequest Create()
{
int releaseYear = _random.Next(2000, 2010);
int reReleaseYear = _random.Next(2010, 2020);
ReleaseInfoDto releaseInfo = new Faker<ReleaseInfoDto>()
.CustomInstantiator(f => new ReleaseInfoDto(
default,
default,
default,
default,
default,
default
))
.RuleFor(x => x.OriginalReleaseDate, _faker.DateOnlyBetween(new DateOnly(releaseYear, 1, 1), new DateOnly(releaseYear, 12, 31)))
.RuleFor(x => x.OriginalReleaseYear, releaseYear)
.RuleFor(x => x.ReReleaseDate, _faker.DateOnlyBetween(new DateOnly(reReleaseYear, 1, 1), new DateOnly(reReleaseYear, 12, 31)))
.RuleFor(x => x.ReReleaseYear, reReleaseYear)
.RuleFor(x => x.ReleaseCountry, f => f.Random.String2(2))
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
.Generate();
Faker<GenreDto> genre = new Faker<GenreDto>()
.CustomInstantiator(f => new GenreDto(
default!
))
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<TagDto> tag = new Faker<TagDto>()
.CustomInstantiator(f => new TagDto(
default!
))
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<MediaContributorRoleDto> mediaContributorRole = new Faker<MediaContributorRoleDto>()
.CustomInstantiator(f => new MediaContributorRoleDto(
default!,
default!
))
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(e => e.Category, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<MediaContributorNameDto> mediaContributorName = new Faker<MediaContributorNameDto>()
.CustomInstantiator(f => new MediaContributorNameDto(
default!,
default!
))
.RuleFor(e => e.DisplayName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(e => e.LegalName, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<MediaContributorDto> mediaContributor = new Faker<MediaContributorDto>()
.CustomInstantiator(f => new MediaContributorDto(
default!,
default!
))
.RuleFor(e => e.Name, mediaContributorName)
.RuleFor(e => e.Role, mediaContributorRole);
Faker<BookRatingDto> rating = new Faker<BookRatingDto>()
.CustomInstantiator(f => new BookRatingDto(
default,
default,
default,
default
))
.RuleFor(e => e.Value, _random.Next(1, 5))
.RuleFor(e => e.MaxValue, 5)
.RuleFor(e => e.Source, _fixture.Create<BookRatingSource>())
.RuleFor(e => e.VoteCount, _random.Next(1, 1000));
Faker<LanguageInfoDto> language = new Faker<LanguageInfoDto>()
.CustomInstantiator(f => new LanguageInfoDto(
default!,
default!,
default
))
.RuleFor(e => e.LanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<LanguageInfoDto> originalLanguage = new Faker<LanguageInfoDto>()
.CustomInstantiator(f => new LanguageInfoDto(
default!,
default!,
default
))
.RuleFor(e => e.LanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
Faker<WrittenContentMetadataDto> metadata = new Faker<WrittenContentMetadataDto>()
.CustomInstantiator(f => new WrittenContentMetadataDto(
default!,
default,
default,
default!,
default!,
default!,
default,
default,
default,
default
))
.RuleFor(x => x.Title, f => f.Random.String2(f.Random.Number(1, 255)))
.RuleFor(x => x.OriginalTitle, f => f.Random.String2(f.Random.Number(1, 255)))
.RuleFor(x => x.Description, f => f.Random.String2(f.Random.Number(1, 2000)))
.RuleFor(x => x.ReleaseInfo, releaseInfo)
.RuleFor(p => p.Genres, f => genre.Generate(f.Random.Number(1, 5)))
.RuleFor(x => x.Tags, f => tag.Generate(f.Random.Number(1, 5)))
.RuleFor(x => x.Language, language)
.RuleFor(x => x.OriginalLanguage, originalLanguage)
.RuleFor(x => x.Publisher, f => f.Random.String2(f.Random.Number(1, 100)))
.RuleFor(x => x.PageCount, _random.Next(100, 300));
Faker<IsbnDto> isbn = new Faker<IsbnDto>()
.CustomInstantiator(f => new IsbnDto(
default!,
default
))
.RuleFor(i => i.Value, f =>
{
bool isIsbn13 = f.Random.Bool();
if (isIsbn13)
{
string prefix = f.Random.Bool() ? "978" : "979";
string group = f.Random.Number(0, 99999).ToString().PadLeft(5, '0');
string publisher = f.Random.Number(0, 999999).ToString().PadLeft(6, '0');
string title = f.Random.Number(0, 99).ToString().PadLeft(2, '0');
string isbn = $"{prefix}{group[..1]}{publisher}{title}";
int sum = 0;
for (int i = 0; i < 12; i++)
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
int checkDigit = (10 - sum % 10) % 10;
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
}
else
{
int[] digits = new int[9];
for (int i = 0; i < 9; i++)
digits[i] = f.Random.Number(0, 9);
int sum = 0;
for (int i = 0; i < 9; i++)
sum += (10 - i) * digits[i];
int checkDigit = (11 - sum % 11) % 11;
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
}
})
.RuleFor(i => i.Format, (f, i) => i.Value!.Length > 13 ? IsbnFormat.Isbn13 : IsbnFormat.Isbn10);
return new Faker<AddBookRequest>()
.CustomInstantiator(f => new AddBookRequest(
default,
default!,
default!,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default!,
default!,
default!,
default!,
default!
))
.RuleFor(x => x.LibraryId, _fixture.Create<Guid>())
.RuleFor(x => x.Path, f => f.System.FilePath())
.RuleFor(x => x.Metadata, metadata)
.RuleFor(x => x.Format, _fixture.Create<BookFormat>())
.RuleFor(x => x.Edition, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.VolumeNumber, _random.Next(1, 3))
.RuleFor(x => x.ASIN, f => f.Random.String2(10))
.RuleFor(x => x.GoodreadsId, _random.Next(100000, 500000).ToString())
.RuleFor(x => x.LCCN, f =>
{
string letters = new([.. Enumerable.Range(0, f.Random.Number(0, 3)).Select(_ => f.Random.Char('a', 'z'))]);
string digits = f.Random.String2(f.Random.Number(8, 10), "0123456789");
return letters + digits;
})
.RuleFor(x => x.OCLCNumber, f =>
{
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
string prefix = f.Random.ArrayElement(prefixes);
string number;
switch (prefix)
{
case "ocm":
number = f.Random.String2(8, "0123456789");
break;
case "ocn":
number = f.Random.String2(f.Random.Number(9, 11), "0123456789");
break;
case "on":
number = f.Random.String2(10, "0123456789");
break;
case "(OCoLC)":
number = f.Random.String2(f.Random.Number(8, 10), "0123456789");
break;
default:
number = f.Random.String2(f.Random.Number(8, 10), "0123456789");
return number;
}
return prefix + number;
})
.RuleFor(x => x.OpenLibraryId, f =>
{
int firstDigit = f.Random.Number(1, 9);
string remainingDigits = f.Random.String2(f.Random.Number(0, 6), "0123456789");
char suffix = f.Random.ArrayElement(['A', 'M', 'W']);
return $"OL{firstDigit}{remainingDigits}{suffix}";
})
.RuleFor(x => x.LibraryThingId, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.GoogleBooksId, f =>
{
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[f.Random.Number(VALID_CHARS.Length - 1)])]);
})
.RuleFor(x => x.BarnesAndNobleId, f => f.Random.String2(10, "0123456789"))
.RuleFor(x => x.AppleBooksId, f => $"id{f.Random.Number(1, 999999)}")
.RuleFor(p => p.ISBNs, f => isbn.Generate(f.Random.Number(1, 5)))
.RuleFor(p => p.Ratings, f => rating.Generate(f.Random.Number(1, 5)))
.RuleFor(x => x.Contributors, f => mediaContributor.Generate(f.Random.Number(1, 5)));
}
}
@@ -0,0 +1,58 @@
#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>
/// <returns>A <see cref="FileSystemTreeNodeResponse"/> with a nested structure.</returns>
public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3)
{
FileSystemTreeNodeResponse response = new()
{
Path = _faker.System.FilePath(),
Name = _faker.System.FileName(),
ItemType = FileSystemItemType.Directory,
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,47 @@
#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 _fileSystemItemModelFixture = new();
/// <summary>
/// Creates a random valid <see cref="DirectoryResponse"/>.
/// </summary>
/// <param name="itemCount">Optional. The number of children elements to create.</param>
/// <returns>The created <see cref="DirectoryResponse"/>.</returns>
public DirectoryResponse Create(int itemCount = 3)
{
return new DirectoryResponse(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent(),
_fileSystemItemModelFixture.CreateMany(itemCount)
);
}
/// <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,43 @@
#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>
/// <returns>The created <see cref="FileResponse"/>.</returns>
public FileResponse Create()
{
return new FileResponse(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent(),
_faker.Random.Long()
);
}
/// <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,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,42 @@
#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
{
/// <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)
{
Faker faker = new();
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())];
}
}