aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-08-05 13:02:48 -0700
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-08-05 13:02:48 -0700
commitc6f2d4f3cdca7eeb040d659e1ef9f24d750ceffa (patch)
treec5ba1b20c7bde2cbf1fe911afa9765e007bbbe70 /src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
parentc08a4d6975e0abc112800c4cd7ae6612d2aa5197 (diff)
parent31ba0632247993b02b552294691a354ee5d0ef08 (diff)
Merge pull request #2797 from jtattermusch/polishing_api
C# API improvements
Diffstat (limited to 'src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs')
-rw-r--r--src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
index 242d29a9a5..08aece7ef2 100644
--- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
+++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
@@ -46,7 +47,7 @@ namespace math.Tests
/// </summary>
public class MathClientServerTest
{
- string host = "localhost";
+ const string Host = "localhost";
Server server;
Channel channel;
Math.MathClient client;
@@ -54,19 +55,14 @@ namespace math.Tests
[TestFixtureSetUp]
public void Init()
{
- server = new Server();
- server.AddServiceDefinition(Math.BindService(new MathServiceImpl()));
- int port = server.AddPort(host, Server.PickUnusedPort, ServerCredentials.Insecure);
- server.Start();
- channel = new Channel(host, port, Credentials.Insecure);
- client = Math.NewClient(channel);
-
- // TODO(jtattermusch): get rid of the custom header here once we have dedicated tests
- // for header support.
- client.HeaderInterceptor = (metadata) =>
+ server = new Server
{
- metadata.Add(new Metadata.Entry("custom-header", "abcdef"));
+ Services = { Math.BindService(new MathServiceImpl()) },
+ Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } }
};
+ server.Start();
+ channel = new Channel(Host, server.Ports.Single().BoundPort, Credentials.Insecure);
+ client = Math.NewClient(channel);
}
[TestFixtureTearDown]