fix(options): canonicalize Communication/DataConnection config sections to ScadaBridge:*; drop the duplicate Host bindings that were masking the drift (plan R2-08 T9, arch-review 08r2 NF8)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.Communication.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Locks the config section <see cref="ServiceCollectionExtensions.AddCommunication"/>
|
||||
/// binds (arch-review 08 round 2 NF8). Every real appsettings nests this section under
|
||||
/// <c>ScadaBridge:</c>; binding a root-level <c>Communication</c> section reads config
|
||||
/// that no deployment writes — the drift the Host duplicate was silently masking.
|
||||
/// AddCommunication alone must bind the canonical <c>ScadaBridge:Communication</c> section.
|
||||
/// </summary>
|
||||
public class CommunicationOptionsBindingTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddCommunication_BindsTheScadaBridgeCommunicationSection()
|
||||
{
|
||||
var config = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["ScadaBridge:Communication:DeploymentTimeout"] = "00:01:23",
|
||||
}).Build();
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(config);
|
||||
services.AddCommunication();
|
||||
using var sp = services.BuildServiceProvider();
|
||||
Assert.Equal(TimeSpan.FromSeconds(83),
|
||||
sp.GetRequiredService<IOptions<CommunicationOptions>>().Value.DeploymentTimeout);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Locks the config section <see cref="ServiceCollectionExtensions.AddDataConnectionLayer"/>
|
||||
/// binds (arch-review 08 round 2 NF8). Every real appsettings nests this section under
|
||||
/// <c>ScadaBridge:</c>; binding a root-level <c>DataConnectionLayer</c> section reads config
|
||||
/// that no deployment writes — the drift the Host duplicate was silently masking.
|
||||
/// AddDataConnectionLayer alone must bind the canonical <c>ScadaBridge:DataConnection</c> section.
|
||||
/// </summary>
|
||||
public class DataConnectionOptionsBindingTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddDataConnectionLayer_BindsTheScadaBridgeDataConnectionSection()
|
||||
{
|
||||
var config = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["ScadaBridge:DataConnection:ReconnectInterval"] = "00:00:42",
|
||||
}).Build();
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(config);
|
||||
services.AddDataConnectionLayer();
|
||||
using var sp = services.BuildServiceProvider();
|
||||
Assert.Equal(TimeSpan.FromSeconds(42),
|
||||
sp.GetRequiredService<IOptions<DataConnectionOptions>>().Value.ReconnectInterval);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user