bd6c0b4d3d
Add missing <returns>/<param>/<summary>/<typeparam> tags and clean up misused inheritdoc across 481 files so the documented API surface is complete. Documentation-only (zero code lines changed). The 131 remaining findings are inheritdoc-style warnings deliberately left to preserve hand-written implementation rationale (plan-decision notes, race-condition explanations).
55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.Hubs;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
|
|
|
|
/// <summary>
|
|
/// Covers the in-process fan-out the Blazor Server Alerts / Script log pages rely on:
|
|
/// <see cref="IInProcessBroadcaster{T}.Publish"/> raises <c>Received</c> for every current
|
|
/// subscriber, and unsubscribing stops delivery. These pages read this broadcaster directly
|
|
/// instead of opening a self-targeted SignalR connection (unreachable behind a reverse proxy).
|
|
/// </summary>
|
|
public sealed class InProcessBroadcasterTests
|
|
{
|
|
/// <summary>Verifies that Publish raises the Received event for all current subscribers.</summary>
|
|
[Fact]
|
|
public void Publish_raises_Received_for_all_current_subscribers()
|
|
{
|
|
var broadcaster = new InProcessBroadcaster<string>();
|
|
var a = new List<string>();
|
|
var b = new List<string>();
|
|
broadcaster.Received += a.Add;
|
|
broadcaster.Received += b.Add;
|
|
|
|
broadcaster.Publish("evt-1");
|
|
|
|
a.ShouldBe(["evt-1"]);
|
|
b.ShouldBe(["evt-1"]);
|
|
}
|
|
|
|
/// <summary>Verifies that an unsubscribed handler stops receiving events after removal.</summary>
|
|
[Fact]
|
|
public void Unsubscribed_handler_stops_receiving()
|
|
{
|
|
var broadcaster = new InProcessBroadcaster<string>();
|
|
var received = new List<string>();
|
|
void Handler(string s) => received.Add(s);
|
|
|
|
broadcaster.Received += Handler;
|
|
broadcaster.Publish("first");
|
|
broadcaster.Received -= Handler;
|
|
broadcaster.Publish("second");
|
|
|
|
received.ShouldBe(["first"]);
|
|
}
|
|
|
|
/// <summary>Verifies that Publish with no subscribers does not throw an exception.</summary>
|
|
[Fact]
|
|
public void Publish_with_no_subscribers_does_not_throw()
|
|
{
|
|
var broadcaster = new InProcessBroadcaster<int>();
|
|
Should.NotThrow(() => broadcaster.Publish(42));
|
|
}
|
|
}
|