From 56605efca630d693765ff2b10c253d8fbf5b0955 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 23 May 2016 15:04:42 -0400 Subject: adjust the tests to reflect the correct send behavior on client --- src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs index b4dd2c107e..303a878742 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs @@ -33,7 +33,6 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Grpc.Core.Internal; @@ -211,7 +210,9 @@ namespace Grpc.Core.Internal.Tests new Metadata()); AssertUnaryResponseSuccess(asyncCall, fakeCall, resultTask); - var ex = Assert.Throws(() => requestStream.WriteAsync("request1")); + + var writeTask = requestStream.WriteAsync("request1"); + var ex = Assert.ThrowsAsync(async () => await writeTask); Assert.AreEqual(Status.DefaultSuccess, ex.Status); } @@ -227,7 +228,9 @@ namespace Grpc.Core.Internal.Tests new Metadata()); AssertUnaryResponseError(asyncCall, fakeCall, resultTask, StatusCode.OutOfRange); - var ex = Assert.Throws(() => requestStream.WriteAsync("request1")); + + var writeTask = requestStream.WriteAsync("request1"); + var ex = Assert.ThrowsAsync(async () => await writeTask); Assert.AreEqual(StatusCode.OutOfRange, ex.Status.StatusCode); } @@ -275,6 +278,7 @@ namespace Grpc.Core.Internal.Tests asyncCall.Cancel(); Assert.IsTrue(fakeCall.IsCancelled); + // TODO: awaiting the writeTask should throw TaskCanceledException Assert.Throws(typeof(OperationCanceledException), () => requestStream.WriteAsync("request1")); fakeCall.UnaryResponseClientHandler(true, @@ -390,7 +394,8 @@ namespace Grpc.Core.Internal.Tests AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); - var ex = Assert.ThrowsAsync(async () => await requestStream.WriteAsync("request1")); + var writeTask = requestStream.WriteAsync("request1"); + var ex = Assert.ThrowsAsync(async () => await writeTask); Assert.AreEqual(Status.DefaultSuccess, ex.Status); } -- cgit v1.2.3