feat(templateengine): validate native alarm source connection + source reference

This commit is contained in:
Joseph Doherty
2026-05-29 16:04:01 -04:00
parent e5392d2c7b
commit ba278736af
3 changed files with 67 additions and 2 deletions
@@ -7,6 +7,42 @@ public class SemanticValidatorTests
{
private readonly SemanticValidator _sut = new();
[Fact]
public void Validate_NativeAlarmSource_UnknownConnection_ReturnsError()
{
var cfg = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
NativeAlarmSources = [new ResolvedNativeAlarmSource { CanonicalName = "P", ConnectionName = "Ghost", SourceReference = "x" }]
};
var result = _sut.Validate(cfg, alarmCapableConnectionNames: new HashSet<string> { "RealConn" });
Assert.Contains(result.Errors, e => e.Category == ValidationCategory.NativeAlarmSourceInvalid);
}
[Fact]
public void Validate_NativeAlarmSource_EmptySourceRef_ReturnsError()
{
var cfg = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
NativeAlarmSources = [new ResolvedNativeAlarmSource { CanonicalName = "P", ConnectionName = "RealConn", SourceReference = "" }]
};
var result = _sut.Validate(cfg, alarmCapableConnectionNames: new HashSet<string> { "RealConn" });
Assert.Contains(result.Errors, e => e.Category == ValidationCategory.NativeAlarmSourceInvalid);
}
[Fact]
public void Validate_NativeAlarmSource_ValidBinding_NoError()
{
var cfg = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
NativeAlarmSources = [new ResolvedNativeAlarmSource { CanonicalName = "P", ConnectionName = "RealConn", SourceReference = "ns=2;s=T1" }]
};
var result = _sut.Validate(cfg, alarmCapableConnectionNames: new HashSet<string> { "RealConn" });
Assert.DoesNotContain(result.Errors, e => e.Category == ValidationCategory.NativeAlarmSourceInvalid);
}
[Fact]
public void Validate_CallScriptTargetNotFound_ReturnsError()
{