using ZB.MOM.WW.ScadaBridge.AuditLog.Site.Telemetry; using ZB.MOM.WW.ScadaBridge.Communication.Grpc; namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Site.Telemetry; /// /// Tests for . The NoOp /// client is the default binding until the /// gRPC-backed implementation is delivered; both IngestAuditEventsAsync /// and IngestCachedTelemetryAsync must return an empty ack /// (no rows flipped to Forwarded) without throwing or partially handling the /// batch. /// public class NoOpSiteStreamAuditClientTests { /// Verifies that ingesting an empty cached-telemetry batch returns an empty acknowledgement. /// A task that represents the asynchronous operation. [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); } /// Verifies that ingesting a populated batch still returns an empty acknowledgement, because the no-op client forwards nothing. /// A task that represents the asynchronous operation. [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); } /// Verifies that ingesting a null batch throws an . /// A task that represents the asynchronous operation. [Fact] public async Task IngestCachedTelemetryAsync_NullBatch_Throws() { var sut = new NoOpSiteStreamAuditClient(); await Assert.ThrowsAsync( () => sut.IngestCachedTelemetryAsync(null!, CancellationToken.None)); } }