using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Host.Configuration; using ZB.MOM.WW.OtOpcUa.Host.Historian; namespace ZB.MOM.WW.OtOpcUa.Tests.Historian { /// /// Verifies the load-outcome state machine of . /// public class HistorianPluginLoaderTests { /// /// MarkDisabled publishes a Disabled outcome so the dashboard can distinguish /// "feature off" from "load failed." /// [Fact] public void MarkDisabled_PublishesDisabledOutcome() { HistorianPluginLoader.MarkDisabled(); HistorianPluginLoader.LastOutcome.Status.ShouldBe(HistorianPluginStatus.Disabled); HistorianPluginLoader.LastOutcome.Error.ShouldBeNull(); } /// /// When the plugin directory is missing, TryLoad reports NotFound — not LoadFailed — /// and returns null so the server can start with history disabled. /// [Fact] public void TryLoad_PluginMissing_ReturnsNullWithNotFoundOutcome() { // The test process runs from a bin directory that does not contain a Historian/ // subfolder, so TryLoad will take the file-missing branch. var config = new HistorianConfiguration { Enabled = true }; var result = HistorianPluginLoader.TryLoad(config); result.ShouldBeNull(); HistorianPluginLoader.LastOutcome.Status.ShouldBe(HistorianPluginStatus.NotFound); HistorianPluginLoader.LastOutcome.PluginPath.ShouldContain("ZB.MOM.WW.OtOpcUa.Historian.Aveva.dll"); HistorianPluginLoader.LastOutcome.Error.ShouldBeNull(); } } }