77using OmniSharp . Extensions . LanguageServer . Protocol ;
88using NSubstitute ;
99using OmniSharp . Extensions . JsonRpc ;
10+ using OmniSharp . Extensions . LanguageServer ;
1011using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
1112using Xunit ;
1213using HandlerCollection = OmniSharp . Extensions . LanguageServer . HandlerCollection ;
@@ -17,7 +18,6 @@ namespace Lsp.Tests
1718{
1819 public class HandlerResolverTests
1920 {
20-
2121 [ Theory ]
2222 [ InlineData ( typeof ( IInitializeHandler ) , "initialize" , 1 ) ]
2323 [ InlineData ( typeof ( IInitializedHandler ) , "initialized" , 1 ) ]
@@ -35,11 +35,11 @@ public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, in
3535 }
3636
3737 [ Theory ]
38- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didOpen" , 4 ) ]
39- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didChange" , 4 ) ]
40- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didClose" , 4 ) ]
41- [ InlineData ( typeof ( ITextDocumentSyncHandler ) , "textDocument/didSave" , 4 ) ]
42- public void Should_Contain_AllDefinedTextDocumentSyncMethods ( Type requestHandler , string key , int count )
38+ [ InlineData ( "textDocument/didOpen" , 4 ) ]
39+ [ InlineData ( "textDocument/didChange" , 4 ) ]
40+ [ InlineData ( "textDocument/didClose" , 4 ) ]
41+ [ InlineData ( "textDocument/didSave" , 4 ) ]
42+ public void Should_Contain_AllDefinedTextDocumentSyncMethods ( string key , int count )
4343 {
4444 var handler = new HandlerCollection ( ) ;
4545 var sub = ( IJsonRpcHandler ) TextDocumentSyncHandlerExtensions . With ( DocumentSelector . ForPattern ( "**/*.something" ) ) ;
@@ -49,6 +49,50 @@ public void Should_Contain_AllDefinedTextDocumentSyncMethods(Type requestHandler
4949 handler . _handlers . Count . Should ( ) . Be ( count ) ;
5050 }
5151
52+ [ Theory ]
53+ [ InlineData ( "exit" , 4 ) ]
54+ [ InlineData ( "shutdown" , 4 ) ]
55+ [ InlineData ( "initialized" , 4 ) ]
56+ [ InlineData ( "initialize" , 4 ) ]
57+ public void Should_Contain_AllDefinedLanguageServerMethods ( string key , int count )
58+ {
59+ var handler = new HandlerCollection ( ) ;
60+ handler . Add (
61+ Substitute . For < IInitializeHandler > ( ) ,
62+ Substitute . For < IInitializedHandler > ( ) ,
63+ Substitute . For < IExitHandler > ( ) ,
64+ Substitute . For < IShutdownHandler > ( )
65+ ) ;
66+ handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
67+ handler . _handlers . Count . Should ( ) . Be ( count ) ;
68+ }
69+
70+ [ Theory ]
71+ [ InlineData ( "exit" , 4 ) ]
72+ [ InlineData ( "shutdown" , 4 ) ]
73+ [ InlineData ( "initialized" , 4 ) ]
74+ [ InlineData ( "initialize" , 4 ) ]
75+ public void Should_Contain_AllDefinedLanguageServerMethods_GivenDuplicates ( string key , int count )
76+ {
77+ var handler = new HandlerCollection ( ) ;
78+ handler . Add (
79+ Substitute . For < IInitializeHandler > ( ) ,
80+ Substitute . For < IInitializedHandler > ( ) ,
81+ Substitute . For < IExitHandler > ( ) ,
82+ Substitute . For < IShutdownHandler > ( ) ,
83+ Substitute . For < IInitializeHandler > ( ) ,
84+ Substitute . For < IInitializedHandler > ( ) ,
85+ Substitute . For < IExitHandler > ( ) ,
86+ Substitute . For < IShutdownHandler > ( ) ,
87+ Substitute . For < IInitializeHandler > ( ) ,
88+ Substitute . For < IInitializedHandler > ( ) ,
89+ Substitute . For < IExitHandler > ( ) ,
90+ Substitute . For < IShutdownHandler > ( )
91+ ) ;
92+ handler . _handlers . Should ( ) . Contain ( x => x . Method == key ) ;
93+ handler . _handlers . Count . Should ( ) . Be ( count ) ;
94+ }
95+
5296 [ Theory ]
5397 [ InlineData ( "textDocument/didOpen" , 8 ) ]
5498 [ InlineData ( "textDocument/didChange" , 8 ) ]
@@ -107,5 +151,22 @@ public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys(
107151 handler . _handlers . Should ( ) . Contain ( x => x . Method == key2 ) ;
108152 handler . _handlers . Count . Should ( ) . Be ( count ) ;
109153 }
154+
155+ [ Fact ]
156+ public void Should_BeAwesome ( )
157+ {
158+ var handler = new HandlerCollection ( ) ;
159+
160+ handler . Add (
161+ Substitute . For < IExitHandler > ( ) ,
162+ Substitute . For < IInitializeHandler > ( ) ,
163+ Substitute . For < IInitializedHandler > ( ) ,
164+ Substitute . For < IShutdownHandler > ( )
165+ ) ;
166+
167+ handler . _handlers . Should ( ) . Contain ( x => x . Method == "exit" ) ;
168+ handler . _handlers . Should ( ) . Contain ( x => x . Method == "shutdown" ) ;
169+ handler . _handlers . Count . Should ( ) . Be ( 4 ) ;
170+ }
110171 }
111172}
0 commit comments