using Shouldly;
using Xunit;
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
///
/// Scaffold tests for the reconnect options. Since Gitea #670 the driver has no in-driver reconnect
/// handler (session loss is reported and the host's comms-loss watchdog re-initialises the driver);
/// ReconnectPeriod is retained for config compatibility only. Outage behaviour is covered by
/// and, over the wire, OpcUaClientDriverReconnectWireTests.
///
[Trait("Category", "Unit")]
public sealed class OpcUaClientReconnectTests
{
/// Verifies that the default reconnect period matches the driver specification of 5 seconds.
[Fact]
public void Default_ReconnectPeriod_matches_driver_specs_5_seconds()
{
new OpcUaClientDriverOptions().ReconnectPeriod.ShouldBe(TimeSpan.FromSeconds(5));
}
/// Verifies that reconnect period can be configured for aggressive or relaxed retries.
[Fact]
public void Options_ReconnectPeriod_is_configurable_for_aggressive_or_relaxed_retry()
{
var opts = new OpcUaClientDriverOptions { ReconnectPeriod = TimeSpan.FromMilliseconds(500) };
opts.ReconnectPeriod.ShouldBe(TimeSpan.FromMilliseconds(500));
}
/// Verifies that the driver starts in the Unknown state before initialization.
[Fact]
public void Driver_starts_unknown_pre_init()
{
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-reconnect");
drv.GetHealth().State.ShouldBe(Core.Abstractions.DriverState.Unknown);
}
}