feat(historian): SqlServerHistorianProvider + SqlServer backend registration

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-09 13:42:38 -04:00
parent a611cc358f
commit 7500106c2f
7 changed files with 181 additions and 0 deletions
@@ -0,0 +1,39 @@
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer.Tests;
public sealed class SqlServerHistorianProviderTests
{
private static SqlServerHistorianProvider Make() => new(new SqlServerHistorianOptions
{
ConnectionString = "Server=localhost;User Id=sa;Password=x;TrustServerCertificate=True",
});
[Fact]
public void Name_and_all_six_kinds()
{
var p = Make();
p.Name.ShouldBe("SqlServer");
p.SupportedKinds.ShouldBe(Enum.GetValues<HistorianValueKind>(), ignoreOrder: true);
p.SupportedKinds.Count.ShouldBe(6);
}
[Fact]
public void Creates_all_five_seams_without_touching_sql()
{
var sp = new NullSp();
var p = Make();
p.CreateDataSource(sp).ShouldBeOfType<SqlServerHistorianDataSource>();
p.CreateValueWriter(sp).ShouldBeOfType<SqlServerHistorianValueWriter>();
p.CreateAlarmWriter(sp).ShouldBeOfType<SqlServerAlarmHistorianWriter>();
p.CreateProvisioning(sp).ShouldBeOfType<SqlServerTagProvisioner>();
p.CreateUpdater(sp).ShouldBeOfType<SqlServerHistorianDataUpdater>();
}
private sealed class NullSp : IServiceProvider
{
public object? GetService(Type serviceType) => null;
}
}