33using KustoSchemaTools . Parser ;
44using Microsoft . Extensions . Logging ;
55using Moq ;
6- using System . Collections . Generic ;
7- using System . IO ;
8- using System . Threading . Tasks ;
9- using Xunit ;
10- using System . Data ;
11- using System ;
12- using System . Linq ;
136using Kusto . Data . Common ;
147
158namespace KustoSchemaTools . Tests
@@ -28,10 +21,9 @@ public KustoClusterOrchestratorTests()
2821 kustoClusterHandlerFactoryMock = new Mock < IKustoClusterHandlerFactory > ( ) ;
2922 yamlClusterHandlerFactoryMock = new Mock < IYamlClusterHandlerFactory > ( ) ;
3023
31- // Create mock for KustoClusterHandler
32- var kustoClientMock = new Mock < KustoClient > ( "test.eastus" ) ;
24+ var adminClientMock = new Mock < ICslAdminProvider > ( ) ;
3325 var kustoLoggerMock = new Mock < ILogger < KustoClusterHandler > > ( ) ;
34- kustoHandlerMock = new Mock < KustoClusterHandler > ( kustoClientMock . Object , kustoLoggerMock . Object , "test" , "test.eastus" ) ;
26+ kustoHandlerMock = new Mock < KustoClusterHandler > ( adminClientMock . Object , kustoLoggerMock . Object , "test" , "test.eastus" ) ;
3527
3628 orchestrator = new KustoClusterOrchestrator (
3729 loggerMock . Object ,
@@ -57,12 +49,10 @@ private Clusters CreateClustersWithCapacityPolicy(ClusterCapacityPolicy? capacit
5749
5850 private void SetupMockHandler ( Cluster kustoCluster )
5951 {
60- // Configure the handler factory to return our mock handler
6152 kustoClusterHandlerFactoryMock
6253 . Setup ( f => f . Create ( "test" , "test.eastus" ) )
6354 . Returns ( kustoHandlerMock . Object ) ;
6455
65- // Set up the mock handler to return our test cluster
6656 kustoHandlerMock
6757 . Setup ( h => h . LoadAsync ( ) )
6858 . ReturnsAsync ( kustoCluster ) ;
@@ -106,8 +96,7 @@ private Clusters CreateMultipleClusters()
10696
10797 private void SetupMultipleClusterMocks ( )
10898 {
109- // Mock for cluster1
110- var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "cluster1.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "cluster1" , "cluster1.eastus" ) ;
99+ var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "cluster1" , "cluster1.eastus" ) ;
111100 var kustoCluster1 = new Cluster
112101 {
113102 Name = "cluster1" ,
@@ -128,8 +117,7 @@ private void SetupMultipleClusterMocks()
128117 . Setup ( h => h . LoadAsync ( ) )
129118 . ReturnsAsync ( kustoCluster1 ) ;
130119
131- // Mock for cluster2 - same as config, no changes
132- var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "cluster2.westus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "cluster2" , "cluster2.westus" ) ;
120+ var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "cluster2" , "cluster2.westus" ) ;
133121 var kustoCluster2 = new Cluster
134122 {
135123 Name = "cluster2" ,
@@ -404,7 +392,7 @@ public async Task GenerateChangesFromFileAsync_ValidYamlFile_ReturnsChanges()
404392 . Returns ( new YamlClusterHandler ( yamlFilePath ) ) ;
405393
406394 // Set up mocks for the clusters defined in the YAML file
407- var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "test1.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
395+ var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
408396 var kustoCluster1 = new Cluster
409397 {
410398 Name = "test1" ,
@@ -425,7 +413,7 @@ public async Task GenerateChangesFromFileAsync_ValidYamlFile_ReturnsChanges()
425413 . Setup ( h => h . LoadAsync ( ) )
426414 . ReturnsAsync ( kustoCluster1 ) ;
427415
428- var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "test2.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test2" , "test2.eastus" ) ;
416+ var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test2" , "test2.eastus" ) ;
429417 var kustoCluster2 = new Cluster
430418 {
431419 Name = "test2" ,
@@ -568,8 +556,8 @@ public async Task GenerateChangesFromFileAsync_VerifyLoggingCalled()
568556 . Returns ( new YamlClusterHandler ( yamlFilePath ) ) ;
569557
570558 // Set up a simple mock for the clusters
571- var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "test1.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
572- var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "test2.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test2" , "test2.eastus" ) ;
559+ var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
560+ var kustoHandler2Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test2" , "test2.eastus" ) ;
573561
574562 kustoClusterHandlerFactoryMock
575563 . Setup ( f => f . Create ( "test1" , "test1.eastus" ) )
@@ -639,7 +627,7 @@ public async Task GenerateChangesFromFileAsync_LoadAsyncThrowsException_Propagat
639627 . Setup ( f => f . Create ( yamlFilePath ) )
640628 . Returns ( new YamlClusterHandler ( yamlFilePath ) ) ;
641629
642- var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < KustoClient > ( "test1.eastus" ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
630+ var kustoHandler1Mock = new Mock < KustoClusterHandler > ( new Mock < ICslAdminProvider > ( ) . Object , new Mock < ILogger < KustoClusterHandler > > ( ) . Object , "test1" , "test1.eastus" ) ;
643631
644632 kustoClusterHandlerFactoryMock
645633 . Setup ( f => f . Create ( "test1" , "test1.eastus" ) )
0 commit comments