implement unimplemented_method interop test

pull/4382/head
Jan Tattermusch 9 years ago
parent 0ed7315648
commit fa20ebc631
  1. 2
      src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
  2. 19
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  3. 6
      src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs

@ -284,7 +284,7 @@ namespace Grpc.Core.Internal
var finishedTask = asyncCall.ServerSideCallAsync(); var finishedTask = asyncCall.ServerSideCallAsync();
var responseStream = new ServerResponseStream<byte[], byte[]>(asyncCall); var responseStream = new ServerResponseStream<byte[], byte[]>(asyncCall);
await responseStream.WriteStatusAsync(new Status(StatusCode.Unimplemented, "No such method."), Metadata.Empty).ConfigureAwait(false); await responseStream.WriteStatusAsync(new Status(StatusCode.Unimplemented, ""), Metadata.Empty).ConfigureAwait(false);
await finishedTask.ConfigureAwait(false); await finishedTask.ConfigureAwait(false);
} }
} }

@ -131,8 +131,7 @@ namespace Grpc.IntegrationTesting
}; };
} }
var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions); var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions);
TestService.TestServiceClient client = new TestService.TestServiceClient(channel); await RunTestCaseAsync(channel, options);
await RunTestCaseAsync(client, options);
await channel.ShutdownAsync(); await channel.ShutdownAsync();
} }
@ -160,8 +159,9 @@ namespace Grpc.IntegrationTesting
return credentials; return credentials;
} }
private async Task RunTestCaseAsync(TestService.TestServiceClient client, ClientOptions options) private async Task RunTestCaseAsync(Channel channel, ClientOptions options)
{ {
var client = new TestService.TestServiceClient(channel);
switch (options.TestCase) switch (options.TestCase)
{ {
case "empty_unary": case "empty_unary":
@ -209,6 +209,9 @@ namespace Grpc.IntegrationTesting
case "status_code_and_message": case "status_code_and_message":
await RunStatusCodeAndMessageAsync(client); await RunStatusCodeAndMessageAsync(client);
break; break;
case "unimplemented_method":
RunUnimplementedMethod(new UnimplementedService.UnimplementedServiceClient(channel));
break;
default: default:
throw new ArgumentException("Unknown test case " + options.TestCase); throw new ArgumentException("Unknown test case " + options.TestCase);
} }
@ -577,6 +580,16 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("Passed!"); Console.WriteLine("Passed!");
} }
public static void RunUnimplementedMethod(UnimplementedService.IUnimplementedServiceClient client)
{
Console.WriteLine("running unimplemented_method");
var e = Assert.Throws<RpcException>(() => client.UnimplementedCall(new Empty()));
Assert.AreEqual(StatusCode.Unimplemented, e.Status.StatusCode);
Assert.AreEqual("", e.Status.Detail);
Console.WriteLine("Passed!");
}
private static Payload CreateZerosPayload(int size) private static Payload CreateZerosPayload(int size)
{ {
return new Payload { Body = ByteString.CopyFrom(new byte[size]) }; return new Payload { Body = ByteString.CopyFrom(new byte[size]) };

@ -144,5 +144,11 @@ namespace Grpc.IntegrationTesting
{ {
await InteropClient.RunStatusCodeAndMessageAsync(client); await InteropClient.RunStatusCodeAndMessageAsync(client);
} }
[Test]
public void UnimplementedMethod()
{
InteropClient.RunUnimplementedMethod(UnimplementedService.NewClient(channel));
}
} }
} }

Loading…
Cancel
Save