7
7
using OmniSharp . Extensions . LanguageServer . Protocol ;
8
8
using NSubstitute ;
9
9
using OmniSharp . Extensions . JsonRpc ;
10
+ using OmniSharp . Extensions . LanguageServer ;
10
11
using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
11
12
using Xunit ;
12
13
using HandlerCollection = OmniSharp . Extensions . LanguageServer . HandlerCollection ;
@@ -17,7 +18,6 @@ namespace Lsp.Tests
17
18
{
18
19
public class HandlerResolverTests
19
20
{
20
-
21
21
[ Theory ]
22
22
[ InlineData ( typeof ( IInitializeHandler ) , "initialize" , 1 ) ]
23
23
[ InlineData ( typeof ( IInitializedHandler ) , "initialized" , 1 ) ]
@@ -35,11 +35,11 @@ public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, in
35
35
}
36
36
37
37
[ 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 )
43
43
{
44
44
var handler = new HandlerCollection ( ) ;
45
45
var sub = ( IJsonRpcHandler ) TextDocumentSyncHandlerExtensions . With ( DocumentSelector . ForPattern ( "**/*.something" ) ) ;
@@ -49,6 +49,50 @@ public void Should_Contain_AllDefinedTextDocumentSyncMethods(Type requestHandler
49
49
handler . _handlers . Count . Should ( ) . Be ( count ) ;
50
50
}
51
51
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
+
52
96
[ Theory ]
53
97
[ InlineData ( "textDocument/didOpen" , 8 ) ]
54
98
[ InlineData ( "textDocument/didChange" , 8 ) ]
@@ -107,5 +151,22 @@ public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys(
107
151
handler . _handlers . Should ( ) . Contain ( x => x . Method == key2 ) ;
108
152
handler . _handlers . Count . Should ( ) . Be ( count ) ;
109
153
}
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
+ }
110
171
}
111
172
}
0 commit comments