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,32 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Api.Common.HealthChecks;
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.IntegrationTests.Core.Health;
/// <summary>
/// Factory whose database health check always reports an unhealthy state.
/// </summary>
[ExcludeFromCodeCoverage]
public class FailingDatabaseApiFactory : LuminaApiFactory
{
/// <summary>
/// Configures the web host, replacing the database health check with one that always fails.
/// </summary>
/// <param name="builder">The web host builder to configure.</param>
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);
builder.ConfigureServices(services =>
{
// The health check resolves DatabaseHealthCheck from DI when it runs, so replacing its registration with a failing subclass makes /health/ready report Unhealthy.
services.RemoveAll<DatabaseHealthCheck>();
services.AddScoped<DatabaseHealthCheck, FailingDatabaseHealthCheck>();
});
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using Lumina.DataAccess.Core.UoW;
using Lumina.Presentation.Api.Common.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.IntegrationTests.Core.Health;
/// <summary>
/// Database health check that always reports an unhealthy state.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class FailingDatabaseHealthCheck : DatabaseHealthCheck
{
/// <summary>
/// Initializes a new instance of the <see cref="FailingDatabaseHealthCheck"/> class.
/// </summary>
/// <param name="dbContext">Injected database context.</param>
public FailingDatabaseHealthCheck(LuminaDbContext dbContext) : base(dbContext)
{
}
/// <summary>
/// Reports an unhealthy state without probing the database.
/// </summary>
public override Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
{
return Task.FromResult(HealthCheckResult.Unhealthy("database unavailable"));
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.IntegrationTests.Core.Health;
/// <summary>
/// Contains integration tests for the <c>/health/ready</c> probe route when the database is unreachable.
/// </summary>
[ExcludeFromCodeCoverage]
public class HealthEndpointFailureTests : IClassFixture<FailingDatabaseApiFactory>
{
private readonly HttpClient _client;
/// <summary>
/// Initializes a new instance of the <see cref="HealthEndpointFailureTests"/> class.
/// </summary>
/// <param name="apiFactory">Injected in-memory API factory with a failing database health check.</param>
public HealthEndpointFailureTests(FailingDatabaseApiFactory apiFactory)
{
_client = apiFactory.CreateClient();
}
[Fact]
public async Task HealthReady_WhenDatabaseIsUnreachable_ShouldReturnServiceUnavailable()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/health/ready");
// Assert
Assert.Equal(HttpStatusCode.ServiceUnavailable, response.StatusCode);
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.IntegrationTests.Core.Health;
/// <summary>
/// Contains integration tests for the <c>/health/live</c> and <c>/health/ready</c> probe routes.
/// </summary>
[ExcludeFromCodeCoverage]
public class HealthEndpointTests : IClassFixture<LuminaApiFactory>
{
private readonly HttpClient _client;
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
/// <summary>
/// Initializes a new instance of the <see cref="HealthEndpointTests"/> class.
/// </summary>
/// <param name="apiFactory">Injected in-memory API factory.</param>
public HealthEndpointTests(LuminaApiFactory apiFactory)
{
_client = apiFactory.CreateClient();
}
[Fact]
public async Task HealthLive_WhenCalled_ShouldReturnOk()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/health/live");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
public async Task HealthReady_WhenDatabaseIsReachable_ShouldReturnHealthyReport()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/health/ready");
string content = await response.Content.ReadAsStringAsync();
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
HealthReportDto report = JsonSerializer.Deserialize<HealthReportDto>(content, _jsonOptions)!;
Assert.Equal("Healthy", report.Status);
HealthCheckReportDto databaseCheck = Assert.Single(report.Checks, check => check.Name == "database");
Assert.Equal("Healthy", databaseCheck.Status);
}
/// <summary>
/// Deserialized shape of the health report JSON written by the API.
/// </summary>
private sealed record HealthReportDto(string Status, List<HealthCheckReportDto> Checks);
/// <summary>
/// Deserialized shape of a single health check entry within the health report.
/// </summary>
private sealed record HealthCheckReportDto(string Name, string Status, string? Description);
}