namespace ScadaLink.Host.Tests; /// /// Host-003: appsettings.Central.json no longer commits database connection /// strings — they are externalised to environment variables. Tests that exercise the /// full Program startup pipeline against the real SQL provider must therefore /// supply the local dev connection string the way a deployment would: via an /// environment variable (Program's configuration builder calls /// AddEnvironmentVariables()). /// /// Dispose restores the previous value so tests stay isolated. /// internal sealed class CentralDbTestEnvironment : IDisposable { // Local dev/test database — same credentials the infra docker-compose stack uses. // This is a test fixture value, not a committed production secret. private const string ConfigurationDb = "Server=localhost,1433;Database=ScadaLinkConfig;User Id=scadalink_app;Password=ScadaLink_Dev1#;TrustServerCertificate=true"; private const string ConfigKey = "ScadaLink__Database__ConfigurationDb"; private readonly string? _previousConfig; public CentralDbTestEnvironment() { _previousConfig = Environment.GetEnvironmentVariable(ConfigKey); Environment.SetEnvironmentVariable(ConfigKey, ConfigurationDb); } public void Dispose() { Environment.SetEnvironmentVariable(ConfigKey, _previousConfig); } }