@@ -19,14 +19,36 @@ public class HandlerResolverTests
19
19
[ Theory ]
20
20
[ InlineData ( typeof ( IInitializeHandler ) , "initialize" , 1 ) ]
21
21
[ InlineData ( typeof ( IInitializedHandler ) , "initialized" , 1 ) ]
22
- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didOpen" , 5 ) ]
23
- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didChange" , 5 ) ]
24
- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didClose" , 5 ) ]
25
- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didSave" , 5 ) ]
22
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didOpen" , 4 ) ]
23
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didChange" , 4 ) ]
24
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didClose" , 4 ) ]
25
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didSave" , 4 ) ]
26
26
public void Should_Contain_AllDefinedMethods ( Type requestHandler , string key , int count )
27
27
{
28
28
var handler = new HandlerCollection ( ) ;
29
- handler . Add ( ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler } , new object [ 0 ] ) ) ;
29
+ var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler } , new object [ 0 ] ) ;
30
+ sub . Key . Returns ( "abcd" ) ;
31
+ handler . Add ( sub ) ;
32
+ handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
33
+ handler . _handlers . Count . Should ( ) . Be ( count ) ;
34
+ }
35
+
36
+ [ Theory ]
37
+ [ InlineData ( typeof ( IInitializeHandler ) , "initialize" , 2 ) ]
38
+ [ InlineData ( typeof ( IInitializedHandler ) , "initialized" , 2 ) ]
39
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didOpen" , 8 ) ]
40
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didChange" , 8 ) ]
41
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didClose" , 8 ) ]
42
+ [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didSave" , 8 ) ]
43
+ public void Should_Contain_AllDefinedMethods_ForDifferentKeys ( Type requestHandler , string key , int count )
44
+ {
45
+ var handler = new HandlerCollection ( ) ;
46
+ var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler } , new object [ 0 ] ) ;
47
+ sub . Key . Returns ( "abcd" ) ;
48
+ var sub2 = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler } , new object [ 0 ] ) ;
49
+ sub2 . Key . Returns ( "efgh" ) ;
50
+ handler . Add ( sub ) ;
51
+ handler . Add ( sub2 ) ;
30
52
handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
31
53
handler . _handlers . Count . Should ( ) . Be ( count ) ;
32
54
}
@@ -36,7 +58,25 @@ public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, in
36
58
public void Should_Contain_AllDefinedMethods_OnLanguageServer ( Type requestHandler , Type type2 , string key , string key2 , int count )
37
59
{
38
60
var handler = new HandlerCollection ( ) ;
39
- handler . Add ( ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ) ;
61
+ var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
62
+ sub . Key . Returns ( "abd3" ) ;
63
+ handler . Add ( sub ) ;
64
+ handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
65
+ handler . _handlers . Should ( ) . Contain ( x => x . Method == key2 ) ;
66
+ handler . _handlers . Count . Should ( ) . Be ( count ) ;
67
+ }
68
+
69
+ [ Theory ]
70
+ [ InlineData ( typeof ( IInitializeHandler ) , typeof ( IInitializedHandler ) , "initialize" , "initialized" , 4 ) ]
71
+ public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys ( Type requestHandler , Type type2 , string key , string key2 , int count )
72
+ {
73
+ var handler = new HandlerCollection ( ) ;
74
+ var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
75
+ sub . Key . Returns ( "abd3" ) ;
76
+ var sub2 = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
77
+ sub2 . Key . Returns ( "efgh" ) ;
78
+ handler . Add ( sub ) ;
79
+ handler . Add ( sub2 ) ;
40
80
handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
41
81
handler . _handlers . Should ( ) . Contain ( x => x . Method == key2 ) ;
42
82
handler . _handlers . Count . Should ( ) . Be ( count ) ;
0 commit comments