diff options
author | 2015-08-07 19:13:31 -0700 | |
---|---|---|
committer | 2015-08-07 19:13:31 -0700 | |
commit | a4291e7073a40777bfe8845bd926612a76e154f6 (patch) | |
tree | f1c04f8b3eaaa73922f311e9328a58d809b402d6 | |
parent | 5b0b392cc3e02d7014b918250d6dd1d946a68d46 (diff) |
fixing tests
-rw-r--r-- | src/csharp/Grpc.Core.Tests/TimeoutsTest.cs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs index 239fc95cb6..51709813bf 100644 --- a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs +++ b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs @@ -48,14 +48,17 @@ namespace Grpc.Core.Tests /// </summary> public class TimeoutsTest { - MockServiceHelper helper = new MockServiceHelper(); + MockServiceHelper helper; Server server; Channel channel; [SetUp] public void Init() { + helper = new MockServiceHelper(); + server = helper.GetServer(); + server.Start(); channel = helper.GetChannel(); } @@ -145,6 +148,7 @@ namespace Grpc.Core.Tests [Test] public void ServerReceivesCancellationOnTimeout() { + object myLock = new object(); string receivedCancellation = "NO"; helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) => { @@ -152,7 +156,10 @@ namespace Grpc.Core.Tests var tcs = new TaskCompletionSource<object>(); context.CancellationToken.Register(() => { tcs.SetResult(null); }); await tcs.Task; - receivedCancellation = "YES"; + lock (myLock) + { + receivedCancellation = "YES"; + } return ""; }); @@ -166,7 +173,11 @@ namespace Grpc.Core.Tests // We can't guarantee the status code is always DeadlineExceeded. See issue #2685. Assert.Contains(e.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); } - Assert.AreEqual("YES", receivedCancellation); + + lock (myLock) + { + Assert.AreEqual("YES", receivedCancellation); + } } } } |