From 9e5e7e9a6cde7f9d91b00cb65b3c99e01916c813 Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Thu, 24 Sep 2015 10:34:05 -0700
Subject: [PATCH] a small interop client refactoring

---
 .../Grpc.IntegrationTesting/InteropClient.cs  | 32 +++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
index d3b7fe87f3..c99084d1a9 100644
--- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
@@ -115,6 +115,24 @@ namespace Grpc.IntegrationTesting
         }
 
         private async Task Run()
+        {
+            var credentials = await CreateCredentialsAsync();
+            
+            List<ChannelOption> channelOptions = null;
+            if (!string.IsNullOrEmpty(options.ServerHostOverride))
+            {
+                channelOptions = new List<ChannelOption>
+                {
+                    new ChannelOption(ChannelOptions.SslTargetNameOverride, options.ServerHostOverride)
+                };
+            }
+            var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions);
+            TestService.TestServiceClient client = new TestService.TestServiceClient(channel);
+            await RunTestCaseAsync(client, options);
+            await channel.ShutdownAsync();
+        }
+
+        private async Task<Credentials> CreateCredentialsAsync()
         {
             var credentials = options.UseTls ? TestCredentials.CreateTestClientCredentials(options.UseTestCa) : Credentials.Insecure;
 
@@ -131,19 +149,7 @@ namespace Grpc.IntegrationTesting
                 Assert.IsFalse(googleCredential.IsCreateScopedRequired);
                 credentials = CompositeCredentials.Create(googleCredential.ToGrpcCredentials(), credentials);
             }
-            
-            List<ChannelOption> channelOptions = null;
-            if (!string.IsNullOrEmpty(options.ServerHostOverride))
-            {
-                channelOptions = new List<ChannelOption>
-                {
-                    new ChannelOption(ChannelOptions.SslTargetNameOverride, options.ServerHostOverride)
-                };
-            }
-            var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions);
-            TestService.TestServiceClient client = new TestService.TestServiceClient(channel);
-            await RunTestCaseAsync(client, options);
-            await channel.ShutdownAsync();
+            return credentials;
         }
 
         private async Task RunTestCaseAsync(TestService.TestServiceClient client, ClientOptions options)
-- 
GitLab