feat(historian): SqlServerHistorianProvider + SqlServer backend registration
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
+27
@@ -5,6 +5,8 @@ using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Recorder;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer;
|
||||
using ZB.MOM.WW.OtOpcUa.Host.Configuration;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Historian;
|
||||
|
||||
@@ -59,4 +61,29 @@ public sealed class HistorianBackendRegistryTests
|
||||
p.CreateProvisioning(sp).ShouldBeOfType<GatewayTagProvisioner>();
|
||||
p.CreateUpdater(sp).ShouldBeNull();
|
||||
}
|
||||
|
||||
private static IConfiguration SqlCfg() => new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["ServerHistorian:SqlServer:ConnectionString"] = "Server=localhost;User Id=sa;Password=x;TrustServerCertificate=True",
|
||||
}).Build();
|
||||
|
||||
[Fact]
|
||||
public void SqlServer_backend_resolves_and_builds_the_sql_seams()
|
||||
{
|
||||
var sp = new ServiceCollection().BuildServiceProvider();
|
||||
var p = HistorianBackendRegistry.Resolve(new ServerHistorianOptions { Backend = "sqlserver", Enabled = true }, SqlCfg());
|
||||
|
||||
p.ShouldBeOfType<SqlServerHistorianProvider>();
|
||||
HistorianBackendRegistry.KnownBackends.ShouldContain("SqlServer");
|
||||
p.SupportedKinds.Count.ShouldBe(6);
|
||||
p.SupportedKinds.ShouldContain(HistorianValueKind.String);
|
||||
p.SupportedKinds.ShouldContain(HistorianValueKind.Empty);
|
||||
p.CreateDataSource(sp).ShouldBeOfType<SqlServerHistorianDataSource>();
|
||||
p.CreateValueWriter(sp).GetType().Name.ShouldBe("SqlServerHistorianValueWriter");
|
||||
p.CreateAlarmWriter(sp).GetType().Name.ShouldBe("SqlServerAlarmHistorianWriter");
|
||||
p.CreateProvisioning(sp).GetType().Name.ShouldBe("SqlServerTagProvisioner");
|
||||
var holder = new HistorianUpdaterHolder(p.CreateUpdater(sp));
|
||||
holder.Updater.ShouldNotBeNull();
|
||||
holder.Updater!.GetType().Name.ShouldBe("SqlServerHistorianDataUpdater");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user