blob: 3045a8cdf3188075a9d3a21d338cb3df6c335461 [file] [log] [blame]
Jan Tattermusch02017762016-11-23 15:39:56 +01001#region Copyright notice and license
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002// Copyright 2015 gRPC authors.
Jan Tattermusch02017762016-11-23 15:39:56 +01003//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
Jan Tattermusch02017762016-11-23 15:39:56 +01007//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008// http://www.apache.org/licenses/LICENSE-2.0
Jan Tattermusch02017762016-11-23 15:39:56 +01009//
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
Jan Tattermusch02017762016-11-23 15:39:56 +010015#endregion
16
17using Grpc.Reflection;
18using Grpc.Reflection.V1Alpha;
19using NUnit.Framework;
20
21
22namespace Grpc.Reflection.Tests
23{
24 /// <summary>
25 /// Tests for ReflectionServiceImpl
26 /// </summary>
27 public class SymbolRegistryTest
28 {
29 SymbolRegistry registry = SymbolRegistry.FromFiles(new[] { ReflectionReflection.Descriptor, Google.Protobuf.WellKnownTypes.Duration.Descriptor.File });
30
31 [Test]
32 public void FileByName()
33 {
34 Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileByName("google/protobuf/duration.proto"));
35 Assert.IsNull(registry.FileByName("somepackage/nonexistent.proto"));
36 }
37
38 [Test]
39 public void FileContainingSymbol()
40 {
41 Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileContainingSymbol("google.protobuf.Duration"));
42 Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo")); // method
43 Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection")); // service
44 Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflectionRequest")); // message
45 Assert.IsNull(registry.FileContainingSymbol("somepackage.Nonexistent"));
46 }
47 }
48}