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.
52 lines
2.4 KiB
C#
52 lines
2.4 KiB
C#
using Grpc.Core;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using NSubstitute;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces;
|
|
using ZB.MOM.WW.ScadaBridge.Communication.Grpc;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.Communication.Tests;
|
|
|
|
public class LowReviewTransportTests
|
|
{
|
|
private static SiteStreamGrpcServer Server() => new(
|
|
Substitute.For<ISiteStreamSubscriber>(), NullLogger<SiteStreamGrpcServer>.Instance);
|
|
|
|
/// <summary>Verifies that pull requests with an oversized batch size are rejected before any rows are read.</summary>
|
|
/// <param name="size">The oversized batch size requested.</param>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Theory]
|
|
[InlineData(2001)]
|
|
[InlineData(int.MaxValue)]
|
|
public async Task Pulls_RejectOversizedRowRequestsBeforeReading(int size)
|
|
{
|
|
var server = Server();
|
|
var queue = Substitute.For<ISiteAuditQueue>();
|
|
var store = Substitute.For<IOperationTrackingStore>();
|
|
server.SetSiteAuditQueue(queue);
|
|
server.SetOperationTrackingStore(store);
|
|
var context = Substitute.For<ServerCallContext>();
|
|
var audit = await Assert.ThrowsAsync<RpcException>(() => server.PullAuditEvents(
|
|
new PullAuditEventsRequest { BatchSize = size }, context));
|
|
var calls = await Assert.ThrowsAsync<RpcException>(() => server.PullSiteCalls(
|
|
new PullSiteCallsRequest { BatchSize = size }, context));
|
|
Assert.Equal(StatusCode.InvalidArgument, audit.StatusCode);
|
|
Assert.Equal(StatusCode.InvalidArgument, calls.StatusCode);
|
|
Assert.Empty(queue.ReceivedCalls());
|
|
Assert.Empty(store.ReceivedCalls());
|
|
}
|
|
|
|
/// <summary>Verifies that the retired site ingest RPCs return Unimplemented even for empty batches.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task RetiredSiteIngestRpcs_ReturnUnimplementedEvenForEmptyBatches()
|
|
{
|
|
var server = Server();
|
|
var context = Substitute.For<ServerCallContext>();
|
|
var audit = await Assert.ThrowsAsync<RpcException>(() => server.IngestAuditEvents(new(), context));
|
|
var cached = await Assert.ThrowsAsync<RpcException>(() => server.IngestCachedTelemetry(new(), context));
|
|
Assert.Equal(StatusCode.Unimplemented, audit.StatusCode);
|
|
Assert.Equal(StatusCode.Unimplemented, cached.StatusCode);
|
|
}
|
|
}
|