Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.NotificationOutbox.Tests/OutboxRepositorySubstitute.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
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.
2026-10-07 15:05:49 -04:00

38 lines
1.7 KiB
C#

using NSubstitute;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
namespace ZB.MOM.WW.ScadaBridge.NotificationOutbox.Tests;
/// <summary>
/// Factory for the outbox repository substitute used across these tests.
/// </summary>
/// <remarks>
/// <see cref="INotificationOutboxRepository.UpdateAsync"/> and
/// <see cref="INotificationOutboxRepository.TryUpdateFromParkedAsync"/> both
/// return whether the targeted UPDATE actually matched a row — <c>false</c> is
/// the "this notification no longer exists (or, for the CAS variant, is no
/// longer Parked)" signal the operator retry/discard handlers turn into a
/// not-found / already-progressed reply. NSubstitute's default for
/// <c>Task&lt;bool&gt;</c> is <c>false</c>, i.e. the failure answer, so an
/// unconfigured substitute would silently put every test on the failure path.
/// Tests that want a healthy store take one from here; the vanished-row and
/// lost-CAS tests configure <c>Returns(false)</c> for themselves.
/// </remarks>
internal static class OutboxRepositorySubstitute
{
/// <summary>Creates a substitute whose writes report that the row was found.</summary>
/// <returns>A substitute outbox repository whose writes report the row as found.</returns>
public static INotificationOutboxRepository Healthy()
{
var repository = Substitute.For<INotificationOutboxRepository>();
repository
.UpdateAsync(Arg.Any<Notification>(), Arg.Any<CancellationToken>())
.Returns(true);
repository
.TryUpdateFromParkedAsync(Arg.Any<Notification>(), Arg.Any<CancellationToken>())
.Returns(true);
return repository;
}
}