Skip to content

Commit

Permalink
Add tests for streaming messages on background (#3797)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone authored Nov 27, 2023
1 parent 3c0dd6f commit 7260c79
Show file tree
Hide file tree
Showing 3 changed files with 424 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/IceRpc.Protobuf/InvokerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static Task<IAsyncEnumerable<TOutput>> InvokeServerStreamingAsync<TOutput
}

// ReceiveStreamingResponseAsync is responsible for disposing the request
return ReceiveStreamingResponseAsync(messageParser, responseTask, request, cancellationToken);
return ReceiveStreamingResponseAsync(messageParser, responseTask, request);
}

/// <summary>Sends a request to a service and decodes the response. This method is for Protobuf bidi-streaming
Expand Down Expand Up @@ -213,7 +213,7 @@ public static Task<IAsyncEnumerable<TOutput>> InvokeBidiStreamingAsync<TInput, T
}

// ReceiveStreamingResponseAsync is responsible for disposing the request
return ReceiveStreamingResponseAsync(messageParser, responseTask, request, cancellationToken);
return ReceiveStreamingResponseAsync(messageParser, responseTask, request);
}

private static async Task<TOutput> ReceiveResponseAsync<TOutput>(
Expand Down Expand Up @@ -251,8 +251,7 @@ private static async Task<TOutput> ReceiveResponseAsync<TOutput>(
private static async Task<IAsyncEnumerable<TOutput>> ReceiveStreamingResponseAsync<TOutput>(
MessageParser<TOutput> messageParser,
Task<IncomingResponse> responseTask,
OutgoingRequest request,
CancellationToken cancellationToken) where TOutput : IMessage<TOutput>
OutgoingRequest request) where TOutput : IMessage<TOutput>
{
try
{
Expand All @@ -264,7 +263,7 @@ private static async Task<IAsyncEnumerable<TOutput>> ReceiveStreamingResponseAsy
return payload.ToAsyncEnumerable(
messageParser,
protobufFeature.MaxMessageLength,
cancellationToken);
CancellationToken.None);
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions tests/IceRpc.Protobuf.Tests/OperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using IceRpc.Features;
using IceRpc.Tests.Common;
using NUnit.Framework;
using System.IO.Pipelines;
using static System.Net.Mime.MediaTypeNames;

namespace IceRpc.Protobuf.Tests;

Expand Down Expand Up @@ -436,7 +434,7 @@ public void Server_streaming_rpc_completes_request_and_response_payloads_upon_fa

var client = new MyOperationsClient(pipeline);

// Act
// Act/Assert
Assert.ThrowsAsync<DispatchException>(async () => await client.ServerStreamingOpAsync(new Empty()));
Assert.That(() => requestPayload!.Completed, Throws.Nothing);
Assert.That(() => responsePayload!.Completed, Throws.Nothing);
Expand Down
Loading

0 comments on commit 7260c79

Please sign in to comment.