Files
lmxopcua/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayAlarmWriterFactoryTests.cs
T

29 lines
1.3 KiB
C#

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);
}
}