Resolve all high-severity architecture review findings
This commit is contained in:
@@ -56,6 +56,49 @@ public class NativeAlarmActorTests : TestKit, IDisposable
|
||||
Source(), "inst", instanceActor, dclManager, _storage, options,
|
||||
NullLogger<NativeAlarmActor>.Instance, AlarmKind.NativeOpcUa, serviceProvider)));
|
||||
|
||||
[Fact]
|
||||
public void Stop_ReleasesAlarmSubscriptionWithOwnerIdentity()
|
||||
{
|
||||
var dcl = CreateTestProbe();
|
||||
var actor = Spawn(CreateTestProbe().Ref, dcl.Ref);
|
||||
dcl.ExpectMsg<SubscribeAlarmsRequest>();
|
||||
Sys.Stop(actor);
|
||||
var request = dcl.ExpectMsg<UnsubscribeAlarmsRequest>();
|
||||
Assert.Equal(Source().SourceReference, request.SourceReference);
|
||||
Assert.Equal(actor, dcl.LastSender);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DuplicateSnapshotEnd_DoesNotClearCommittedAlarm()
|
||||
{
|
||||
var instance = CreateTestProbe();
|
||||
var dcl = CreateTestProbe();
|
||||
var actor = Spawn(instance.Ref, dcl.Ref);
|
||||
dcl.ExpectMsg<SubscribeAlarmsRequest>();
|
||||
var epoch = Guid.NewGuid();
|
||||
NativeAlarmTransition Framed(AlarmTransitionKind kind)
|
||||
{
|
||||
var transition = Transition("T01.Hi", kind,
|
||||
new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, 800));
|
||||
var json = JsonSerializer.SerializeToNode(transition)!;
|
||||
json["SnapshotId"] = JsonSerializer.SerializeToNode(epoch);
|
||||
json["SnapshotSourceReference"] = Source().SourceReference;
|
||||
return json.Deserialize<NativeAlarmTransition>()!;
|
||||
}
|
||||
// Append-only enum value for the new start marker; before the fix it is not handled.
|
||||
actor.Tell(new NativeAlarmTransitionUpdate("Opc", Framed((AlarmTransitionKind)7)));
|
||||
actor.Tell(new NativeAlarmTransitionUpdate("Opc", Framed(AlarmTransitionKind.Snapshot)));
|
||||
var end = new NativeAlarmTransitionUpdate("Opc", Framed(AlarmTransitionKind.SnapshotComplete));
|
||||
actor.Tell(end);
|
||||
instance.ExpectMsg<AlarmStateChanged>(m => m.State == AlarmState.Active);
|
||||
// Before the fix there is also an unwanted Active event for the unrecognized start.
|
||||
// Fish out all initial active events before applying the duplicate marker.
|
||||
actor.Tell(new SubscribeAlarmsResponse("barrier", "inst", true, null, DateTimeOffset.UtcNow));
|
||||
instance.ReceiveWhile(TimeSpan.FromMilliseconds(100), msg => msg);
|
||||
actor.Tell(end);
|
||||
instance.ExpectNoMsg(TimeSpan.FromMilliseconds(200));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SubscribeOnStart_SendsRequestForSourceBinding()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user