| Index: third_party/grpc/src/csharp/Grpc.Core.Tests/ShutdownTest.cs
|
| diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs b/third_party/grpc/src/csharp/Grpc.Core.Tests/ShutdownTest.cs
|
| similarity index 53%
|
| copy from third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs
|
| copy to third_party/grpc/src/csharp/Grpc.Core.Tests/ShutdownTest.cs
|
| index 8dfad8b331c1622d9325af438a1eaa6e1c5c25fd..10d666d1098f8ed2d012dee0f998e4c5671c6495 100644
|
| --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs
|
| +++ b/third_party/grpc/src/csharp/Grpc.Core.Tests/ShutdownTest.cs
|
| @@ -1,7 +1,7 @@
|
| -#region Copyright notice and license
|
| -// Protocol Buffers - Google's data interchange format
|
| -// Copyright 2015 Google Inc. All rights reserved.
|
| -// https://developers.google.com/protocol-buffers/
|
| +#region Copyright notice and license
|
| +
|
| +// Copyright 2015, Google Inc.
|
| +// All rights reserved.
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,28 +28,53 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| #endregion
|
| -
|
| +
|
| using System;
|
| -using System.Reflection;
|
| -using Google.Protobuf.TestProtos;
|
| +using System.Diagnostics;
|
| +using System.Linq;
|
| +using System.Threading;
|
| +using System.Threading.Tasks;
|
| +using Grpc.Core;
|
| +using Grpc.Core.Internal;
|
| +using Grpc.Core.Utils;
|
| using NUnit.Framework;
|
|
|
| -namespace Google.Protobuf
|
| +namespace Grpc.Core.Tests
|
| {
|
| - public class DeprecatedMemberTest
|
| + public class ShutdownTest
|
| {
|
| - private static void AssertIsDeprecated(MemberInfo member)
|
| + const string Host = "127.0.0.1";
|
| +
|
| + MockServiceHelper helper;
|
| + Server server;
|
| + Channel channel;
|
| +
|
| + [SetUp]
|
| + public void Init()
|
| {
|
| - Assert.NotNull(member);
|
| - Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
|
| + helper = new MockServiceHelper(Host);
|
| + server = helper.GetServer();
|
| + server.Start();
|
| + channel = helper.GetChannel();
|
| }
|
|
|
| [Test]
|
| - public void TestDepreatedPrimitiveValue()
|
| + public async Task AbandonedCall_ServerKillAsync()
|
| {
|
| - AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32"));
|
| - }
|
| + var readyToShutdown = new TaskCompletionSource<object>();
|
| + helper.DuplexStreamingHandler = new DuplexStreamingServerMethod<string, string>(async (requestStream, responseStream, context) =>
|
| + {
|
| + readyToShutdown.SetResult(null);
|
| + await requestStream.ToListAsync();
|
| + });
|
|
|
| + var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall());
|
| + await readyToShutdown.Task; // make sure handler is running
|
| +
|
| + await channel.ShutdownAsync(); // channel.ShutdownAsync() works even if there's a pending call.
|
| + await server.KillAsync(); // server.ShutdownAsync() would hang waiting for the call to finish.
|
| + }
|
| }
|
| }
|
|
|