@@ -147,6 +147,84 @@ internal void GetQueryClient_Returns_Client_With_Connection_And_Database_Without
147147 Assert . Equal ( databaseName , client . DefaultDatabaseName ) ;
148148 }
149149
150+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : true ) ]
151+ internal void GetQueryClient_Returns_Client_With_ConnectionString_And_Database_With_Credential (
152+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
153+ AtcKustoOptions options ,
154+ KustoClientProvider sut )
155+ {
156+ // Arrange
157+ options . HostAddress = null ;
158+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
159+ monitor . Get ( null ) . Returns ( options ) ;
160+
161+ // Act
162+ var client = sut . GetQueryClient ( ) ;
163+
164+ // Assert
165+ Assert . NotNull ( client ) ;
166+ Assert . Equal ( options . DatabaseName , client . DefaultDatabaseName ) ;
167+ }
168+
169+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : false ) ]
170+ internal void GetQueryClient_Returns_Client_With_ConnectionString_And_Database_Without_Credential (
171+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
172+ AtcKustoOptions options ,
173+ KustoClientProvider sut )
174+ {
175+ // Arrange
176+ options . HostAddress = null ;
177+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
178+ monitor . Get ( null ) . Returns ( options ) ;
179+
180+ // Act
181+ var client = sut . GetQueryClient ( ) ;
182+
183+ // Assert
184+ Assert . NotNull ( client ) ;
185+ Assert . Equal ( options . DatabaseName , client . DefaultDatabaseName ) ;
186+ }
187+
188+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : true ) ]
189+ internal void GetQueryClient_Returns_Client_With_ConnectionString_With_Credential (
190+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
191+ AtcKustoOptions options ,
192+ KustoClientProvider sut )
193+ {
194+ // Arrange
195+ options . HostAddress = null ;
196+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
197+ options . DatabaseName = null ;
198+ monitor . Get ( null ) . Returns ( options ) ;
199+
200+ // Act
201+ var client = sut . GetQueryClient ( ) ;
202+
203+ // Assert
204+ Assert . NotNull ( client ) ;
205+ Assert . Equal ( "NetDefaultDB" , client . DefaultDatabaseName ) ; // Apparently the library still sets a default database name
206+ }
207+
208+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : false ) ]
209+ internal void GetQueryClient_Returns_Client_With_ConnectionString_Without_Credential (
210+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
211+ AtcKustoOptions options ,
212+ KustoClientProvider sut )
213+ {
214+ // Arrange
215+ options . HostAddress = null ;
216+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
217+ options . DatabaseName = null ;
218+ monitor . Get ( null ) . Returns ( options ) ;
219+
220+ // Act
221+ var client = sut . GetQueryClient ( ) ;
222+
223+ // Assert
224+ Assert . NotNull ( client ) ;
225+ Assert . Equal ( "NetDefaultDB" , client . DefaultDatabaseName ) ; // Apparently the library still sets a default database name
226+ }
227+
150228 [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : true ) ]
151229 internal void GetAdminClient_Returns_Client_With_Credential (
152230 [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
@@ -289,4 +367,82 @@ internal void GetAdminClient_Returns_Client_With_Connection_And_Database_Without
289367 Assert . NotNull ( client ) ;
290368 Assert . Equal ( databaseName , client . DefaultDatabaseName ) ;
291369 }
370+
371+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : true ) ]
372+ internal void GetAdminClient_Returns_Client_With_ConnectionString_And_Database_With_Credential (
373+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
374+ AtcKustoOptions options ,
375+ KustoClientProvider sut )
376+ {
377+ // Arrange
378+ options . HostAddress = null ;
379+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
380+ monitor . Get ( null ) . Returns ( options ) ;
381+
382+ // Act
383+ var client = sut . GetAdminClient ( ) ;
384+
385+ // Assert
386+ Assert . NotNull ( client ) ;
387+ Assert . Equal ( options . DatabaseName , client . DefaultDatabaseName ) ;
388+ }
389+
390+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : false ) ]
391+ internal void GetAdminClient_Returns_Client_With_ConnectionString_And_Database_Without_Credential (
392+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
393+ AtcKustoOptions options ,
394+ KustoClientProvider sut )
395+ {
396+ // Arrange
397+ options . HostAddress = null ;
398+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
399+ monitor . Get ( null ) . Returns ( options ) ;
400+
401+ // Act
402+ var client = sut . GetAdminClient ( ) ;
403+
404+ // Assert
405+ Assert . NotNull ( client ) ;
406+ Assert . Equal ( options . DatabaseName , client . DefaultDatabaseName ) ;
407+ }
408+
409+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : true ) ]
410+ internal void GetAdminClient_Returns_Client_With_ConnectionString_With_Credential (
411+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
412+ AtcKustoOptions options ,
413+ KustoClientProvider sut )
414+ {
415+ // Arrange
416+ options . HostAddress = null ;
417+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
418+ options . DatabaseName = null ;
419+ monitor . Get ( null ) . Returns ( options ) ;
420+
421+ // Act
422+ var client = sut . GetAdminClient ( ) ;
423+
424+ // Assert
425+ Assert . NotNull ( client ) ;
426+ Assert . Equal ( "NetDefaultDB" , client . DefaultDatabaseName ) ; // Apparently the library still sets a default database name
427+ }
428+
429+ [ Theory , AutoNSubstituteDataWithAtcKustoOptions ( withCredential : false ) ]
430+ internal void GetAdminClient_Returns_Client_With_ConnectionString_Without_Credential (
431+ [ Frozen ] IOptionsMonitor < AtcKustoOptions > monitor ,
432+ AtcKustoOptions options ,
433+ KustoClientProvider sut )
434+ {
435+ // Arrange
436+ options . HostAddress = null ;
437+ options . ConnectionString = $ "https://{ Guid . NewGuid ( ) : N} .kusto.windows.net";
438+ options . DatabaseName = null ;
439+ monitor . Get ( null ) . Returns ( options ) ;
440+
441+ // Act
442+ var client = sut . GetAdminClient ( ) ;
443+
444+ // Assert
445+ Assert . NotNull ( client ) ;
446+ Assert . Equal ( "NetDefaultDB" , client . DefaultDatabaseName ) ; // Apparently the library still sets a default database name
447+ }
292448}
0 commit comments