1111using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
1212using Xunit ;
1313using HandlerCollection = OmniSharp . Extensions . LanguageServer . Server . HandlerCollection ;
14+ using System . Collections . Generic ;
1415
1516namespace Lsp . Tests
1617{
@@ -133,7 +134,8 @@ public void Should_Contain_AllDefinedMethods_OnLanguageServer(Type requestHandle
133134 var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
134135 if ( sub is IRegistration < TextDocumentRegistrationOptions > reg )
135136 reg . GetRegistrationOptions ( )
136- . Returns ( new TextDocumentRegistrationOptions ( ) {
137+ . Returns ( new TextDocumentRegistrationOptions ( )
138+ {
137139 DocumentSelector = new DocumentSelector ( )
138140 } ) ;
139141 handler . Add ( sub ) ;
@@ -150,13 +152,15 @@ public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys(
150152 var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
151153 if ( sub is IRegistration < TextDocumentRegistrationOptions > reg )
152154 reg . GetRegistrationOptions ( )
153- . Returns ( new TextDocumentRegistrationOptions ( ) {
155+ . Returns ( new TextDocumentRegistrationOptions ( )
156+ {
154157 DocumentSelector = new DocumentSelector ( )
155158 } ) ;
156159 var sub2 = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { requestHandler , type2 } , new object [ 0 ] ) ;
157160 if ( sub2 is IRegistration < TextDocumentRegistrationOptions > reg2 )
158161 reg2 . GetRegistrationOptions ( )
159- . Returns ( new TextDocumentRegistrationOptions ( ) {
162+ . Returns ( new TextDocumentRegistrationOptions ( )
163+ {
160164 DocumentSelector = new DocumentSelector ( )
161165 } ) ;
162166 handler . Add ( sub ) ;
@@ -172,12 +176,31 @@ public void Should_AllowSpecificHandlers_ToBeAdded(string method, Type handlerTy
172176 {
173177 var handler = new HandlerCollection ( ) ;
174178 var sub = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { handlerType } , new object [ 0 ] ) ;
175- var sub2 = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { handlerType } , new object [ 0 ] ) ;
179+ var sub2 = ( IJsonRpcHandler ) Substitute . For ( new Type [ ] { handlerType } , new object [ 0 ] ) ;
176180 handler . Add ( method , sub ) ;
177181 handler . Add ( method , sub2 ) ;
178182 handler . _handlers . Should ( ) . Contain ( x => x . Method == method ) ;
179183 handler . _handlers . Should ( ) . Contain ( x => x . Method == method ) ;
180184 handler . _handlers . Count . Should ( ) . Be ( 1 ) ;
181185 }
186+
187+ [ Theory ]
188+ [ MemberData ( nameof ( Should_DealWithClassesThatImplementMultipleHandlers_WithoutConflictingRegistrations_Data ) ) ]
189+ public void Should_DealWithClassesThatImplementMultipleHandlers_WithoutConflictingRegistrations ( string method , IJsonRpcHandler sub )
190+ {
191+ var handler = new HandlerCollection ( ) ;
192+ handler . Add ( sub ) ;
193+
194+ var descriptor = handler . _handlers . First ( x => x . Method == method ) ;
195+ descriptor . Key . Should ( ) . Be ( "default" ) ;
196+ }
197+
198+ public static IEnumerable < object [ ] > Should_DealWithClassesThatImplementMultipleHandlers_WithoutConflictingRegistrations_Data ( )
199+ {
200+ yield return new object [ ] {
201+ DocumentNames . CodeLensResolve ,
202+ Substitute . For ( new Type [ ] { typeof ( ICodeLensHandler ) , typeof ( ICodeLensResolveHandler ) } , new object [ 0 ] )
203+ } ;
204+ }
182205 }
183206}
0 commit comments