aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-08-07 20:41:26 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-08-07 20:41:26 -0700
commit2615f39b208efec60619ee431e17acbf4d60a458 (patch)
tree55765c30c336580c22dd72b6777d43abe08f0d5d
parent0abb84746ce3f35bb859c0b5a88afa5cff5e2ef0 (diff)
fixing tests
-rw-r--r--src/csharp/Grpc.Core.Tests/ClientServerTest.cs9
-rw-r--r--src/csharp/Grpc.Core.Tests/TimeoutsTest.cs15
2 files changed, 10 insertions, 14 deletions
diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
index eb9cd7cf0c..08c80bbe53 100644
--- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
@@ -174,7 +174,7 @@ namespace Grpc.Core.Tests
}
[Test]
- public void AsyncUnaryCall_EchoMetadata()
+ public async Task AsyncUnaryCall_EchoMetadata()
{
helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
{
@@ -194,8 +194,7 @@ namespace Grpc.Core.Tests
new Metadata.Entry("binary-header-bin", new byte[] { 1, 2, 3, 0, 0xff }),
};
var call = Calls.AsyncUnaryCall(helper.CreateUnaryCall(new CallOptions(headers: headers)), "ABC");
-
- Assert.AreEqual("ABC", call.ResponseAsync.Result);
+ await call;
Assert.AreEqual(StatusCode.OK, call.GetStatus().StatusCode);
@@ -218,6 +217,10 @@ namespace Grpc.Core.Tests
[Test]
public void UnaryCallPerformance()
{
+ helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) => {
+ return request;
+ });
+
var callDetails = helper.CreateUnaryCall();
BenchmarkUtil.RunBenchmark(100, 100,
() => { Calls.BlockingUnaryCall(callDetails, "ABC"); });
diff --git a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs
index a52020cf40..ead0b1854b 100644
--- a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs
+++ b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs
@@ -132,20 +132,16 @@ namespace Grpc.Core.Tests
}
[Test]
- public void ServerReceivesCancellationOnTimeout()
+ public async Task ServerReceivesCancellationOnTimeout()
{
- object myLock = new object();
- string receivedCancellation = "NO";
+ var serverReceivedCancellationTcs = new TaskCompletionSource<bool>();
helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) => {
// wait until cancellation token is fired.
var tcs = new TaskCompletionSource<object>();
context.CancellationToken.Register(() => { tcs.SetResult(null); });
await tcs.Task;
- lock (myLock)
- {
- receivedCancellation = "YES";
- }
+ serverReceivedCancellationTcs.SetResult(true);
return "";
});
@@ -153,10 +149,7 @@ namespace Grpc.Core.Tests
// We can't guarantee the status code always DeadlineExceeded. See issue #2685.
Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal });
- lock (myLock)
- {
- Assert.AreEqual("YES", receivedCancellation);
- }
+ Assert.IsTrue(await serverReceivedCancellationTcs.Task);
}
}
}