Adds a restore action for soft deleted bundled themes

This commit is contained in:
BinaryAlley committed 2026-08-21 11:47:51 -07:00
1 parent 15945c2e56
commit 7e54c990ad
49 files changed
+1666 -26

No files matched your search

@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Themes.Management.Commands.RestoreTheme;
/// <summary>
/// Fixture class for the <see cref="RestoreThemeCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreThemeCommandFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RestoreThemeCommand"/>.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme to restore.</param>
/// <returns>The created <see cref="RestoreThemeCommand"/>.</returns>
public RestoreThemeCommand Create(string? themeId = null)
{
return new RestoreThemeCommand(themeId ?? _faker.Lorem.Slug(2));
}
/// <summary>
/// Creates a list of <see cref="RestoreThemeCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RestoreThemeCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Themes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
/// <summary>
/// Fixture class for the <see cref="RestoreThemeRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreThemeRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RestoreThemeRequest"/>.
/// </summary>
/// <param name="themeId">Optional. The manifest id of the theme to restore.</param>
/// <returns>The created <see cref="RestoreThemeRequest"/>.</returns>
public RestoreThemeRequest Create(string? themeId = null)
{
return new RestoreThemeRequest(themeId ?? _faker.Lorem.Slug(2));
}
/// <summary>
/// Creates a list of <see cref="RestoreThemeRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RestoreThemeRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -33,6 +33,7 @@ public class ThemeResponseFixture
/// <param name="isCurrent">Optional. Whether the theme is the currently active one.</param>
/// <param name="includeIsCurrent">Whether to set <paramref name="isCurrent"/>, or <see langword="null"/> when <see langword="false"/>.</param>
/// <param name="installedAtUtc">Optional. The UTC timestamp when the theme was installed.</param>
/// <param name="isDeleted">Optional. Whether the theme was deleted by the user.</param>
/// <returns>The created <see cref="ThemeResponse"/>.</returns>
public ThemeResponse Create(
Guid? id = null,
@@ -46,7 +47,8 @@ public class ThemeResponseFixture
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null)
DateTime? installedAtUtc = null,
bool? isDeleted = null)
{
return new ThemeResponse(
id ?? Guid.NewGuid(),
@@ -58,7 +60,8 @@ public class ThemeResponseFixture
includePreviewPath ? (previewPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)) : null,
installSource ?? _faker.PickRandom<ThemeInstallSource>(),
includeIsCurrent ? (isCurrent ?? (_faker.Random.Bool() ? true : null)) : null,
installedAtUtc ?? _faker.Date.Recent().ToUniversalTime());
installedAtUtc ?? _faker.Date.Recent().ToUniversalTime(),
isDeleted ?? _faker.Random.Bool());
}
/// <summary>
@@ -25,6 +25,7 @@ public class ThemeInfoDtoFixture
/// <param name="version">Optional semantic version of the theme.</param>
/// <param name="previewUrl">Optional URL of the theme preview image.</param>
/// <param name="isBundled">Whether the theme ships with the application.</param>
/// <param name="isDeleted">Whether the theme was deleted by the user.</param>
/// <returns>A configured <see cref="ThemeInfoDto"/> instance.</returns>
public ThemeInfoDto Create(
string? id = null,
@@ -33,7 +34,8 @@ public class ThemeInfoDtoFixture
string? author = null,
string? version = null,
string? previewUrl = null,
bool? isBundled = null)
bool? isBundled = null,
bool? isDeleted = null)
{
Faker faker = new();
return new ThemeInfoDto(
@@ -43,7 +45,8 @@ public class ThemeInfoDtoFixture
Author: author ?? faker.Name.FullName(),
Version: version ?? faker.System.Semver(),
PreviewUrl: previewUrl ?? $"/theme-assets/{faker.Lorem.Word()}/preview.png",
IsBundled: isBundled ?? faker.Random.Bool()
IsBundled: isBundled ?? faker.Random.Bool(),
IsDeleted: isDeleted ?? faker.Random.Bool()
);
}
@@ -31,6 +31,7 @@ public class ThemeResponseDtoFixture
/// <param name="isCurrent">Optional value indicating whether the theme is the active one.</param>
/// <param name="includeIsCurrent">Whether to set <paramref name="isCurrent"/>, or <see langword="null"/> when <see langword="false"/>.</param>
/// <param name="installedAtUtc">Optional UTC timestamp at which the theme was installed.</param>
/// <param name="isDeleted">Optional value indicating whether the theme was deleted by the user.</param>
/// <returns>A configured <see cref="ThemeResponseDto"/> instance.</returns>
public ThemeResponseDto Create(
Guid? id = null,
@@ -44,7 +45,8 @@ public class ThemeResponseDtoFixture
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null)
DateTime? installedAtUtc = null,
bool? isDeleted = null)
{
Faker faker = new();
return new ThemeResponseDto(
@@ -57,7 +59,8 @@ public class ThemeResponseDtoFixture
PreviewPath: includePreviewPath ? (previewPath ?? (faker.Random.Bool() ? faker.System.FilePath() : null)) : null,
InstallSource: installSource ?? ThemeInstallSource.Uploaded,
IsCurrent: includeIsCurrent ? (isCurrent ?? (faker.Random.Bool() ? true : null)) : null,
InstalledAtUtc: installedAtUtc ?? faker.Date.Recent()
InstalledAtUtc: installedAtUtc ?? faker.Date.Recent(),
IsDeleted: isDeleted ?? faker.Random.Bool()
);
}