513fa1aa16
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
83 lines
3.9 KiB
C#
83 lines
3.9 KiB
C#
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Entities;
|
|
|
|
/// <summary>
|
|
/// Verifies the <see cref="Notification"/> outbox entity's constructor defaults
|
|
/// and null-argument guards on required reference-type parameters.
|
|
/// </summary>
|
|
public class NotificationEntityTests
|
|
{
|
|
/// <summary>Verifies that the constructor sets the expected default values.</summary>
|
|
[Fact]
|
|
public void Constructor_SetsDefaults()
|
|
{
|
|
var n = new Notification("id-1", NotificationType.Email, "ops-team", "subj", "body", "SiteA");
|
|
Assert.Equal(NotificationStatus.Pending, n.Status);
|
|
Assert.Equal(0, n.RetryCount);
|
|
Assert.Equal("id-1", n.NotificationId);
|
|
Assert.Equal(NotificationType.Email, n.Type);
|
|
Assert.Equal("ops-team", n.ListName);
|
|
Assert.Equal("SiteA", n.SourceSiteId);
|
|
}
|
|
|
|
/// <summary>Verifies that OriginExecutionId defaults to null and can be set.</summary>
|
|
[Fact]
|
|
public void OriginExecutionId_DefaultsToNull_AndIsSettable()
|
|
{
|
|
// OriginExecutionId carries the originating script
|
|
// execution's id from the site so the dispatcher can echo it onto
|
|
// NotifyDeliver rows. Null for notifications submitted before the
|
|
// column existed; settable from the NotificationSubmit message.
|
|
var n = new Notification("id-1", NotificationType.Email, "ops-team", "subj", "body", "SiteA");
|
|
Assert.Null(n.OriginExecutionId);
|
|
|
|
var executionId = Guid.NewGuid();
|
|
n.OriginExecutionId = executionId;
|
|
Assert.Equal(executionId, n.OriginExecutionId);
|
|
}
|
|
|
|
/// <summary>Verifies that OriginParentExecutionId defaults to null and can be set.</summary>
|
|
[Fact]
|
|
public void OriginParentExecutionId_DefaultsToNull_AndIsSettable()
|
|
{
|
|
// Audit Log ParentExecutionId: OriginParentExecutionId carries the
|
|
// routed run's parent ExecutionId from the site so the dispatcher can
|
|
// echo it onto NotifyDeliver rows. Null for non-routed runs, or for
|
|
// notifications submitted before the column existed.
|
|
var n = new Notification("id-1", NotificationType.Email, "ops-team", "subj", "body", "SiteA");
|
|
Assert.Null(n.OriginParentExecutionId);
|
|
|
|
var parentExecutionId = Guid.NewGuid();
|
|
n.OriginParentExecutionId = parentExecutionId;
|
|
Assert.Equal(parentExecutionId, n.OriginParentExecutionId);
|
|
}
|
|
|
|
/// <summary>Verifies that SourceNode defaults to null and can be set.</summary>
|
|
[Fact]
|
|
public void SourceNode_DefaultsToNull_AndIsSettable()
|
|
{
|
|
// SourceNode identifies the cluster node that emitted the notification
|
|
// (site node-a/node-b or central-a/central-b). Additive nullable
|
|
// property — defaults to null on rows submitted before the column
|
|
// existed, and round-trips its value when set.
|
|
var n = new Notification("id-1", NotificationType.Email, "ops-team", "subj", "body", "SiteA");
|
|
Assert.Null(n.SourceNode);
|
|
|
|
n.SourceNode = "node-a";
|
|
Assert.Equal("node-a", n.SourceNode);
|
|
}
|
|
|
|
/// <summary>Verifies that the constructor throws for null arguments.</summary>
|
|
[Fact]
|
|
public void Constructor_NullArguments_Throw()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => new Notification(null!, NotificationType.Email, "list", "s", "b", "SiteA"));
|
|
Assert.Throws<ArgumentNullException>(() => new Notification("id", NotificationType.Email, null!, "s", "b", "SiteA"));
|
|
Assert.Throws<ArgumentNullException>(() => new Notification("id", NotificationType.Email, "list", null!, "b", "SiteA"));
|
|
Assert.Throws<ArgumentNullException>(() => new Notification("id", NotificationType.Email, "list", "s", null!, "SiteA"));
|
|
Assert.Throws<ArgumentNullException>(() => new Notification("id", NotificationType.Email, "list", "s", "b", null!));
|
|
}
|
|
}
|