fix(dcl): feed ScadaBridge:MxGateway:ClientNamePrefix into the MxGateway client-name fallback (review 2026-10-21 02/U1, 08/O2)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
||||
|
||||
@@ -32,4 +35,27 @@ public class GlobalOptionsValidationTests
|
||||
using var provider = services.BuildServiceProvider();
|
||||
provider.GetRequiredService<IStartupValidator>().Validate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Review 2026-10-21 02/U1: the bound <c>ScadaBridge:MxGateway:ClientNamePrefix</c> actually
|
||||
/// reaches the MxGateway adapters the DI-built factory creates.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ClientNamePrefix_FlowsIntoTheMxGatewayAdapter()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(new ConfigurationBuilder().AddInMemoryCollection(
|
||||
new Dictionary<string, string?> { ["ScadaBridge:MxGateway:ClientNamePrefix"] = "plant7" }).Build());
|
||||
services.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance);
|
||||
services.AddDataConnectionLayer();
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
var adapter = provider.GetRequiredService<IDataConnectionFactory>()
|
||||
.Create("MxGateway", new Dictionary<string, string>());
|
||||
|
||||
var prefix = typeof(MxGatewayDataConnection)
|
||||
.GetField("_clientNamePrefix", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!
|
||||
.GetValue(adapter);
|
||||
Assert.Equal("plant7", prefix);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user