test(siteruntime): assert computed alarms carry unified condition state
This commit is contained in:
@@ -91,6 +91,35 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
Assert.Equal(AlarmState.Normal, clearMsg.State);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AlarmActor_ComputedAlarm_CarriesUnifiedConditionState()
|
||||
{
|
||||
var alarmConfig = new ResolvedAlarm
|
||||
{
|
||||
CanonicalName = "HighTemp",
|
||||
TriggerType = "ValueMatch",
|
||||
TriggerConfiguration = "{\"attributeName\":\"Status\",\"matchValue\":\"Critical\"}",
|
||||
PriorityLevel = 700
|
||||
};
|
||||
|
||||
var instanceProbe = CreateTestProbe();
|
||||
var alarm = ActorOf(Props.Create(() => new AlarmActor(
|
||||
"HighTemp", "Pump1", instanceProbe.Ref, alarmConfig,
|
||||
null, _sharedLibrary, _options,
|
||||
NullLogger<AlarmActor>.Instance)));
|
||||
|
||||
alarm.Tell(new AttributeValueChanged(
|
||||
"Pump1", "Status", "Status", "Critical", "Good", DateTimeOffset.UtcNow));
|
||||
|
||||
var msg = instanceProbe.ExpectMsg<AlarmStateChanged>(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal(AlarmKind.Computed, msg.Kind); // computed origin
|
||||
Assert.Equal(msg.Priority, msg.Condition.Severity); // severity tracks priority
|
||||
Assert.Equal(700, msg.Condition.Severity);
|
||||
Assert.True(msg.Condition.Active); // active alarm → condition active
|
||||
Assert.True(msg.Condition.Acknowledged); // computed alarms are auto-acked
|
||||
Assert.Equal(string.Empty, msg.SourceReference); // no native source reference
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AlarmActor_RangeViolation_ActivatesOutsideRange()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user