Skip to content
Snippets Groups Projects
Commit a83ad2aa authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

add idempotency test

parent 69274c2a
No related branches found
No related tags found
No related merge requests found
...@@ -166,6 +166,37 @@ namespace Grpc.Core.Tests ...@@ -166,6 +166,37 @@ namespace Grpc.Core.Tests
Assert.IsNotNull("xyz", call.GetTrailers()[0].Key); Assert.IsNotNull("xyz", call.GetTrailers()[0].Key);
} }
[Test]
public async Task ServerStreamingCall_EndOfStreamIsIdempotent()
{
helper.ServerStreamingHandler = new ServerStreamingServerMethod<string, string>(async (request, responseStream, context) =>
{
});
var call = Calls.AsyncServerStreamingCall(helper.CreateServerStreamingCall(), "");
Assert.IsFalse(await call.ResponseStream.MoveNext());
Assert.IsFalse(await call.ResponseStream.MoveNext());
}
[Test]
public async Task ServerStreamingCall_ErrorCanBeAwaitedTwice()
{
helper.ServerStreamingHandler = new ServerStreamingServerMethod<string, string>(async (request, responseStream, context) =>
{
context.Status = new Status(StatusCode.InvalidArgument, "");
});
var call = Calls.AsyncServerStreamingCall(helper.CreateServerStreamingCall(), "");
var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.InvalidArgument, ex.Status.StatusCode);
// attempting MoveNext again should result in throwing the same exception.
var ex2 = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.InvalidArgument, ex2.Status.StatusCode);
}
[Test] [Test]
public async Task DuplexStreamingCall() public async Task DuplexStreamingCall()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment