@@ -19,14 +19,36 @@ public class HandlerResolverTests
1919 [ Theory ]
2020 [ InlineData ( typeof ( IInitializeHandler ) , "initialize" , 1 ) ]
2121 [ 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 ) ]
2626 public void Should_Contain_AllDefinedMethods ( Type requestHandler , string key , int count )
2727 {
2828 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 ) ;
3052 handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
3153 handler . _handlers . Count . Should ( ) . Be ( count ) ;
3254 }
@@ -36,7 +58,25 @@ public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, in
3658 public void Should_Contain_AllDefinedMethods_OnLanguageServer ( Type requestHandler , Type type2 , string key , string key2 , int count )
3759 {
3860 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 ) ;
4080 handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
4181 handler . _handlers . Should ( ) . Contain ( x => x . Method == key2 ) ;
4282 handler . _handlers . Count . Should ( ) . Be ( count ) ;
0 commit comments