feat(templateengine): validate native alarm source connection + source reference
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user