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

39 lines
1.4 KiB
C#

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<GatewayHistorianDataSource>(p.CreateDataSource(sp));
var writer = Assert.IsType<GatewayHistorianValueWriter>(p.CreateValueWriter(sp));
Assert.IsType<GatewayAlarmHistorianWriter>(p.CreateAlarmWriter(sp));
Assert.IsType<GatewayTagProvisioner>(p.CreateProvisioning(sp));
await writer.DisposeAsync();
}
}