From 25e3ba57b135d75ae1985fc1a94b5c498b8c8a40 Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Wed, 1 Jun 2016 14:10:29 -0700
Subject: [PATCH] improve shutdown tests

---
 src/csharp/Grpc.Core.Tests/ShutdownHookServerTest.cs | 7 +++----
 src/csharp/Grpc.Core.Tests/ShutdownHookTest.cs       | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/csharp/Grpc.Core.Tests/ShutdownHookServerTest.cs b/src/csharp/Grpc.Core.Tests/ShutdownHookServerTest.cs
index 7990a7d15f..2f40e1a8ef 100644
--- a/src/csharp/Grpc.Core.Tests/ShutdownHookServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ShutdownHookServerTest.cs
@@ -59,10 +59,9 @@ namespace Grpc.Core.Tests
             server.Start();
             AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) =>
             {
-                // TODO: expose API for killing all servers
-                // TODO: expose API for closing all channels
-                server.KillAsync();
-                GrpcEnvironment.ReleaseAsync();
+                var shutdownChannelsTask = GrpcEnvironment.ShutdownChannelsAsync();
+                var killServersTask = GrpcEnvironment.KillServersAsync();
+                Task.WaitAll(shutdownChannelsTask, killServersTask);
             };
         }
 
diff --git a/src/csharp/Grpc.Core.Tests/ShutdownHookTest.cs b/src/csharp/Grpc.Core.Tests/ShutdownHookTest.cs
index 301ae091c6..da71ed7e2e 100644
--- a/src/csharp/Grpc.Core.Tests/ShutdownHookTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ShutdownHookTest.cs
@@ -55,10 +55,10 @@ namespace Grpc.Core.Tests
         public void AppDomainProcessExitHook()
         {
             var channel = new Channel(Host, 1000, ChannelCredentials.Insecure);
+            var channel2 = new Channel(Host, 1001, ChannelCredentials.Insecure);
             AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) =>
             {
-                // TODO: expose API to shutdown all channels.
-                channel.ShutdownAsync();
+                GrpcEnvironment.ShutdownChannelsAsync().Wait();
             };
         }
 
-- 
GitLab