chore: organize solution into module folders (Core/Server/Drivers/Client/Tooling)
Group all 69 projects into category subfolders under src/ and tests/ so the Rider Solution Explorer mirrors the module structure. Folders: Core, Server, Drivers (with a nested Driver CLIs subfolder), Client, Tooling. - Move every project folder on disk with git mv (history preserved as renames). - Recompute relative paths in 57 .csproj files: cross-category ProjectReferences, the lib/ HintPath+None refs in Driver.Historian.Wonderware, and the external mxaccessgw refs in Driver.Galaxy and its test project. - Rebuild ZB.MOM.WW.OtOpcUa.slnx with nested solution folders. - Re-prefix project paths in functional scripts (e2e, compliance, smoke SQL, integration, install). Build green (0 errors); unit tests pass. Docs left for a separate pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// #139 connection-layer config knobs: keep-alive, idle-disconnect, reconnect backoff.
|
||||
/// Coverage focuses on default behaviour (matches pre-#139 wire output exactly) and the
|
||||
/// DTO-binding path so users can drive these from JSON without editing C#.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class ModbusConnectionOptionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Defaults_Match_Historical_Behaviour()
|
||||
{
|
||||
var opts = new ModbusDriverOptions();
|
||||
|
||||
opts.KeepAlive.Enabled.ShouldBeTrue();
|
||||
opts.KeepAlive.Time.ShouldBe(TimeSpan.FromSeconds(30));
|
||||
opts.KeepAlive.Interval.ShouldBe(TimeSpan.FromSeconds(10));
|
||||
opts.KeepAlive.RetryCount.ShouldBe(3);
|
||||
|
||||
opts.IdleDisconnectTimeout.ShouldBeNull();
|
||||
|
||||
opts.Reconnect.InitialDelay.ShouldBe(TimeSpan.Zero);
|
||||
opts.Reconnect.MaxDelay.ShouldBe(TimeSpan.FromSeconds(30));
|
||||
opts.Reconnect.BackoffMultiplier.ShouldBe(2.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Factory_Reads_KeepAlive_Knobs_From_Json()
|
||||
{
|
||||
const string json = """
|
||||
{
|
||||
"host": "10.0.0.10",
|
||||
"tags": [],
|
||||
"keepAlive": { "enabled": false, "timeMs": 60000, "intervalMs": 5000, "retryCount": 5 }
|
||||
}
|
||||
""";
|
||||
var driver = ModbusDriverFactoryExtensions.CreateInstance("modbus-1", json);
|
||||
// Reach into options via reflection — the factory's options field is internal.
|
||||
var opts = (ModbusDriverOptions)typeof(ModbusDriver)
|
||||
.GetField("_options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!
|
||||
.GetValue(driver)!;
|
||||
|
||||
opts.KeepAlive.Enabled.ShouldBeFalse();
|
||||
opts.KeepAlive.Time.ShouldBe(TimeSpan.FromMinutes(1));
|
||||
opts.KeepAlive.Interval.ShouldBe(TimeSpan.FromSeconds(5));
|
||||
opts.KeepAlive.RetryCount.ShouldBe(5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Factory_Reads_IdleDisconnect_From_Json()
|
||||
{
|
||||
const string json = """{ "host": "10.0.0.10", "tags": [], "idleDisconnectMs": 120000 }""";
|
||||
var driver = ModbusDriverFactoryExtensions.CreateInstance("modbus-1", json);
|
||||
var opts = (ModbusDriverOptions)typeof(ModbusDriver)
|
||||
.GetField("_options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!
|
||||
.GetValue(driver)!;
|
||||
|
||||
opts.IdleDisconnectTimeout.ShouldBe(TimeSpan.FromMinutes(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Factory_Reads_Reconnect_Backoff_From_Json()
|
||||
{
|
||||
const string json = """
|
||||
{
|
||||
"host": "10.0.0.10",
|
||||
"tags": [],
|
||||
"reconnect": { "initialDelayMs": 500, "maxDelayMs": 60000, "backoffMultiplier": 1.5 }
|
||||
}
|
||||
""";
|
||||
var driver = ModbusDriverFactoryExtensions.CreateInstance("modbus-1", json);
|
||||
var opts = (ModbusDriverOptions)typeof(ModbusDriver)
|
||||
.GetField("_options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!
|
||||
.GetValue(driver)!;
|
||||
|
||||
opts.Reconnect.InitialDelay.ShouldBe(TimeSpan.FromMilliseconds(500));
|
||||
opts.Reconnect.MaxDelay.ShouldBe(TimeSpan.FromMinutes(1));
|
||||
opts.Reconnect.BackoffMultiplier.ShouldBe(1.5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Factory_With_Empty_Json_Uses_All_Defaults()
|
||||
{
|
||||
const string json = """{ "host": "10.0.0.10", "tags": [] }""";
|
||||
var driver = ModbusDriverFactoryExtensions.CreateInstance("modbus-1", json);
|
||||
var opts = (ModbusDriverOptions)typeof(ModbusDriver)
|
||||
.GetField("_options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!
|
||||
.GetValue(driver)!;
|
||||
|
||||
// Every connection-layer field must match the historical defaults so existing config
|
||||
// rows stay bit-for-bit identical after #139.
|
||||
opts.KeepAlive.Enabled.ShouldBeTrue();
|
||||
opts.IdleDisconnectTimeout.ShouldBeNull();
|
||||
opts.Reconnect.InitialDelay.ShouldBe(TimeSpan.Zero);
|
||||
opts.AutoReconnect.ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user