mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 01:25:42 -05:00
Schema compare cancel operation (#826)
* First cut of schema compare cancel (private nuget) * Update Dacfx nuget to a published version
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
|
||||
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="$(SmoPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="150.4316.1-preview" />
|
||||
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="150.4451.1-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
|
||||
@@ -626,6 +626,56 @@ CREATE TABLE [dbo].[table3]
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the schema compare cancel
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void SchemaCompareCancelCompareOperation()
|
||||
{
|
||||
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
|
||||
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
|
||||
SqlTestDb targetDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, TargetScript, "SchemaCompareTarget");
|
||||
|
||||
try
|
||||
{
|
||||
SchemaCompareEndpointInfo sourceInfo = new SchemaCompareEndpointInfo();
|
||||
SchemaCompareEndpointInfo targetInfo = new SchemaCompareEndpointInfo();
|
||||
|
||||
sourceInfo.EndpointType = SchemaCompareEndpointType.Database;
|
||||
sourceInfo.DatabaseName = sourceDb.DatabaseName;
|
||||
targetInfo.EndpointType = SchemaCompareEndpointType.Database;
|
||||
targetInfo.DatabaseName = targetDb.DatabaseName;
|
||||
|
||||
var schemaCompareParams = new SchemaCompareParams
|
||||
{
|
||||
SourceEndpointInfo = sourceInfo,
|
||||
TargetEndpointInfo = targetInfo
|
||||
};
|
||||
|
||||
SchemaCompareOperation schemaCompareOperation = new SchemaCompareOperation(schemaCompareParams, result.ConnectionInfo, result.ConnectionInfo);
|
||||
schemaCompareOperation.schemaCompareStarted += (sender, e) => { schemaCompareOperation.Cancel(); };
|
||||
|
||||
try
|
||||
{
|
||||
Task cTask = Task.Factory.StartNew(() => schemaCompareOperation.Execute(TaskExecutionMode.Execute));
|
||||
cTask.Wait();
|
||||
Assert.False(cTask.IsCompletedSuccessfully, "schema compare task should not complete after cancel");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.NotNull(ex.InnerException);
|
||||
Assert.True(ex.InnerException is OperationCanceledException, $"Exception is expected to be Operation cancelled but actually is {ex.InnerException}");
|
||||
}
|
||||
|
||||
Assert.Null(schemaCompareOperation.ComparisonResult.Differences);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sourceDb.Cleanup();
|
||||
targetDb.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateSchemaCompareWithExcludeIncludeResults(SchemaCompareOperation schemaCompareOperation)
|
||||
{
|
||||
schemaCompareOperation.Execute(TaskExecutionMode.Execute);
|
||||
@@ -732,7 +782,6 @@ CREATE TABLE [dbo].[table3]
|
||||
Assert.True(initialScript.Length == afterIncludeScript.Length, $"Changes should be same as inital since we included what we excluded, before {initialScript}, now {afterIncludeScript}");
|
||||
}
|
||||
|
||||
|
||||
private async Task CreateAndOpenScmp(SchemaCompareEndpointType sourceEndpointType, SchemaCompareEndpointType targetEndpointType)
|
||||
{
|
||||
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareOpenScmpSource");
|
||||
|
||||
Reference in New Issue
Block a user