Search/AdvisoryAI and DAL conversion to EF finishes up. Preparation for microservices consolidation.

This commit is contained in:
master
2026-02-25 18:19:22 +02:00
parent 4db038123b
commit 63c70a6d37
447 changed files with 52257 additions and 2636 deletions

View File

@@ -0,0 +1,76 @@
using FluentAssertions;
using Microsoft.EntityFrameworkCore;
using StellaOps.Authority.Persistence.EfCore.CompiledModels;
using StellaOps.Authority.Persistence.EfCore.Models;
using StellaOps.TestKit;
using Xunit;
namespace StellaOps.Authority.Persistence.Tests;
/// <summary>
/// Guard tests ensuring the EF Core compiled model is real (not a stub)
/// and contains all expected entity type registrations.
/// </summary>
public sealed class CompiledModelGuardTests
{
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CompiledModel_Instance_IsNotNull()
{
AuthorityDbContextModel.Instance.Should().NotBeNull(
"compiled model must be generated via 'dotnet ef dbcontext optimize', not a stub");
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CompiledModel_HasExpectedEntityTypeCount()
{
var entityTypes = AuthorityDbContextModel.Instance.GetEntityTypes().ToList();
entityTypes.Should().HaveCount(22,
"authority compiled model must contain exactly 22 entity types (regenerate with 'dotnet ef dbcontext optimize' if count differs)");
}
[Trait("Category", TestCategories.Unit)]
[Theory]
[InlineData(typeof(TenantEfEntity))]
[InlineData(typeof(UserEfEntity))]
[InlineData(typeof(RoleEfEntity))]
[InlineData(typeof(PermissionEfEntity))]
[InlineData(typeof(RolePermissionEfEntity))]
[InlineData(typeof(UserRoleEfEntity))]
[InlineData(typeof(ApiKeyEfEntity))]
[InlineData(typeof(TokenEfEntity))]
[InlineData(typeof(RefreshTokenEfEntity))]
[InlineData(typeof(SessionEfEntity))]
[InlineData(typeof(AuditEfEntity))]
[InlineData(typeof(BootstrapInviteEfEntity))]
[InlineData(typeof(ServiceAccountEfEntity))]
[InlineData(typeof(ClientEfEntity))]
[InlineData(typeof(RevocationEfEntity))]
[InlineData(typeof(LoginAttemptEfEntity))]
[InlineData(typeof(OidcTokenEfEntity))]
[InlineData(typeof(OidcRefreshTokenEfEntity))]
[InlineData(typeof(AirgapAuditEfEntity))]
[InlineData(typeof(RevocationExportStateEfEntity))]
[InlineData(typeof(OfflineKitAuditEfEntity))]
[InlineData(typeof(VerdictManifestEfEntity))]
public void CompiledModel_ContainsEntityType(Type entityType)
{
var found = AuthorityDbContextModel.Instance.FindEntityType(entityType);
found.Should().NotBeNull(
$"compiled model must contain entity type '{entityType.Name}' — regenerate if missing");
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CompiledModel_EntityTypes_HaveTableNames()
{
var entityTypes = AuthorityDbContextModel.Instance.GetEntityTypes();
foreach (var entityType in entityTypes)
{
var tableName = entityType.GetTableName();
tableName.Should().NotBeNullOrWhiteSpace(
$"entity type '{entityType.ClrType.Name}' must have a table name configured");
}
}
}