Jan Tattermusch | 0201776 | 2016-11-23 15:39:56 +0100 | [diff] [blame] | 1 | #region Copyright notice and license |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | // Copyright 2015 gRPC authors. |
Jan Tattermusch | 0201776 | 2016-11-23 15:39:56 +0100 | [diff] [blame] | 3 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | // 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 Tattermusch | 0201776 | 2016-11-23 15:39:56 +0100 | [diff] [blame] | 7 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
Jan Tattermusch | 0201776 | 2016-11-23 15:39:56 +0100 | [diff] [blame] | 9 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | // 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 Tattermusch | 0201776 | 2016-11-23 15:39:56 +0100 | [diff] [blame] | 15 | #endregion |
| 16 | |
| 17 | using Grpc.Reflection; |
| 18 | using Grpc.Reflection.V1Alpha; |
| 19 | using NUnit.Framework; |
| 20 | |
| 21 | |
| 22 | namespace 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 | } |