Search/AdvisoryAI and DAL conversion to EF finishes up. Preparation for microservices consolidation.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user