@@ -185,4 +185,67 @@ public async Task SearchAsync_WithParallelQueryingDisabled_StillWorks()
185185 Assert . IsNotNull ( results ) ;
186186 Assert . IsTrue ( results . Any ( ) , "Should return results even with sequential querying" ) ;
187187 }
188+
189+ [ TestMethod ]
190+ public void GetBackendInfo_UsesConfiguredEndpointNames_WhenEndpointsProvided ( )
191+ {
192+ // Arrange
193+ var optionsWithEndpoints = new MultiBackendOptions
194+ {
195+ Enabled = true ,
196+ EnableParallelQuerying = true ,
197+ EnableResultDeduplication = true ,
198+ MaxConcurrentQueries = 5 ,
199+ BackendTimeoutSeconds = 30 ,
200+ WriteEndpoint = "primary_backend" ,
201+ Endpoints = new Dictionary < string , BackendEndpointOptions >
202+ {
203+ [ "primary_backend" ] = new ( ) { Enabled = true , BackendType = "mock" , Priority = 10 } ,
204+ [ "secondary_backend" ] = new ( ) { Enabled = true , BackendType = "mock" , Priority = 5 }
205+ }
206+ } ;
207+
208+ var backends = new [ ] { _backend1 , _backend2 } ;
209+ var optionsWrapper = Options . Create ( optionsWithEndpoints ) ;
210+ var manager = new BackendManager ( backends , optionsWrapper , _logger ) ;
211+
212+ // Act
213+ var backendInfo = manager . GetBackendInfo ( ) ;
214+
215+ // Assert
216+ Assert . IsNotNull ( backendInfo ) ;
217+ var infoList = backendInfo . ToList ( ) ;
218+ Assert . AreEqual ( 2 , infoList . Count , "Should return info for all backends" ) ;
219+
220+ // Verify that configured endpoint names are used instead of generic backend_0, backend_1
221+ var backendIds = infoList . Select ( info => info . Id ) . OrderBy ( id => id ) . ToList ( ) ;
222+ CollectionAssert . AreEqual ( new [ ] { "primary_backend" , "secondary_backend" } , backendIds ,
223+ "Backend IDs should use configured endpoint names" ) ;
224+
225+ // Verify write endpoint identification works with configured names
226+ var writeBackend = infoList . Single ( info => info . IsWriteEndpoint ) ;
227+ Assert . AreEqual ( "primary_backend" , writeBackend . Id , "Primary backend should be identified as write endpoint" ) ;
228+ }
229+
230+ [ TestMethod ]
231+ public void GetBackendInfo_FallsBackToGenericNames_WhenNoEndpointsConfigured ( )
232+ {
233+ // Arrange - use original options without configured endpoints
234+ var backends = new [ ] { _backend1 , _backend2 } ;
235+ var optionsWrapper = Options . Create ( _options ) ;
236+ var manager = new BackendManager ( backends , optionsWrapper , _logger ) ;
237+
238+ // Act
239+ var backendInfo = manager . GetBackendInfo ( ) ;
240+
241+ // Assert
242+ Assert . IsNotNull ( backendInfo ) ;
243+ var infoList = backendInfo . ToList ( ) ;
244+ Assert . AreEqual ( 2 , infoList . Count , "Should return info for all backends" ) ;
245+
246+ // Verify that generic names are used as fallback
247+ var backendIds = infoList . Select ( info => info . Id ) . OrderBy ( id => id ) . ToList ( ) ;
248+ CollectionAssert . AreEqual ( new [ ] { "backend_0" , "backend_1" } , backendIds ,
249+ "Backend IDs should fall back to generic names when no endpoints configured" ) ;
250+ }
188251}
0 commit comments