public void WriteAfterCancelNotificationFails() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream <string, string>(asyncCallServer); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); // TODO(jtattermusch): should we throw a different exception type instead? Assert.Throws(typeof(InvalidOperationException), () => responseStream.WriteAsync("request1")); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteAfterWriteStatusThrowsInvalidOperationException() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream <string, string>(asyncCallServer); asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null); Assert.ThrowsAsync(typeof(InvalidOperationException), async() => await responseStream.WriteAsync("request1")); fakeCall.SendStatusFromServerHandler(true); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteCompletionFailureThrows() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream <string, string>(asyncCallServer); var writeTask = responseStream.WriteAsync("request1"); fakeCall.SendCompletionCallback.OnSendCompletion(false); Assert.ThrowsAsync(typeof(IOException), async() => await writeTask); fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteAndWriteStatusCanRunConcurrently() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream <string, string>(asyncCallServer); var writeTask = responseStream.WriteAsync("request1"); var writeStatusTask = asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null); fakeCall.SendCompletionHandler(true); fakeCall.SendStatusFromServerHandler(true); Assert.DoesNotThrowAsync(async() => await writeTask); Assert.DoesNotThrowAsync(async() => await writeStatusTask); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteAfterWriteStatusThrowsInvalidOperationException() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream<string, string>(asyncCallServer); asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null); Assert.ThrowsAsync(typeof(InvalidOperationException), async () => await responseStream.WriteAsync("request1")); fakeCall.SendStatusFromServerHandler(true); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteAndWriteStatusCanRunConcurrently() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream<string, string>(asyncCallServer); var writeTask = responseStream.WriteAsync("request1"); var writeStatusTask = asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null); fakeCall.SendCompletionHandler(true); fakeCall.SendStatusFromServerHandler(true); Assert.DoesNotThrowAsync(async () => await writeTask); Assert.DoesNotThrowAsync(async () => await writeStatusTask); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteCompletionFailureThrows() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream<string, string>(asyncCallServer); var writeTask = responseStream.WriteAsync("request1"); fakeCall.SendCompletionHandler(false); // TODO(jtattermusch): should we throw a different exception type instead? Assert.ThrowsAsync(typeof(InvalidOperationException), async () => await writeTask); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteCompletionFailureThrows() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var responseStream = new ServerResponseStream<string, string>(asyncCallServer); var writeTask = responseStream.WriteAsync("request1"); fakeCall.SendCompletionHandler(false); Assert.ThrowsAsync(typeof(IOException), async () => await writeTask); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); AssertFinished(asyncCallServer, fakeCall, finishedTask); }
public void WriteAfterCancelNotificationFails() { var finishedTask = asyncCallServer.ServerSideCallAsync(); var requestStream = new ServerRequestStream<string, string>(asyncCallServer); var responseStream = new ServerResponseStream<string, string>(asyncCallServer); fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true); // TODO(jtattermusch): should we throw a different exception type instead? Assert.Throws(typeof(InvalidOperationException), () => responseStream.WriteAsync("request1")); AssertFinished(asyncCallServer, fakeCall, finishedTask); }