Hardens test assertions and adds missing test coverage.

This commit is contained in:
BinaryAlley committed 2026-08-18 08:28:16 -07:00
1 parent 6b86fd5805
commit 1189bbaf36
489 files changed
+39982 -512

No files matched your search

@@ -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,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,79 @@
#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="downloadMetadataFromWeb">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="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? downloadMetadataFromWeb = null,
bool? shouldSaveMetadataInMediaDirectories = null,
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = 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(),
downloadMetadataFromWeb ?? _faker.Random.Bool(),
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
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,51 @@
#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>
/// <returns>The created <see cref="BookLiteResponse"/>.</returns>
public BookLiteResponse Create(
Guid? id = null,
string? title = null,
int? releaseYear = null,
string? coverPath = null)
{
return new BookLiteResponse(
id ?? Guid.NewGuid(),
title ?? _faker.Commerce.ProductName(),
releaseYear ?? _faker.Random.Int(1900, 2024),
coverPath ?? _faker.System.FilePath()
);
}
/// <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,102 @@
#region ========================================================================= USING =====================================================================================
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.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
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.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="BookResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookResponseFixture
{
private readonly Faker _faker = 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>
/// <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)
{
DateTime resolvedCreatedOnUtc = createdOnUtc ?? _faker.Date.Past().ToUniversalTime();
return new BookResponse(
id ?? Guid.NewGuid(),
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
metadata ?? CreateMetadata(),
format ?? _faker.PickRandom<BookFormat>(),
_faker.Lorem.Word(),
_faker.Random.Int(1, 10),
new BookSeriesDto(_faker.Lorem.Word()),
_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),
[new IsbnDto(_faker.Random.Replace("###-#-##-#####-#"), IsbnFormat.Isbn13)],
[new MediaContributorDto(
new MediaContributorNameDto(_faker.Name.FullName(), _faker.Name.FullName()),
new MediaContributorRoleDto(_faker.Commerce.ProductAdjective(), _faker.Commerce.Department()))],
[new BookRatingDto(_faker.Random.Decimal(1m, 5m), 5m, BookRatingSource.Goodreads, _faker.Random.Int(1, 1000))],
metadataStatus ?? _faker.PickRandom<MetadataStatus>(),
_faker.Date.Recent().ToUniversalTime(),
_faker.Company.CompanyName(),
resolvedCreatedOnUtc,
_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : 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())];
}
private WrittenContentMetadataDto CreateMetadata()
{
return new WrittenContentMetadataDto(
_faker.Lorem.Sentence(3),
_faker.Lorem.Sentence(3),
_faker.Lorem.Paragraph(),
new ReleaseInfoDto(_faker.Date.PastDateOnly(), _faker.Random.Int(1900, 2024), null, null, _faker.Address.CountryCode(), null),
[new GenreDto(_faker.Lorem.Word())],
[new TagDto(_faker.Lorem.Word())],
new LanguageInfoDto("en", "English", "English"),
null,
_faker.Company.CompanyName(),
_faker.Random.Int(100, 1000)
);
}
}
@@ -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,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())];
}
}