using Microsoft.Extensions.DependencyInjection; using Xunit; using ZB.MOM.WW.OtOpcUa.Runtime.Historian; using ZB.MOM.WW.OtOpcUa.Core.Abstractions; using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Recorder; namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests; public sealed class GatewayHistorianProviderTests { private static GatewayHistorianProvider Provider() => new(new ServerHistorianOptions { Endpoint = "http://localhost:5222", UseTls = false, ApiKey = "histgw_test_secret" }); private static IServiceProvider Sp() => new ServiceCollection().BuildServiceProvider(); [Fact] public void Shape_is_gateway_numeric_without_updater() { var p = Provider(); Assert.Equal("Gateway", p.Name); Assert.Equal( new[] { HistorianValueKind.Double, HistorianValueKind.Int64, HistorianValueKind.Boolean }.OrderBy(x => x), p.SupportedKinds.OrderBy(x => x)); Assert.Null(p.CreateUpdater(Sp())); } [Fact] public async Task Create_methods_build_gateway_seams() { var p = Provider(); var sp = Sp(); Assert.IsType(p.CreateDataSource(sp)); var writer = Assert.IsType(p.CreateValueWriter(sp)); Assert.IsType(p.CreateAlarmWriter(sp)); Assert.IsType(p.CreateProvisioning(sp)); await writer.DisposeAsync(); } }