1
- using Grpc . Core ;
2
- using ProtoBuf . Grpc . Configuration ;
1
+ using ProtoBuf . Grpc . Configuration ;
3
2
using System ;
4
- using System . Collections . Generic ;
5
3
using Xunit ;
4
+ using Xunit . Abstractions ;
6
5
7
6
namespace protobuf_net . Grpc . Test . Issues
8
7
{
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
+
24
9
25
10
public class Issue87
26
11
{
12
+ public Issue87 ( ITestOutputHelper log )
13
+ => _log = log ;
14
+ private readonly ITestOutputHelper _log ;
15
+ private void Log ( string message ) => _log ? . WriteLine ( message ) ;
16
+
27
17
[ Theory ]
28
18
[ InlineData ( typeof ( MyService ) , null ) ]
29
19
[ InlineData ( typeof ( MyServiceBase ) , null ) ]
@@ -50,21 +40,28 @@ public void IsService(Type type, string name)
50
40
}
51
41
52
42
[ 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 )
60
53
{
61
54
var binder = new TestServerBinder ( ) ;
62
55
int count = binder . Bind ( this , type ) ;
56
+ foreach ( var bound in binder . Methods )
57
+ {
58
+ Log ( bound ) ;
59
+ }
63
60
Assert . Equal ( methods . Length , count ) ;
64
61
Assert . Equal ( methods . Length , binder . Methods . Count ) ;
65
62
foreach ( var method in methods )
66
63
{
67
- Assert . Contains ( method , binder . Methods ) ;
64
+ Assert . Contains ( prefix + method , binder . Methods ) ;
68
65
}
69
66
70
67
Assert . Empty ( binder . Warnings ) ;
0 commit comments