Wraps the 4 HistoryRead overrides and OnAlarmAcknowledge with PerformanceMetrics.BeginOperation, adds alarm counters to LmxNodeManager, publishes a structured HistorianPluginOutcome from HistorianPluginLoader, and extends HealthCheckService with plugin-load, history-read, and alarm-ack-failure degradation rules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.8 KiB
C#
46 lines
1.8 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.LmxOpcUa.Host.Configuration;
|
|
using ZB.MOM.WW.LmxOpcUa.Host.Historian;
|
|
|
|
namespace ZB.MOM.WW.LmxOpcUa.Tests.Historian
|
|
{
|
|
/// <summary>
|
|
/// Verifies the load-outcome state machine of <see cref="HistorianPluginLoader"/>.
|
|
/// </summary>
|
|
public class HistorianPluginLoaderTests
|
|
{
|
|
/// <summary>
|
|
/// MarkDisabled publishes a Disabled outcome so the dashboard can distinguish
|
|
/// "feature off" from "load failed."
|
|
/// </summary>
|
|
[Fact]
|
|
public void MarkDisabled_PublishesDisabledOutcome()
|
|
{
|
|
HistorianPluginLoader.MarkDisabled();
|
|
|
|
HistorianPluginLoader.LastOutcome.Status.ShouldBe(HistorianPluginStatus.Disabled);
|
|
HistorianPluginLoader.LastOutcome.Error.ShouldBeNull();
|
|
}
|
|
|
|
/// <summary>
|
|
/// When the plugin directory is missing, TryLoad reports NotFound — not LoadFailed —
|
|
/// and returns null so the server can start with history disabled.
|
|
/// </summary>
|
|
[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.LmxOpcUa.Historian.Aveva.dll");
|
|
HistorianPluginLoader.LastOutcome.Error.ShouldBeNull();
|
|
}
|
|
}
|
|
}
|