using GB5Shared.Deployment; using Microsoft.Extensions.Options; using Xunit; namespace GB5SharedTests; /// /// Covers GB5Shared.Deployment.GB5Environment — the deployment-tier abstraction consumed by /// EntitlementLoginFactory/DXPSystemContext/GopPublishService/GopQueueBLL/ /// PromotionFlowProvisioningBLL to resolve tier-suffixed connection names and GOP's own /// environment code consistently, replacing three previously-unaligned config knobs. /// public class GB5EnvironmentTests { private static GB5Environment For(GB5Tier tier) => new(Options.Create(new GB5EnvironmentOptions { Environment = tier })); [Theory] [InlineData(GB5Tier.Dev, "EntitlementDb-Dev")] [InlineData(GB5Tier.QC, "EntitlementDb-QC")] [InlineData(GB5Tier.Live, "EntitlementDb")] public void Resolve_AppliesTierSuffix_ExceptOnLive(GB5Tier tier, string expected) { var env = For(tier); Assert.Equal(expected, env.Resolve("EntitlementDb")); } [Theory] [InlineData(GB5Tier.Dev, "DXPDb-Dev")] [InlineData(GB5Tier.QC, "DXPDb-QC")] [InlineData(GB5Tier.Live, "DXPDb")] public void Resolve_WorksForAnyBaseConnectionName(GB5Tier tier, string expected) { var env = For(tier); Assert.Equal(expected, env.Resolve("DXPDb")); } [Theory] [InlineData(GB5Tier.Dev, "DEV")] [InlineData(GB5Tier.QC, "QC")] [InlineData(GB5Tier.Live, "PROD")] public void GopEnvironmentCode_MatchesHistoricalFreeTextValues(GB5Tier tier, string expected) { // Live intentionally still resolves to "PROD" — the pre-existing // MGOPSOURCEBINDING/MGOPFLOWSNAPSHOT column default, so existing rows aren't orphaned. var env = For(tier); Assert.Equal(expected, env.GopEnvironmentCode); } [Fact] public void IsLive_TrueOnlyForLiveTier() { Assert.False(For(GB5Tier.Dev).IsLive); Assert.False(For(GB5Tier.QC).IsLive); Assert.True(For(GB5Tier.Live).IsLive); } [Theory] [InlineData(GB5Tier.Dev, "Dev")] [InlineData(GB5Tier.QC, "QC")] [InlineData(GB5Tier.Live, "Live")] public void TierCode_MatchesEnumName(GB5Tier tier, string expected) { Assert.Equal(expected, For(tier).TierCode); } }