using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests; /// /// Locks the config section /// binds (arch-review 08 round 2 NF8). Every real appsettings nests this section under /// ScadaBridge:; binding a root-level DataConnectionLayer section reads config /// that no deployment writes — the drift the Host duplicate was silently masking. /// AddDataConnectionLayer alone must bind the canonical ScadaBridge:DataConnection section. /// public class DataConnectionOptionsBindingTests { [Fact] public void AddDataConnectionLayer_BindsTheScadaBridgeDataConnectionSection() { var config = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary { ["ScadaBridge:DataConnection:ReconnectInterval"] = "00:00:42", }).Build(); var services = new ServiceCollection(); services.AddSingleton(config); services.AddDataConnectionLayer(); using var sp = services.BuildServiceProvider(); Assert.Equal(TimeSpan.FromSeconds(42), sp.GetRequiredService>().Value.ReconnectInterval); } }