1- using Grpc . Core ;
2- using ProtoBuf . Grpc . Configuration ;
1+ using ProtoBuf . Grpc . Configuration ;
32using System ;
4- using System . Collections . Generic ;
53using Xunit ;
4+ using Xunit . Abstractions ;
65
76namespace protobuf_net . Grpc . Test . Issues
87{
9- class TestServerBinder : ServerBinder // just tracks what methods are observed
10- {
11- public HashSet < string > Methods { get ; } = new HashSet < string > ( ) ;
12- public List < string > Warnings { get ; } = new List < string > ( ) ;
13- public List < string > Errors { get ; } = new List < string > ( ) ;
14- protected override bool TryBind < TService , TRequest , TResponse > ( ServiceBindContext bindContext , Method < TRequest , TResponse > method , MethodStub < TService > stub )
15- {
16- Methods . Add ( method . Name ) ;
17- return true ;
18- }
19- protected internal override void OnWarn ( string message , object ? [ ] ? args = null )
20- => Warnings . Add ( string . Format ( message , args ?? Array . Empty < object > ( ) ) ) ;
21- protected internal override void OnError ( string message , object ? [ ] ? args = null )
22- => Errors . Add ( string . Format ( message , args ?? Array . Empty < object > ( ) ) ) ;
23- }
8+
249
2510 public class Issue87
2611 {
12+ public Issue87 ( ITestOutputHelper log )
13+ => _log = log ;
14+ private readonly ITestOutputHelper _log ;
15+ private void Log ( string message ) => _log ? . WriteLine ( message ) ;
16+
2717 [ Theory ]
2818 [ InlineData ( typeof ( MyService ) , null ) ]
2919 [ InlineData ( typeof ( MyServiceBase ) , null ) ]
@@ -50,21 +40,28 @@ public void IsService(Type type, string name)
5040 }
5141
5242 [ Theory ]
53- [ InlineData ( typeof ( Foo ) , new [ ] { nameof ( Foo . PublicDerived ) , nameof ( FooBase . PublicBase ) , nameof ( FooBase . PublicPolymorphic ) } ) ]
54- [ InlineData ( typeof ( FooBase ) , new string [ ] { } ) ]
55- [ InlineData ( typeof ( Bar ) , new [ ] { nameof ( Bar . PublicDerived ) , nameof ( BarBase . PublicBase ) , nameof ( BarBase . PublicPolymorphic ) } ) ]
56- [ InlineData ( typeof ( BarBase ) , new [ ] { nameof ( BarBase . PublicBase ) , nameof ( BarBase . PublicPolymorphic ) } ) ]
57- [ InlineData ( typeof ( MyServiceBase ) , new [ ] { nameof ( IBaseService . BaseServiceMethodExplicit ) , nameof ( IBaseService . BaseServiceMethodImplicit ) } ) ]
58- [ InlineData ( typeof ( MyService ) , new [ ] { nameof ( IBaseService . BaseServiceMethodExplicit ) , nameof ( IBaseService . BaseServiceMethodImplicit ) , nameof ( IDerivedService . DerivedServiceMethodExplicit ) , nameof ( IDerivedService . DerivedServiceMethodImplicit ) } ) ]
59- public void CanSeeCorrectMethods ( Type type , string [ ] methods )
43+ [ InlineData ( typeof ( Foo ) , "/Foo/" , new [ ] { nameof ( Foo . PublicDerived ) , nameof ( FooBase . PublicBase ) , nameof ( FooBase . PublicPolymorphic ) } ) ]
44+ [ InlineData ( typeof ( FooBase ) , "/FooBase/" , new string [ ] { } ) ]
45+ [ InlineData ( typeof ( Bar ) , "/Bar/" , new [ ] { nameof ( Bar . PublicDerived ) , nameof ( BarBase . PublicBase ) , nameof ( BarBase . PublicPolymorphic ) } ) ]
46+ [ InlineData ( typeof ( BarBase ) , "/BarBase/" , new [ ] { nameof ( BarBase . PublicBase ) , nameof ( BarBase . PublicPolymorphic ) } ) ]
47+ [ InlineData ( typeof ( MyServiceBase ) , "/protobuf_net.Grpc.Test.Issues.BaseService/" , new [ ] { nameof ( IBaseService . BaseServiceMethodExplicit ) , nameof ( IBaseService . BaseServiceMethodImplicit ) } ) ]
48+ [ InlineData ( typeof ( MyService ) , "/protobuf_net.Grpc.Test.Issues." , new [ ] {
49+ "BaseService/" + nameof ( IBaseService . BaseServiceMethodExplicit ) , "BaseService/" + nameof ( IBaseService . BaseServiceMethodImplicit ) ,
50+ "DerivedService/" + nameof ( IDerivedService . DerivedServiceMethodExplicit ) , "DerivedService/" + nameof ( IDerivedService . DerivedServiceMethodImplicit )
51+ } ) ]
52+ public void CanSeeCorrectMethods ( Type type , string prefix , string [ ] methods )
6053 {
6154 var binder = new TestServerBinder ( ) ;
6255 int count = binder . Bind ( this , type ) ;
56+ foreach ( var bound in binder . Methods )
57+ {
58+ Log ( bound ) ;
59+ }
6360 Assert . Equal ( methods . Length , count ) ;
6461 Assert . Equal ( methods . Length , binder . Methods . Count ) ;
6562 foreach ( var method in methods )
6663 {
67- Assert . Contains ( method , binder . Methods ) ;
64+ Assert . Contains ( prefix + method , binder . Methods ) ;
6865 }
6966
7067 Assert . Empty ( binder . Warnings ) ;
0 commit comments