feat(notification-outbox): CommunicationService per-site KPI accessor
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ScadaLink.Commons.Messages.Deployment;
|
||||
using ScadaLink.Commons.Messages.Notification;
|
||||
using ScadaLink.Commons.Types.Notifications;
|
||||
|
||||
namespace ScadaLink.Communication.Tests;
|
||||
|
||||
@@ -209,6 +210,32 @@ public class CommunicationServiceTests : TestKit
|
||||
Assert.Equal(3, result.QueueDepth);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetPerSiteNotificationKpisAsync_AsksOutboxProxyDirectly()
|
||||
{
|
||||
var service = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions()),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
var probe = CreateTestProbe();
|
||||
service.SetNotificationOutbox(probe.Ref);
|
||||
|
||||
var request = new PerSiteNotificationKpiRequest("corr-ps");
|
||||
var task = service.GetPerSiteNotificationKpisAsync(request);
|
||||
|
||||
var received = probe.ExpectMsg<PerSiteNotificationKpiRequest>();
|
||||
Assert.Same(request, received);
|
||||
var reply = new PerSiteNotificationKpiResponse(
|
||||
"corr-ps", true, null,
|
||||
new[] { new SiteNotificationKpiSnapshot("plant-a", 2, 0, 0, 5, null) });
|
||||
probe.Reply(reply);
|
||||
|
||||
var result = await task;
|
||||
Assert.Same(reply, result);
|
||||
Assert.True(result.Success);
|
||||
Assert.Single(result.Sites);
|
||||
Assert.Equal("plant-a", result.Sites[0].SourceSiteId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stand-in for CentralCommunicationActor: verifies the message is wrapped
|
||||
/// in a SiteEnvelope targeting the requested site and replies with a typed
|
||||
|
||||
Reference in New Issue
Block a user