blob: 55ff160feb8686a38cbe71ac1d45945ce7ccff76 [file] [log] [blame]
Jan Tattermusch253769e2016-03-21 16:25:59 -07001#region Copyright notice and license
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003// Copyright 2016 gRPC authors.
Jan Tattermusch253769e2016-03-21 16:25:59 -07004//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
Jan Tattermusch253769e2016-03-21 16:25:59 -07008//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009// http://www.apache.org/licenses/LICENSE-2.0
Jan Tattermusch253769e2016-03-21 16:25:59 -070010//
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
Jan Tattermusch253769e2016-03-21 16:25:59 -070016
17#endregion
18
19using System;
20using System.Collections.Generic;
21using System.Diagnostics;
22using System.IO;
23using System.Linq;
24using System.Text.RegularExpressions;
25using System.Threading.Tasks;
26using Google.Protobuf;
27using Grpc.Core;
28using Grpc.Core.Utils;
29using NUnit.Framework;
30using Grpc.Testing;
31
32namespace Grpc.IntegrationTesting
33{
34 /// <summary>
35 /// Utility methods for defining and calling a service that doesn't use protobufs
36 /// for serialization/deserialization.
37 /// </summary>
38 public static class GenericService
39 {
40 readonly static Marshaller<byte[]> ByteArrayMarshaller = new Marshaller<byte[]>((b) => b, (b) => b);
41
42 public readonly static Method<byte[], byte[]> StreamingCallMethod = new Method<byte[], byte[]>(
43 MethodType.DuplexStreaming,
44 "grpc.testing.BenchmarkService",
45 "StreamingCall",
46 ByteArrayMarshaller,
47 ByteArrayMarshaller
48 );
49
50 public static ServerServiceDefinition BindHandler(DuplexStreamingServerMethod<byte[], byte[]> handler)
51 {
Jan Tattermusch781720f2016-06-03 17:40:28 -070052 return ServerServiceDefinition.CreateBuilder()
Jan Tattermusch253769e2016-03-21 16:25:59 -070053 .AddMethod(StreamingCallMethod, handler).Build();
54 }
55 }
56}