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