Adds plugin upload from the web client

This commit is contained in:
BinaryAlley committed 2026-08-23 08:15:29 -07:00
1 parent d84823f6d2
commit b3ffb5dfab
57 files changed
+2774 -16

No files matched your search

@@ -127,6 +127,16 @@ public class StubApiHttpClient : IApiHttpClient
_getResponseFactories[endpoint] = () => throw exception;
}
/// <summary>
/// Registers the exception thrown when the specified PUT endpoint is called.
/// </summary>
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
/// <param name="exception">The exception to throw.</param>
public void RegisterPutException(string endpoint, ApiException exception)
{
_putResponseFactories[endpoint] = _ => throw exception;
}
/// <summary>
/// Registers the response returned when the specified PUT endpoint is called.
/// </summary>
@@ -138,6 +148,16 @@ public class StubApiHttpClient : IApiHttpClient
_putResponseFactories[endpoint] = _ => response;
}
/// <summary>
/// Registers the response factory invoked when the specified PUT endpoint is called.
/// </summary>
/// <param name="endpoint">The API endpoint for which to register the response factory.</param>
/// <param name="responseFactory">The factory that produces the response from the request payload.</param>
public void RegisterPutResponseFactory(string endpoint, Func<object, object> responseFactory)
{
_putResponseFactories[endpoint] = responseFactory;
}
/// <summary>
/// Registers the specified DELETE endpoint as succeeding.
/// </summary>
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Plugins;
using Lumina.Presentation.Web.Common.Enums.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
/// <summary>
/// Fixture class for generating <see cref="PluginDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="PluginDto"/> instance with randomized test data.
/// </summary>
/// <param name="id">Optional identifier of the plugin.</param>
/// <param name="name">Optional name of the plugin.</param>
/// <param name="author">Optional author of the plugin.</param>
/// <param name="version">Optional version of the plugin.</param>
/// <param name="loadStatus">Optional load status of the plugin.</param>
/// <returns>A configured <see cref="PluginDto"/> instance.</returns>
public PluginDto Create(Guid? id = null, string? name = null, string? author = null, string? version = null, PluginLoadStatus? loadStatus = null)
{
return new PluginDto
{
Id = id ?? Guid.NewGuid(),
Name = name ?? _faker.Hacker.Noun(),
Author = author ?? _faker.Name.FullName(),
Version = version ?? _faker.System.Semver(),
Description = _faker.Lorem.Sentence(),
LoadStatus = loadStatus ?? PluginLoadStatus.Loaded,
LoadError = null,
Settings = null
};
}
/// <summary>
/// Creates multiple <see cref="PluginDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PluginDto"/> instances.</returns>
public List<PluginDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}