Adds test fixtures and endpoint test coverage

This commit is contained in:
BinaryAlley committed 2026-08-24 14:19:45 -07:00
1 parent c82fadc7a2
commit 7aeed04255
198 files changed
+11649

No files matched your search

@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Authorization;
using Lumina.Presentation.Web.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
/// <summary>
/// Fixture class for generating <see cref="PermissionDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PermissionDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PermissionDto"/> instance with randomized test data.
/// </summary>
/// <param name="id">Optional unique identifier of the permission.</param>
/// <param name="permission">Optional name of the permission.</param>
/// <returns>A configured <see cref="PermissionDto"/> instance.</returns>
public PermissionDto Create(
Guid? id = null,
AuthorizationPermission? permission = null)
{
return new PermissionDto(
Id: id ?? Guid.NewGuid(),
PermissionName: permission ?? _faker.Random.Enum<AuthorizationPermission>()
);
}
/// <summary>
/// Creates multiple <see cref="PermissionDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PermissionDto"/> instances.</returns>
public List<PermissionDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Authorization;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
/// <summary>
/// Fixture class for the <see cref="RolePermissionsDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RolePermissionsDtoFixture
{
private readonly RoleDtoFixture _roleDtoFixture = new();
private readonly PermissionDtoFixture _permissionDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="RolePermissionsDto"/>.
/// </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="RolePermissionsDto"/>.</returns>
public RolePermissionsDto Create(
RoleDto? role = null,
PermissionDto[]? permissions = null)
{
return new RolePermissionsDto(
role ?? _roleDtoFixture.Create(),
permissions ?? [.. _permissionDtoFixture.CreateMany()]);
}
/// <summary>
/// Creates a list of <see cref="RolePermissionsDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RolePermissionsDto"/> instances.</returns>
public List<RolePermissionsDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="ProblemDetailsDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ProblemDetailsDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ProblemDetailsDto"/>.
/// </summary>
/// <param name="type">Optional. The URI reference that identifies the problem type.</param>
/// <param name="title">Optional. A short, human-readable summary of the problem type.</param>
/// <param name="status">Optional. The HTTP status code generated by the server.</param>
/// <param name="detail">Optional. A detailed explanation specific to this occurrence of the problem.</param>
/// <param name="instance">Optional. A URI reference that identifies the specific occurrence of the problem.</param>
/// <returns>The created <see cref="ProblemDetailsDto"/>.</returns>
public ProblemDetailsDto Create(
string? type = null,
string? title = null,
int? status = null,
string? detail = null,
string? instance = null)
{
return new ProblemDetailsDto
{
Type = type ?? "https://tools.ietf.org/html/rfc4918#section-11.2",
Title = title ?? _faker.Lorem.Word(),
Status = status ?? _faker.Random.Int(400, 599),
Detail = detail ?? _faker.Lorem.Sentence(),
Instance = instance
};
}
/// <summary>
/// Creates a list of <see cref="ProblemDetailsDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ProblemDetailsDto"/> instances.</returns>
public List<ProblemDetailsDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Configuration;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
/// <summary>
/// Fixture class for the <see cref="EncryptionSettingsDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class EncryptionSettingsDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="EncryptionSettingsDto"/>.
/// </summary>
/// <param name="secretKey">Optional. The secret key used to encrypt data.</param>
/// <returns>The created <see cref="EncryptionSettingsDto"/>.</returns>
public EncryptionSettingsDto Create(
string? secretKey = null)
{
return new EncryptionSettingsDto
{
SecretKey = secretKey ?? _faker.Random.String2(44, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
};
}
/// <summary>
/// Creates a list of <see cref="EncryptionSettingsDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="EncryptionSettingsDto"/> instances.</returns>
public List<EncryptionSettingsDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Configuration;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
/// <summary>
/// Fixture class for the <see cref="ServerConfigurationDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ServerConfigurationDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ServerConfigurationDto"/>.
/// </summary>
/// <param name="apiVersion">Optional. The remote API server path version.</param>
/// <param name="baseAddress">Optional. The remote API server path.</param>
/// <param name="port">Optional. The remote API server port.</param>
/// <returns>The created <see cref="ServerConfigurationDto"/>.</returns>
public ServerConfigurationDto Create(
char? apiVersion = null,
string? baseAddress = null,
ushort? port = null)
{
return new ServerConfigurationDto
{
ApiVersion = apiVersion ?? _faker.Random.Char('1', '9'),
BaseAddress = baseAddress ?? "http://localhost",
Port = port ?? _faker.Random.UShort()
};
}
/// <summary>
/// Creates a list of <see cref="ServerConfigurationDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ServerConfigurationDto"/> instances.</returns>
public List<ServerConfigurationDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for the <see cref="BlobDataDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class BlobDataDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BlobDataDto"/>.
/// </summary>
/// <param name="data">Optional. The binary data as a byte array.</param>
/// <param name="contentType">Optional. The content type (MIME type) of the blob data.</param>
/// <returns>The created <see cref="BlobDataDto"/>.</returns>
public BlobDataDto Create(
byte[]? data = null,
string? contentType = null)
{
return new BlobDataDto
{
Data = data ?? _faker.Random.Bytes(32),
ContentType = contentType ?? _faker.System.MimeType()
};
}
/// <summary>
/// Creates a list of <see cref="BlobDataDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="BlobDataDto"/> instances.</returns>
public List<BlobDataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for the <see cref="DirectoryDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DirectoryDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="DirectoryDto"/>.
/// </summary>
/// <param name="path">Optional. The full path to the directory.</param>
/// <param name="name">Optional. The name of the directory.</param>
/// <param name="items">Optional. The children items of the directory.</param>
/// <param name="includeItems">Whether the directory should include children items, or an empty collection.</param>
/// <returns>The created <see cref="DirectoryDto"/>.</returns>
public DirectoryDto Create(
string? path = null,
string? name = null,
List<FileSystemItemDto>? items = null,
bool includeItems = false)
{
string generatedPath = _faker.System.DirectoryPath();
return new DirectoryDto
{
Path = path ?? generatedPath,
Name = name ?? Path.GetFileName(generatedPath),
DateCreated = _faker.Date.Past(),
DateModified = _faker.Date.Recent(),
Items = includeItems ? (items ?? []) : []
};
}
/// <summary>
/// Creates a list of <see cref="DirectoryDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DirectoryDto"/> instances.</returns>
public List<DirectoryDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="FileDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="FileDto"/> instance with randomized test data.
/// </summary>
/// <param name="path">Optional. The full path to the file.</param>
/// <param name="name">Optional. The name of the file.</param>
/// <param name="size">Optional. The size of the file, in bytes.</param>
/// <returns>A configured <see cref="FileDto"/> instance.</returns>
public FileDto Create(
string? path = null,
string? name = null,
long? size = null)
{
string generatedPath = _faker.System.FilePath();
return new FileDto
{
Path = path ?? generatedPath,
Name = name ?? Path.GetFileName(generatedPath),
DateCreated = _faker.Date.Past(),
DateModified = _faker.Date.Recent(),
Size = size ?? _faker.Random.Long(0, 10_000_000)
};
}
/// <summary>
/// Creates multiple <see cref="FileDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FileDto"/> instances.</returns>
public List<FileDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="FileSystemTreeNodeDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemTreeNodeDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="FileSystemTreeNodeDto"/> instance with randomized test data.
/// </summary>
/// <param name="path">Optional. The full path of the file or directory.</param>
/// <param name="name">Optional. The name of the file or directory.</param>
/// <param name="itemType">Optional. The type of the item, indicating whether it is a file, directory, or drive.</param>
/// <returns>A configured <see cref="FileSystemTreeNodeDto"/> instance.</returns>
public FileSystemTreeNodeDto Create(
string? path = null,
string? name = null,
FileSystemItemType? itemType = null)
{
string generatedPath = _faker.System.FilePath();
return new FileSystemTreeNodeDto
{
Path = path ?? generatedPath,
Name = name ?? Path.GetFileName(generatedPath),
ItemType = itemType ?? _faker.PickRandom<FileSystemItemType>(),
IsExpanded = _faker.Random.Bool(),
ChildrenLoaded = _faker.Random.Bool(),
Children = []
};
}
/// <summary>
/// Creates multiple <see cref="FileSystemTreeNodeDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FileSystemTreeNodeDto"/> instances.</returns>
public List<FileSystemTreeNodeDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="FileSystemTypeDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemTypeDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="FileSystemTypeDto"/> instance with randomized test data.
/// </summary>
/// <param name="platformType">Optional file system platform type.</param>
/// <returns>A configured <see cref="FileSystemTypeDto"/> instance.</returns>
public FileSystemTypeDto Create(
PlatformType? platformType = null)
{
return new FileSystemTypeDto
{
PlatformType = platformType ?? _faker.PickRandom<PlatformType>()
};
}
/// <summary>
/// Creates multiple <see cref="FileSystemTypeDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FileSystemTypeDto"/> instances.</returns>
public List<FileSystemTypeDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="PathExistsDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathExistsDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PathExistsDto"/> instance with randomized test data.
/// </summary>
/// <param name="exists">Optional value indicating whether a file system path exists or not.</param>
/// <returns>A configured <see cref="PathExistsDto"/> instance.</returns>
public PathExistsDto Create(
bool? exists = null)
{
return new PathExistsDto(
Exists: exists ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates multiple <see cref="PathExistsDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PathExistsDto"/> instances.</returns>
public List<PathExistsDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="PathSegmentDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathSegmentDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PathSegmentDto"/> instance with randomized test data.
/// </summary>
/// <param name="path">Optional. The returned path.</param>
/// <returns>A configured <see cref="PathSegmentDto"/> instance.</returns>
public PathSegmentDto Create(
string? path = null)
{
return new PathSegmentDto
{
Path = path ?? _faker.System.FilePath()
};
}
/// <summary>
/// Creates multiple <see cref="PathSegmentDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PathSegmentDto"/> instances.</returns>
public List<PathSegmentDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="PathSeparatorDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathSeparatorDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PathSeparatorDto"/> instance with randomized test data.
/// </summary>
/// <param name="separator">Optional file system path separator.</param>
/// <returns>A configured <see cref="PathSeparatorDto"/> instance.</returns>
public PathSeparatorDto Create(
string? separator = null)
{
return new PathSeparatorDto(
Separator: separator ?? (_faker.Random.Bool() ? "\\" : "/")
);
}
/// <summary>
/// Creates multiple <see cref="PathSeparatorDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PathSeparatorDto"/> instances.</returns>
public List<PathSeparatorDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for generating <see cref="PathValidDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathValidDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PathValidDto"/> instance with randomized test data.
/// </summary>
/// <param name="isValid">Optional value indicating whether a file system path is valid or not.</param>
/// <returns>A configured <see cref="PathValidDto"/> instance.</returns>
public PathValidDto Create(
bool? isValid = null)
{
return new PathValidDto(
IsValid: isValid ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates multiple <see cref="PathValidDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PathValidDto"/> instances.</returns>
public List<PathValidDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
/// <summary>
/// Fixture class for the <see cref="BookLiteDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookLiteDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BookLiteDto"/>.
/// </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="BookLiteDto"/>.</returns>
public BookLiteDto Create(
Guid? id = null,
string? title = null,
int? releaseYear = null,
string? coverPath = null,
bool includeReleaseYear = false,
bool includeCoverPath = false)
{
return new BookLiteDto
{
Id = id ?? _faker.Random.Guid(),
Title = title ?? _faker.Lorem.Sentence(3),
ReleaseYear = includeReleaseYear ? (releaseYear ?? _faker.Random.Int(1900, 2024)) : null,
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
};
}
/// <summary>
/// Creates a list of <see cref="BookLiteDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="BookLiteDto"/> instances.</returns>
public List<BookLiteDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
/// <summary>
/// Fixture class for generating <see cref="LibraryScanJobProgressDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanJobProgressDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="LibraryScanJobProgressDto"/> instance with randomized test data.
/// </summary>
/// <param name="completedItems">Optional number of completed items of the media library scan job.</param>
/// <param name="totalItems">Optional total number of items of the media library scan job.</param>
/// <param name="currentOperation">Optional current operation being performed by the media library scan job.</param>
/// <param name="progressPercentage">Optional completion ratio of the media library scan job, as a percentage.</param>
/// <returns>A configured <see cref="LibraryScanJobProgressDto"/> instance.</returns>
public LibraryScanJobProgressDto Create(
int? completedItems = null,
int? totalItems = null,
string? currentOperation = null,
decimal? progressPercentage = null)
{
int completed = completedItems ?? _faker.Random.Int(0, 100);
int total = totalItems ?? _faker.Random.Int(completed, 100);
return new LibraryScanJobProgressDto
{
CompletedItems = completed,
TotalItems = total,
CurrentOperation = currentOperation ?? _faker.Hacker.Verb(),
ProgressPercentage = progressPercentage ?? (total > 0 ? (decimal)completed / total * 100 : 0)
};
}
/// <summary>
/// Creates multiple <see cref="LibraryScanJobProgressDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryScanJobProgressDto"/> instances.</returns>
public List<LibraryScanJobProgressDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,66 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
/// <summary>
/// Fixture class for generating <see cref="LibraryScanProgressDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanProgressDtoFixture
{
private readonly Faker _faker = new();
private readonly LibraryScanJobProgressDtoFixture _libraryScanJobProgressDtoFixture = new();
/// <summary>
/// Creates a new <see cref="LibraryScanProgressDto"/> instance with randomized test data.
/// </summary>
/// <param name="scanId">Optional unique identifier of the media library scan.</param>
/// <param name="userId">Optional unique identifier of the user initiating the media library scan.</param>
/// <param name="libraryId">Optional unique identifier of the media library that is scanned.</param>
/// <param name="completedJobs">Optional number of completed jobs of the media library scan job.</param>
/// <param name="totalJobs">Optional total number of jobs of the media library scan job.</param>
/// <param name="status">Optional status of the media library scan.</param>
/// <param name="includeCurrentJobProgress">Whether the current job progress should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="LibraryScanProgressDto"/> instance.</returns>
public LibraryScanProgressDto Create(
Guid? scanId = null,
Guid? userId = null,
Guid? libraryId = null,
int? completedJobs = null,
int? totalJobs = null,
string? status = null,
bool includeCurrentJobProgress = false)
{
int completed = completedJobs ?? _faker.Random.Int(0, 10);
int total = totalJobs ?? _faker.Random.Int(completed, 10);
return new LibraryScanProgressDto
{
ScanId = scanId ?? Guid.NewGuid(),
UserId = userId ?? Guid.NewGuid(),
LibraryId = libraryId ?? Guid.NewGuid(),
CompletedJobs = completed,
TotalJobs = total,
CurrentJobProgress = includeCurrentJobProgress ? _libraryScanJobProgressDtoFixture.Create() : null,
Status = status ?? _faker.PickRandom("Running", "Completed", "Failed"),
OverallProgressPercentage = total > 0 ? (decimal)completed / total * 100 : 0
};
}
/// <summary>
/// Creates multiple <see cref="LibraryScanProgressDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryScanProgressDto"/> instances.</returns>
public List<LibraryScanProgressDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
/// <summary>
/// Fixture class for generating <see cref="PaginatedBookLiteDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PaginatedBookLiteDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PaginatedBookLiteDto"/> instance with randomized test data.
/// </summary>
/// <param name="data">Optional collection of lightweight book elements.</param>
/// <param name="currentPage">Optional current page number in a paginated collection.</param>
/// <param name="perPage">Optional number of items to include per page in paginated results.</param>
/// <param name="count">Optional total number of elements available in the paginated result set.</param>
/// <param name="numberOfPages">Optional total number of pages based on the elements available and per page.</param>
/// <returns>A configured <see cref="PaginatedBookLiteDto"/> instance.</returns>
public PaginatedBookLiteDto Create(
IReadOnlyList<BookLiteDto>? data = null,
int? currentPage = null,
int? perPage = null,
int? count = null,
int? numberOfPages = null)
{
return new PaginatedBookLiteDto
{
Data = data ?? [],
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
PerPage = perPage ?? _faker.Random.Int(1, 100),
Count = count ?? _faker.Random.Int(0, 1000),
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
};
}
/// <summary>
/// Creates multiple <see cref="PaginatedBookLiteDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PaginatedBookLiteDto"/> instances.</returns>
public List<PaginatedBookLiteDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeLayoutPageDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeLayoutPageDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeLayoutPageDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the page, displayed by the themed shell.</param>
/// <param name="content">Optional. The rendered HTML content of the page section.</param>
/// <param name="script">Optional. The rendered script element of the page section, when the template defines one.</param>
/// <returns>The created <see cref="ThemeLayoutPageDto"/>.</returns>
public ThemeLayoutPageDto Create(
string? title = null,
string? content = null,
string? script = null)
{
return new ThemeLayoutPageDto(
title ?? _faker.Lorem.Word(),
content ?? _faker.Lorem.Paragraph(),
script ?? _faker.Lorem.Word());
}
/// <summary>
/// Creates a list of <see cref="ThemeLayoutPageDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ThemeLayoutPageDto"/> instances.</returns>
public List<ThemeLayoutPageDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeNavEntryDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeNavEntryDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ThemeNavEntryDto"/>.
/// </summary>
/// <param name="label">Optional label of the entry.</param>
/// <param name="url">Optional URL of the link, or <see langword="null"/> for a submenu.</param>
/// <param name="includeUrl">Whether to set <paramref name="url"/>, or <see langword="null"/> when <see langword="false"/>.</param>
/// <param name="cssClass">Optional CSS classes of the link.</param>
/// <param name="includeCssClass">Whether to set <paramref name="cssClass"/>, or <see langword="null"/> when <see langword="false"/>.</param>
/// <param name="children">Optional child links of a submenu.</param>
/// <returns>The created <see cref="ThemeNavEntryDto"/>.</returns>
public ThemeNavEntryDto Create(
string? label = null,
string? url = null,
bool includeUrl = false,
string? cssClass = null,
bool includeCssClass = false,
IReadOnlyList<ThemeNavEntryDto>? children = null)
{
return new ThemeNavEntryDto(
Label: label ?? _faker.Lorem.Word(),
Url: includeUrl ? (url ?? _faker.Internet.Url()) : null,
CssClass: includeCssClass ? (cssClass ?? _faker.Lorem.Word()) : null,
Children: children ?? []);
}
/// <summary>
/// Creates a list of <see cref="ThemeNavEntryDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeNavEntryDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
/// <summary>
/// Fixture class for the <see cref="ThemeNavSectionDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeNavSectionDtoFixture
{
private readonly Faker _faker = new();
private readonly ThemeNavEntryDtoFixture _themeNavEntryDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="ThemeNavSectionDto"/>.
/// </summary>
/// <param name="label">Optional label of the section.</param>
/// <param name="items">Optional entries of the section.</param>
/// <returns>The created <see cref="ThemeNavSectionDto"/>.</returns>
public ThemeNavSectionDto Create(
string? label = null,
IReadOnlyList<ThemeNavEntryDto>? items = null)
{
return new ThemeNavSectionDto(
Label: label ?? _faker.Lorem.Word(),
Items: items ?? [_themeNavEntryDtoFixture.Create()]);
}
/// <summary>
/// Creates a list of <see cref="ThemeNavSectionDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ThemeNavSectionDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
/// <summary>
/// Fixture class for generating <see cref="ThemePageRenderResultDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemePageRenderResultDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="ThemePageRenderResultDto"/> instance with randomized test data.
/// </summary>
/// <param name="content">Optional rendered HTML content of the page section.</param>
/// <param name="script">Optional rendered script element of the page section.</param>
/// <returns>A configured <see cref="ThemePageRenderResultDto"/> instance.</returns>
public ThemePageRenderResultDto Create(
string? content = null,
string? script = null)
{
return new ThemePageRenderResultDto(
Content: content ?? _faker.Lorem.Paragraph(),
Script: script ?? _faker.Lorem.Paragraph()
);
}
/// <summary>
/// Creates multiple <see cref="ThemePageRenderResultDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ThemePageRenderResultDto"/> instances.</returns>
public List<ThemePageRenderResultDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.UsersManagement;
/// <summary>
/// Fixture class for generating <see cref="UserDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="UserDto"/> instance with randomized test data.
/// </summary>
/// <param name="id">Optional identifier of the user.</param>
/// <param name="username">Optional username of the user.</param>
/// <returns>A configured <see cref="UserDto"/> instance.</returns>
public UserDto Create(
Guid? id = null,
string? username = null)
{
return new UserDto(
Id: id ?? Guid.NewGuid(),
Username: username ?? _faker.Internet.UserName()
);
}
/// <summary>
/// Creates multiple <see cref="UserDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserDto"/> instances.</returns>
public List<UserDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Requests.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
/// <summary>
/// Fixture class for generating <see cref="UpdateRoleRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateRoleRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="UpdateRoleRequest"/> instance with randomized test data.
/// </summary>
/// <param name="roleId">Optional identifier of the role.</param>
/// <param name="roleName">Optional name of the role.</param>
/// <param name="permissions">Optional collection of permission identifiers.</param>
/// <returns>A configured <see cref="UpdateRoleRequest"/> instance.</returns>
public UpdateRoleRequest Create(
Guid? roleId = null,
string? roleName = null,
List<Guid>? permissions = null)
{
return new UpdateRoleRequest(
RoleId: roleId ?? Guid.NewGuid(),
RoleName: roleName ?? _faker.Commerce.Department(),
Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
);
}
/// <summary>
/// Creates multiple <see cref="UpdateRoleRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateRoleRequest"/> instances.</returns>
public List<UpdateRoleRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
/// <summary>
/// Fixture class for generating <see cref="UpdateUserRoleAndPermissionsRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateUserRoleAndPermissionsRequestFixture
{
/// <summary>
/// Creates a new <see cref="UpdateUserRoleAndPermissionsRequest"/> instance with randomized test data.
/// </summary>
/// <param name="userId">Optional identifier of the user.</param>
/// <param name="roleId">Optional identifier of the role assigned to the user.</param>
/// <param name="permissions">Optional collection of permission identifiers assigned to the user.</param>
/// <returns>A configured <see cref="UpdateUserRoleAndPermissionsRequest"/> instance.</returns>
public UpdateUserRoleAndPermissionsRequest Create(
Guid? userId = null,
Guid? roleId = null,
List<Guid>? permissions = null)
{
return new UpdateUserRoleAndPermissionsRequest(
UserId: userId ?? Guid.NewGuid(),
RoleId: roleId ?? Guid.NewGuid(),
Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
);
}
/// <summary>
/// Creates multiple <see cref="UpdateUserRoleAndPermissionsRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateUserRoleAndPermissionsRequest"/> instances.</returns>
public List<UpdateUserRoleAndPermissionsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for generating <see cref="GetBooksViewRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBooksViewRequestFixture
{
/// <summary>
/// Creates a new <see cref="GetBooksViewRequest"/> instance.
/// </summary>
/// <param name="libraryId">Optional unique identifier of the media library whose books are browsed.</param>
/// <returns>A configured <see cref="GetBooksViewRequest"/> instance.</returns>
public GetBooksViewRequest Create(
Guid? libraryId = null)
{
return new GetBooksViewRequest(
LibraryId: libraryId
);
}
/// <summary>
/// Creates multiple <see cref="GetBooksViewRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetBooksViewRequest"/> instances.</returns>
public List<GetBooksViewRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
/// <summary>
/// Fixture class for generating <see cref="DeleteThemeRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteThemeRequestFixture
{
/// <summary>
/// Creates a new <see cref="DeleteThemeRequest"/> instance.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme to delete.</param>
/// <returns>A configured <see cref="DeleteThemeRequest"/> instance.</returns>
public DeleteThemeRequest Create(
string? themeId = null)
{
return new DeleteThemeRequest(
ThemeId: themeId
);
}
/// <summary>
/// Creates multiple <see cref="DeleteThemeRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="DeleteThemeRequest"/> instances.</returns>
public List<DeleteThemeRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
/// <summary>
/// Fixture class for generating <see cref="GetThemeArchiveRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetThemeArchiveRequestFixture
{
/// <summary>
/// Creates a new <see cref="GetThemeArchiveRequest"/> instance.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme to download.</param>
/// <returns>A configured <see cref="GetThemeArchiveRequest"/> instance.</returns>
public GetThemeArchiveRequest Create(
string? themeId = null)
{
return new GetThemeArchiveRequest(
ThemeId: themeId
);
}
/// <summary>
/// Creates multiple <see cref="GetThemeArchiveRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetThemeArchiveRequest"/> instances.</returns>
public List<GetThemeArchiveRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
/// <summary>
/// Fixture class for generating <see cref="GetThemeAssetRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetThemeAssetRequestFixture
{
/// <summary>
/// Creates a new <see cref="GetThemeAssetRequest"/> instance.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme.</param>
/// <param name="path">Optional asset path relative to the theme pack root.</param>
/// <returns>A configured <see cref="GetThemeAssetRequest"/> instance.</returns>
public GetThemeAssetRequest Create(
string? themeId = null,
string? path = null)
{
return new GetThemeAssetRequest(
ThemeId: themeId,
Path: path
);
}
/// <summary>
/// Creates multiple <see cref="GetThemeAssetRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetThemeAssetRequest"/> instances.</returns>
public List<GetThemeAssetRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
/// <summary>
/// Fixture class for generating <see cref="RestoreThemeRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreThemeRequestFixture
{
/// <summary>
/// Creates a new <see cref="RestoreThemeRequest"/> instance.
/// </summary>
/// <param name="themeId">Optional manifest id of the bundled theme to restore.</param>
/// <returns>A configured <see cref="RestoreThemeRequest"/> instance.</returns>
public RestoreThemeRequest Create(
string? themeId = null)
{
return new RestoreThemeRequest(
ThemeId: themeId
);
}
/// <summary>
/// Creates multiple <see cref="RestoreThemeRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RestoreThemeRequest"/> instances.</returns>
public List<RestoreThemeRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
/// <summary>
/// Fixture class for generating <see cref="SetCurrentThemeRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class SetCurrentThemeRequestFixture
{
/// <summary>
/// Creates a new <see cref="SetCurrentThemeRequest"/> instance.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme to activate.</param>
/// <returns>A configured <see cref="SetCurrentThemeRequest"/> instance.</returns>
public SetCurrentThemeRequest Create(
string? themeId = null)
{
return new SetCurrentThemeRequest(
ThemeId: themeId
);
}
/// <summary>
/// Creates multiple <see cref="SetCurrentThemeRequest"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="SetCurrentThemeRequest"/> instances.</returns>
public List<SetCurrentThemeRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Lumina.Presentation.Web.Common.Responses.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
/// <summary>
/// Fixture class for generating <see cref="GetAuthorizationResponse"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAuthorizationResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="GetAuthorizationResponse"/> instance with randomized test data.
/// </summary>
/// <param name="userId">Optional unique identifier of the user.</param>
/// <param name="role">Optional role associated to the user.</param>
/// <param name="permissions">Optional collection of permissions associated to the user.</param>
/// <returns>A configured <see cref="GetAuthorizationResponse"/> instance.</returns>
public GetAuthorizationResponse Create(
Guid? userId = null,
string? role = null,
AuthorizationPermission[]? permissions = null)
{
return new GetAuthorizationResponse(
UserId: userId ?? Guid.NewGuid(),
Role: role ?? _faker.Name.JobTitle(),
Permissions: permissions ?? [AuthorizationPermission.CanViewUsers]
);
}
/// <summary>
/// Creates multiple <see cref="GetAuthorizationResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="GetAuthorizationResponse"/> instances.</returns>
public List<GetAuthorizationResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
/// <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 or not.</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"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ChangePasswordResponse"/> instances.</returns>
public List<ChangePasswordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
/// <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 or not.</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"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RecoverPasswordResponse"/> instances.</returns>
public List<RecoverPasswordResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
/// <summary>
/// Fixture class for generating <see cref="RegisterResponse"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class RegisterResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="RegisterResponse"/> instance with randomized test data.
/// </summary>
/// <param name="username">Optional username of the registered user.</param>
/// <param name="totpSecret">Optional TOTP secret used for two-factor authentication.</param>
/// <returns>A configured <see cref="RegisterResponse"/> instance.</returns>
public RegisterResponse Create(
string? username = null,
string? totpSecret = null)
{
return new RegisterResponse(
Username: username ?? _faker.Internet.UserName(),
TotpSecret: totpSecret ?? _faker.Random.AlphaNumeric(16)
);
}
/// <summary>
/// Creates multiple <see cref="RegisterResponse"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="RegisterResponse"/> instances.</returns>
public List<RegisterResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}