feat(historian): SqlServerHistorianProvider + SqlServer backend registration
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
+33
@@ -306,4 +306,37 @@ public sealed class ServerHistorianOptionsValidatorTests
|
||||
() => _ = provider.GetRequiredService<IOptions<ServerHistorianOptions>>().Value);
|
||||
ex.Failures.ShouldContain(f => f.Contains("ServerHistorian:Endpoint"));
|
||||
}
|
||||
|
||||
private static ServerHistorianOptionsValidator SqlSut(string? connectionString)
|
||||
{
|
||||
var values = new Dictionary<string, string?> { ["AlarmHistorian:Enabled"] = "false" };
|
||||
if (connectionString is not null) values["ServerHistorian:SqlServer:ConnectionString"] = connectionString;
|
||||
return new ServerHistorianOptionsValidator(new ConfigurationBuilder().AddInMemoryCollection(values).Build());
|
||||
}
|
||||
|
||||
/// <summary>SqlServer with a connection string passes; the gateway Endpoint/ApiKey/UseTls checks do not fire.</summary>
|
||||
[Fact]
|
||||
public void SqlServer_backend_with_connection_string_passes_without_gateway_settings()
|
||||
{
|
||||
var result = SqlSut("Server=localhost;Database=h").Validate(null,
|
||||
new ServerHistorianOptions { Backend = "SqlServer", Enabled = true });
|
||||
|
||||
result.Failed.ShouldBeFalse(string.Join("; ", result.Failures ?? []));
|
||||
}
|
||||
|
||||
/// <summary>SqlServer with no connection string fails, naming the key.</summary>
|
||||
[Fact]
|
||||
public void SqlServer_backend_without_connection_string_fails_naming_the_key()
|
||||
{
|
||||
var result = SqlSut(null).Validate(null, new ServerHistorianOptions { Backend = "SqlServer", Enabled = true });
|
||||
|
||||
result.Failed.ShouldBeTrue();
|
||||
result.Failures.ShouldContain(f => f.Contains("ServerHistorian:SqlServer:ConnectionString"));
|
||||
result.Failures.ShouldNotContain(f => f.Contains("ServerHistorian:Endpoint"));
|
||||
}
|
||||
|
||||
/// <summary>Unconsumed SqlServer section (nothing enabled) is not validated.</summary>
|
||||
[Fact]
|
||||
public void SqlServer_backend_not_consumed_passes_without_connection_string() =>
|
||||
SqlSut(null).Validate(null, new ServerHistorianOptions { Backend = "SqlServer" }).Failed.ShouldBeFalse();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user