feat(historian-gateway): alarm-write cutover — AddAlarmHistorian drains to GatewayAlarmHistorianWriter

Claude-Session: https://claude.ai/code/session_012SDSQ3AcaXqPcBtDESBRii
This commit is contained in:
Joseph Doherty
2026-06-26 17:40:23 -04:00
parent 8559905e8a
commit 0be79219fc
3 changed files with 87 additions and 15 deletions
@@ -0,0 +1,28 @@
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian;
using ZB.MOM.WW.OtOpcUa.Runtime.Historian;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests;
/// <summary>
/// Alarm-write cutover seam test (T13). The Host's <c>AddAlarmHistorian</c> wiring drains the durable
/// <c>SqliteStoreAndForwardSink</c> through this factory, so it must yield the gateway-backed writer —
/// sourcing the single gateway's connection from <see cref="ServerHistorianOptions"/> (endpoint/key/TLS),
/// not the legacy Wonderware-shaped <c>AlarmHistorian</c> host/port. Built offline: the underlying
/// channel dials lazily, so both the factory and the writer ctor perform no network I/O (a bogus,
/// unreachable endpoint must construct without throwing or connecting).
/// </summary>
public sealed class GatewayAlarmWriterFactoryTests
{
[Fact]
public void Factory_builds_GatewayAlarmHistorianWriter()
{
var opts = new ServerHistorianOptions { Enabled = true, Endpoint = "https://localhost:5222", ApiKey = "histgw_x_y" };
using var services = new ServiceCollection().BuildServiceProvider();
IAlarmHistorianWriter writer = GatewayHistorian.CreateAlarmWriter(opts, services);
Assert.IsType<GatewayAlarmHistorianWriter>(writer);
}
}