using System; using ArchestrA; using ZB.MOM.WW.LmxOpcUa.Historian.Aveva; using ZB.MOM.WW.LmxOpcUa.Host.Configuration; namespace ZB.MOM.WW.LmxOpcUa.Historian.Aveva.Tests { /// /// Fake Historian connection factory for tests. Controls whether connections /// succeed, fail, or timeout without requiring the real Historian SDK runtime. /// internal sealed class FakeHistorianConnectionFactory : IHistorianConnectionFactory { public Exception? ConnectException { get; set; } public int ConnectCallCount { get; private set; } public Action? OnConnect { get; set; } public HistorianAccess CreateAndConnect(HistorianConfiguration config, HistorianConnectionType type) { ConnectCallCount++; if (OnConnect != null) { OnConnect(ConnectCallCount); } else if (ConnectException != null) { throw ConnectException; } // Return a HistorianAccess that is not actually connected. // ReadRawAsync etc. will fail when they try to use it, which exercises // the HandleConnectionError → reconnect path. return new HistorianAccess(); } } }