fix(template-engine): computed-alarm IsMesReportable in revision hash and diff, true-only (ScadaBridge#102 item 2)

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 15:19:15 -05:00
parent 3dd492a77f
commit 3b0c2b3bfa
4 changed files with 48 additions and 0 deletions
@@ -230,6 +230,28 @@ public class DiffServiceTests
Assert.Equal(DiffChangeType.Changed, diff.AlarmChanges[0].ChangeType);
}
/// <summary>Gitea #102: flipping a computed alarm's MES-reportable flag is a diff.</summary>
[Fact]
public void ComputeDiff_AlarmIsMesReportableChange_DetectedAsChanged()
{
var oldConfig = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
Alarms = [new ResolvedAlarm { CanonicalName = "HighTemp", TriggerType = "RangeViolation" }]
};
var newConfig = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
Alarms = [new ResolvedAlarm { CanonicalName = "HighTemp", TriggerType = "RangeViolation", IsMesReportable = true }]
};
var diff = _sut.ComputeDiff(oldConfig, newConfig);
Assert.True(diff.HasChanges);
Assert.Single(diff.AlarmChanges);
Assert.Equal(DiffChangeType.Changed, diff.AlarmChanges[0].ChangeType);
}
/// <summary>Verifies that a native alarm source reference change is detected as changed.</summary>
[Fact]
public void ComputeDiff_NativeAlarmSourceReferenceChange_DetectedAsChanged()
@@ -191,6 +191,24 @@ public class RevisionHashServiceTests
Assert.NotEqual(_sut.ComputeHash(configBefore), _sut.ComputeHash(configAfter));
}
/// <summary>Gitea #102: the computed alarm's MES-reportable flag participates in the hash; false hashes as before the field existed.</summary>
[Fact]
public void ComputeHash_AlarmIsMesReportableChange_ChangesHash()
{
var baseAlarm = new ResolvedAlarm { CanonicalName = "HighTemp", TriggerType = "RangeViolation" };
var configFalse = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1", TemplateId = 1, SiteId = 1,
Alarms = [baseAlarm]
};
var configTrue = configFalse with { Alarms = [baseAlarm with { IsMesReportable = true }] };
Assert.NotEqual(_sut.ComputeHash(configFalse), _sut.ComputeHash(configTrue));
// false is omitted from the canonical JSON, so adding the field cannot invalidate stored hashes.
Assert.Equal(_sut.ComputeHash(configFalse),
_sut.ComputeHash(configFalse with { Alarms = [baseAlarm with { IsMesReportable = false }] }));
}
/// <summary>Verifies that editing a connection endpoint changes the hash.</summary>
[Fact]
public void ComputeHash_ConnectionEndpointEdit_ChangesHash()