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.
65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using ZB.MOM.WW.ScadaBridge.AuditLog.Site.Telemetry;
|
|
using ZB.MOM.WW.ScadaBridge.Communication.Grpc;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Site.Telemetry;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="NoOpSiteStreamAuditClient"/>. The NoOp
|
|
/// client is the default <see cref="ISiteStreamAuditClient"/> binding until the
|
|
/// gRPC-backed implementation is delivered; both <c>IngestAuditEventsAsync</c>
|
|
/// and <c>IngestCachedTelemetryAsync</c> must return an empty ack
|
|
/// (no rows flipped to Forwarded) without throwing or partially handling the
|
|
/// batch.
|
|
/// </summary>
|
|
public class NoOpSiteStreamAuditClientTests
|
|
{
|
|
/// <summary>Verifies that ingesting an empty cached-telemetry batch returns an empty acknowledgement.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task IngestCachedTelemetryAsync_EmptyBatch_ReturnsEmptyAck()
|
|
{
|
|
var sut = new NoOpSiteStreamAuditClient();
|
|
var batch = new CachedTelemetryBatch();
|
|
|
|
var ack = await sut.IngestCachedTelemetryAsync(batch, CancellationToken.None);
|
|
|
|
Assert.NotNull(ack);
|
|
Assert.Empty(ack.AcceptedEventIds);
|
|
}
|
|
|
|
/// <summary>Verifies that ingesting a populated batch still returns an empty acknowledgement, because the no-op client forwards nothing.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task IngestCachedTelemetryAsync_PopulatedBatch_ReturnsEmptyAck()
|
|
{
|
|
var sut = new NoOpSiteStreamAuditClient();
|
|
var batch = new CachedTelemetryBatch();
|
|
batch.Packets.Add(new CachedTelemetryPacket
|
|
{
|
|
AuditEvent = new AuditEventDto
|
|
{
|
|
EventId = Guid.NewGuid().ToString(),
|
|
Channel = "ApiOutbound",
|
|
Kind = "CachedSubmit",
|
|
Status = "Submitted",
|
|
},
|
|
});
|
|
|
|
var ack = await sut.IngestCachedTelemetryAsync(batch, CancellationToken.None);
|
|
|
|
// No EventIds flipped — NoOp does not forward to anyone.
|
|
Assert.Empty(ack.AcceptedEventIds);
|
|
}
|
|
|
|
/// <summary>Verifies that ingesting a null batch throws an <see cref="ArgumentNullException"/>.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task IngestCachedTelemetryAsync_NullBatch_Throws()
|
|
{
|
|
var sut = new NoOpSiteStreamAuditClient();
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(
|
|
() => sut.IngestCachedTelemetryAsync(null!, CancellationToken.None));
|
|
}
|
|
}
|