diff --git a/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentitySharedUserSeparateDbEntityFrameworkCoreTestModule.cs b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentitySharedUserSeparateDbEntityFrameworkCoreTestModule.cs index eee78bbfd9..640965266a 100644 --- a/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentitySharedUserSeparateDbEntityFrameworkCoreTestModule.cs +++ b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentitySharedUserSeparateDbEntityFrameworkCoreTestModule.cs @@ -25,10 +25,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore; typeof(AbpEntityFrameworkCoreSqliteModule))] public class AbpIdentitySharedUserSeparateDbEntityFrameworkCoreTestModule : AbpModule { - public static readonly Guid TenantAId = - IdentityUserManager_SharedUser_SeparateDatabase_Tests.TenantAId; - public static readonly Guid TenantBId = - IdentityUserManager_SharedUser_SeparateDatabase_Tests.TenantBId; + public static readonly Guid TenantAId = IdentitySharedUserSeparateDbConstants.TenantAId; + public static readonly Guid TenantBId = IdentitySharedUserSeparateDbConstants.TenantBId; // Per-app keep-alive connections so the in-memory SQLite databases survive for the test's // lifetime (without an open connection, shared-cache in-memory databases are discarded). diff --git a/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo/Abp/Identity/MongoDB/AbpIdentitySharedUserSeparateDbMongoDbTestModule.cs b/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo/Abp/Identity/MongoDB/AbpIdentitySharedUserSeparateDbMongoDbTestModule.cs index 24ae0c4b1e..0b11a09896 100644 --- a/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo/Abp/Identity/MongoDB/AbpIdentitySharedUserSeparateDbMongoDbTestModule.cs +++ b/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo/Abp/Identity/MongoDB/AbpIdentitySharedUserSeparateDbMongoDbTestModule.cs @@ -13,14 +13,16 @@ namespace Volo.Abp.Identity.MongoDB; [DependsOn(typeof(AbpIdentityMongoDbTestModule))] public class AbpIdentitySharedUserSeparateDbMongoDbTestModule : AbpModule { - public static readonly Guid TenantAId = Guid.Parse("11111111-1111-1111-1111-111111111111"); - public static readonly Guid TenantBId = Guid.Parse("22222222-2222-2222-2222-222222222222"); + public static readonly Guid TenantAId = IdentitySharedUserSeparateDbConstants.TenantAId; + public static readonly Guid TenantBId = IdentitySharedUserSeparateDbConstants.TenantBId; public override void ConfigureServices(ServiceConfigurationContext context) { - // Fixed db names so MongoSandbox's embedded mongod does not accumulate one db per test - // method. Each test method generates unique email / userName so cross-test data does not - // collide on those fields. + // Fixed tenant db names so MongoSandbox's embedded mongod does not accumulate one tenant + // db per test method. The host/default database is still configured by + // AbpIdentityMongoDbTestModule (random per test run), since AbpIdentityTestBaseModule + // re-seeds the host admin/role on every AbpApplication initialization. Each test method + // generates unique email / userName so cross-test data does not collide. var tenantAConnection = MongoDbFixture.GetConnectionString("AbpIdentity_SharedSeparateDb_TenantA"); var tenantBConnection = MongoDbFixture.GetConnectionString("AbpIdentity_SharedSeparateDb_TenantB"); diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentitySharedUserSeparateDbConstants.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentitySharedUserSeparateDbConstants.cs new file mode 100644 index 0000000000..a2a86ca83e --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentitySharedUserSeparateDbConstants.cs @@ -0,0 +1,12 @@ +using System; + +namespace Volo.Abp.Identity; + +// Single source of truth for the predefined tenant ids used by the shared-user separate-database +// test suite. Concrete EF/Mongo test modules and the abstract test class both reference these +// constants directly so the modules don't have to type-couple back into the test class. +public static class IdentitySharedUserSeparateDbConstants +{ + public static readonly Guid TenantAId = Guid.Parse("11111111-1111-1111-1111-111111111111"); + public static readonly Guid TenantBId = Guid.Parse("22222222-2222-2222-2222-222222222222"); +} diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserManager_SharedUser_SeparateDatabase_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserManager_SharedUser_SeparateDatabase_Tests.cs index ce7128c5d2..a44b13bc6c 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserManager_SharedUser_SeparateDatabase_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserManager_SharedUser_SeparateDatabase_Tests.cs @@ -22,8 +22,8 @@ namespace Volo.Abp.Identity; public abstract class IdentityUserManager_SharedUser_SeparateDatabase_Tests : AbpIdentityTestBase where TStartupModule : IAbpModule { - public static readonly Guid TenantAId = Guid.Parse("11111111-1111-1111-1111-111111111111"); - public static readonly Guid TenantBId = Guid.Parse("22222222-2222-2222-2222-222222222222"); + public static readonly Guid TenantAId = IdentitySharedUserSeparateDbConstants.TenantAId; + public static readonly Guid TenantBId = IdentitySharedUserSeparateDbConstants.TenantBId; protected IdentityUserManager IdentityUserManager { get; } protected IIdentityUserRepository IdentityUserRepository { get; }