Files
tiku-backend.net/Tiku.IntegrationTests/ModulePersistenceBoundaryTests.cs
xiong 4793ad1832
Some checks failed
ci / release-gate (push) Has been cancelled
fix(worker): enable safe multi-instance job processing
2026-08-04 14:29:11 +08:00

48 lines
1.9 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Tiku.Application;
using Tiku.Infrastructure;
using Tiku.Infrastructure.Persistence;
using Tiku.IntegrationTests.Infrastructure;
namespace Tiku.IntegrationTests;
public sealed class ModulePersistenceBoundaryTests
{
[Fact]
public void Module_persistence_capabilities_share_one_scoped_db_context()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddApplication();
services.AddInfrastructure(DockerPostgresTestDefaults.CreateConnectionString("tiku_module_boundary_test"));
using var provider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true });
using var scope = provider.CreateScope();
var concrete = scope.ServiceProvider.GetRequiredService<TikuDbContext>();
var capabilityTypes = new[]
{
typeof(IIdentityPersistence),
typeof(ITenancyPersistence),
typeof(ITenantAdministrationPersistence),
typeof(ICatalogPersistence),
typeof(IQuestionBankPersistence),
typeof(IContentAssetPersistence),
typeof(ILearningPersistence),
typeof(ICommercePersistence),
typeof(IPointsPersistence),
typeof(IGrowthPersistence),
typeof(IJobsOperationsPersistence),
typeof(IPlatformControlPlanePersistence),
typeof(IPlatformAdministrationPersistence),
typeof(IPlatformQuestionBankAdministrationPersistence),
typeof(IPlatformTenantCapabilitiesPersistence),
typeof(IPlatformBillingPersistence),
typeof(IOwnerActivationPersistence),
typeof(IBootstrapPersistence)
};
foreach (var capabilityType in capabilityTypes)
Assert.Same(concrete, scope.ServiceProvider.GetRequiredService(capabilityType));
}
}