pull/6712/head
Jan Tattermusch 9 years ago
parent 5a94cf5eae
commit 71702b1d05
  1. 24
      src/csharp/Grpc.Core.Tests/ClientServerTest.cs
  2. 10
      src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs
  3. 7
      src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs
  4. 10
      src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs
  5. 26
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs

@ -235,8 +235,16 @@ namespace Grpc.Core.Tests
await barrier.Task; // make sure the handler has started. await barrier.Task; // make sure the handler has started.
cts.Cancel(); cts.Cancel();
var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseAsync); try
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); {
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
await call.ResponseAsync;
Assert.Fail();
}
catch (RpcException ex)
{
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
} }
[Test] [Test]
@ -265,9 +273,15 @@ namespace Grpc.Core.Tests
await handlerStartedBarrier.Task; await handlerStartedBarrier.Task;
cts.Cancel(); cts.Cancel();
var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseAsync); try
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); {
await call.ResponseAsync;
Assert.Fail();
}
catch (RpcException ex)
{
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
Assert.AreEqual("SUCCESS", await successTcs.Task); Assert.AreEqual("SUCCESS", await successTcs.Task);
} }

@ -105,7 +105,15 @@ namespace Grpc.Core.Tests
var parentCall = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token))); var parentCall = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
await readyToCancelTcs.Task; await readyToCancelTcs.Task;
cts.Cancel(); cts.Cancel();
Assert.ThrowsAsync(typeof(RpcException), async () => await parentCall); try
{
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
await parentCall;
Assert.Fail();
}
catch (RpcException)
{
}
Assert.AreEqual("CHILD_CALL_CANCELLED", await successTcs.Task); Assert.AreEqual("CHILD_CALL_CANCELLED", await successTcs.Task);
} }

@ -44,8 +44,11 @@ namespace Grpc.Core.Tests
public void InitializeAndShutdownGrpcEnvironment() public void InitializeAndShutdownGrpcEnvironment()
{ {
var env = GrpcEnvironment.AddRef(); var env = GrpcEnvironment.AddRef();
Assert.AreEqual(1, env.CompletionQueues.Count); Assert.IsTrue(env.CompletionQueues.Count > 0);
Assert.IsNotNull(env.CompletionQueues.ElementAt(0)); for (int i = 0; i < env.CompletionQueues.Count; i++)
{
Assert.IsNotNull(env.CompletionQueues.ElementAt(i));
}
GrpcEnvironment.Release(); GrpcEnvironment.Release();
} }

@ -134,7 +134,15 @@ namespace Grpc.Core.Tests
{ {
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) => helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
{ {
Assert.ThrowsAsync<IOException>(async () => await requestStream.MoveNext()); try
{
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
await requestStream.MoveNext();
Assert.Fail();
}
catch (IOException)
{
}
return "RESPONSE"; return "RESPONSE";
}); });

@ -471,8 +471,16 @@ namespace Grpc.IntegrationTesting
cts.Cancel(); cts.Cancel();
var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext()); try
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); {
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
await call.ResponseStream.MoveNext();
Assert.Fail();
}
catch (RpcException ex)
{
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
} }
Console.WriteLine("Passed!"); Console.WriteLine("Passed!");
} }
@ -577,9 +585,17 @@ namespace Grpc.IntegrationTesting
await call.RequestStream.WriteAsync(request); await call.RequestStream.WriteAsync(request);
await call.RequestStream.CompleteAsync(); await call.RequestStream.CompleteAsync();
var e = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.ToListAsync()); try
Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode); {
Assert.AreEqual(echoStatus.Message, e.Status.Detail); // cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
await call.ResponseStream.ToListAsync();
Assert.Fail();
}
catch (RpcException e)
{
Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode);
Assert.AreEqual(echoStatus.Message, e.Status.Detail);
}
} }
Console.WriteLine("Passed!"); Console.WriteLine("Passed!");

Loading…
Cancel
Save