Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Fixtures.Core.Endpoints.Common;
/// <summary>
/// Fixture class for the <see cref="BaseEndpoint"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
[DontRegister]
public class BaseEndpointFixture : BaseEndpoint<object, object>
{
/// <summary>
/// Returns a standardized error response using the <see cref="ProblemDetails"/> format.
/// </summary>
/// <param name="errors">A list of errors to include in the response.</param>
/// <returns>An <see cref="IResult"/> with the problem details containing the specified errors.</returns>
public IResult TestProblem(List<Error> errors)
{
return Problem(errors);
}
/// <summary>
/// Returns a standardized validation error response using the <see cref="ValidationProblemDetails"/> format.
/// </summary>
/// <param name="errors">A list of validation errors to include in the response.</param>
/// <returns>An <see cref="IResult"/> with the validation problem details containing the specified errors.</returns>
public IResult TestValidationProblem(List<Error> errors)
{
return ValidationProblem(errors);
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
}
/// <summary>
/// Handles the API request.
/// </summary>
/// <param name="request">The request containing the file system path for which to get the root.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override Task<object> ExecuteAsync(object request, CancellationToken cancellationToken)
{
return Task.FromResult(new object());
}
}
@@ -0,0 +1,135 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#endregion
namespace Lumina.Presentation.Api.Fixtures.Core.Endpoints.FileSystemManagement;
/// <summary>
/// Fixture class for creating and managing a file system structure for integration testing purposes.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemStructureFixture
{
private static readonly bool s_hiddenAttributeIsSupported = DetectHiddenAttributeSupport();
private readonly string _rootPath;
private readonly Faker _faker = new();
/// <summary>
/// Gets a value indicating whether the fixture can create hidden elements on the current platform and file system.
/// </summary>
internal static bool HiddenAttributeIsSupported => s_hiddenAttributeIsSupported;
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemStructureFixture"/> class.
/// </summary>
public FileSystemStructureFixture()
{
_rootPath = Path.Combine(AppContext.BaseDirectory, "TestFileSystemStructure_" + Guid.NewGuid());
}
/// <summary>
/// Creates a file system structure with three nested directories, each containing two text files.
/// Makes the second nested directory and the first file in each directory hidden.
/// </summary>
/// <returns>The path to the root directory of the created file system structure.</returns>
public string CreateFileSystemStructure()
{
// Create the root directory.
Directory.CreateDirectory(_rootPath);
string currentPath = _rootPath;
for (int i = 1; i <= 3; i++)
{
// Create a nested subdirectory.
currentPath = Path.Combine(currentPath, $"NestedDirectory_{i}");
Directory.CreateDirectory(currentPath);
// Create two text files in the current directory.
for (int j = 1; j <= 2; j++)
{
string filePath = Path.Combine(currentPath, $"TestFile_{j}.txt");
File.WriteAllText(filePath, _faker.Lorem.Paragraph());
// Make the first file in each directory hidden.
if (j == 1)
SetHidden(filePath);
}
// Make the second nested directory hidden.
if (i == 2)
currentPath = SetHidden(currentPath);
}
return currentPath;
}
/// <summary>
/// Detects whether the fixture can create hidden elements on the current platform and file system.
/// </summary>
/// <returns><see langword="true"/> when hidden elements can be created, otherwise <see langword="false"/>.</returns>
private static bool DetectHiddenAttributeSupport()
{
// On Unix-like systems the fixture hides elements with the dot-prefix convention, which the file system always supports.
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
return true;
// On Windows the fixture relies on the hidden file attribute, which some file systems (for example network drives) do not persist.
string probePath = Path.Combine(AppContext.BaseDirectory, "lumina_hidden_attribute_probe_" + Guid.NewGuid());
try
{
File.WriteAllText(probePath, string.Empty);
File.SetAttributes(probePath, File.GetAttributes(probePath) | FileAttributes.Hidden);
return (File.GetAttributes(probePath) & FileAttributes.Hidden) == FileAttributes.Hidden;
}
catch
{
return false;
}
finally
{
if (File.Exists(probePath))
{
try
{
File.SetAttributes(probePath, FileAttributes.Normal);
File.Delete(probePath);
}
catch
{
}
}
}
}
/// <summary>
/// Sets the hidden attribute for a file or directory.
/// </summary>
/// <param name="path">The path to the file or directory.</param>
/// <returns>The path to the hidden file or directory.</returns>
private static string SetHidden(string path)
{
if (OperatingSystem.IsWindows())
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
// On Unix-like systems, rename the file/directory to start with a dot.
string directory = Path.GetDirectoryName(path)!;
string name = Path.GetFileName(path);
string newPath = Path.Combine(directory, "." + name);
if (Directory.Exists(path))
Directory.Move(path, newPath);
else if (File.Exists(path))
File.Move(path, newPath);
path = newPath;
}
return path;
}
/// <summary>
/// Deletes the file system structure created for testing purposes.
/// </summary>
public void CleanupFileSystemStructure()
{
if (Directory.Exists(_rootPath))
Directory.Delete(_rootPath, recursive: true);
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#endregion
namespace Lumina.Presentation.Api.Fixtures.Core.Endpoints.FileSystemManagement;
/// <summary>
/// Fixture class for creating and managing a test image for integration testing purposes.
/// </summary>
[ExcludeFromCodeCoverage]
public class TestImageFixture : IDisposable
{
/// <summary>
/// Gets the path of the created test image.
/// </summary>
public string ImagePath { get; }
/// <summary>
/// Initializes a new instance of the <see cref="TestImageFixture"/> class.
/// </summary>
public TestImageFixture()
{
ImagePath = Path.Combine(Path.GetTempPath(), $"TestImage_{Guid.NewGuid()}.jpg");
CreateTestImage();
}
/// <summary>
/// Creates a test image file.
/// </summary>
private void CreateTestImage()
{
using (Image image = new Image<Rgba32>(100, 100))
image.Save(ImagePath, new JpegEncoder());
}
/// <summary>
/// Disposes the fixture, ensuring the test image is deleted.
/// </summary>
public void Dispose()
{
if (File.Exists(ImagePath))
File.Delete(ImagePath);
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
#endregion
namespace Lumina.Presentation.Api.Fixtures.Core.Endpoints.Plugins;
/// <summary>
/// Fixture class for building plugin archives used by the plugin integration tests.
/// </summary>
[ExcludeFromCodeCoverage]
public class TestPluginArchiveFixture
{
/// <summary>
/// Builds a ZIP archive in memory containing a single plugin assembly entry.
/// </summary>
/// <param name="dllName">Optional name of the plugin assembly entry; a unique name is generated when not supplied.</param>
/// <returns>The bytes of the plugin ZIP archive.</returns>
public byte[] CreateZip(string? dllName = null)
{
string resolvedDllName = dllName ?? $"test-plugin-{Guid.NewGuid():N}.dll";
using MemoryStream stream = new();
using (ZipArchive archive = new(stream, ZipArchiveMode.Create, leaveOpen: true))
{
ZipArchiveEntry dllEntry = archive.CreateEntry(resolvedDllName);
using Stream entryStream = dllEntry.Open();
entryStream.Write(CreateAssemblyBytes());
}
return stream.ToArray();
}
/// <summary>
/// Builds a single plugin assembly file in memory.
/// </summary>
/// <returns>The bytes of the plugin assembly.</returns>
public byte[] CreateDll()
{
return CreateAssemblyBytes();
}
/// <summary>
/// Builds the arbitrary bytes of a plugin assembly file.
/// </summary>
/// <returns>The plugin assembly bytes.</returns>
private static byte[] CreateAssemblyBytes()
{
return [0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Text;
#endregion
namespace Lumina.Presentation.Api.Fixtures.Core.Endpoints.Themes;
/// <summary>
/// Fixture class for building theme pack ZIP archives used by the theme integration tests.
/// </summary>
[ExcludeFromCodeCoverage]
public class TestThemeArchiveFixture
{
/// <summary>
/// Builds a valid theme pack ZIP archive in memory, containing a <c>theme.json</c> manifest and a default template.
/// </summary>
/// <param name="themeId">Optional manifest id of the theme; a unique id is generated when not supplied.</param>
/// <returns>The bytes of the theme pack ZIP archive.</returns>
public byte[] Create(string? themeId = null)
{
string resolvedThemeId = themeId ?? $"test-theme-{Guid.NewGuid():N}";
using MemoryStream stream = new();
using (ZipArchive archive = new(stream, ZipArchiveMode.Create, leaveOpen: true))
{
ZipArchiveEntry manifestEntry = archive.CreateEntry("theme.json");
using (StreamWriter writer = new(manifestEntry.Open(), Encoding.UTF8))
{
writer.Write($$"""
{
"schemaVersion": 1,
"id": "{{resolvedThemeId}}",
"name": "Test Theme",
"description": "A test theme used by the integration tests.",
"author": "Test Author",
"version": "1.0.0",
"templates": {
"default": "templates/default.html"
}
}
""");
}
ZipArchiveEntry templateEntry = archive.CreateEntry("templates/default.html");
using (StreamWriter writer = new(templateEntry.Open(), Encoding.UTF8))
writer.Write("<html><body><h1>Default template</h1></body></html>");
}
return stream.ToArray();
}
}