Applying Changes to SQL Database Projects and Using Projects in Comparison (#1282)

* passing initial testing

* update local project from database

* update local project

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* update project from database

* Bump .net version

* PR feedback

Co-authored-by: Noureldine Yehia <t-nyehia@microsoft.com>
This commit is contained in:
Benjin Dubishar
2021-11-04 21:36:59 -04:00
committed by GitHub
parent eda47bc0a4
commit 6acda6e1e6
12 changed files with 1036 additions and 103 deletions

View File

@@ -14,27 +14,34 @@ using NUnit.Framework;
using System;
using System.IO;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
using System.Collections.Generic;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
internal static class SchemaCompareTestUtils
{
internal static void VerifyAndCleanup(string filePath)
internal static void VerifyAndCleanup(string path)
{
// Verify it was created
Assert.True(File.Exists(filePath), $"File {filePath} was expected to exist but did not");
// verify it was created...
Assert.True(File.Exists(path) || Directory.Exists(path), $"File or directory {path} was expected to exist but did not");
// Remove the file
if (File.Exists(filePath))
FileAttributes attr = File.GetAttributes(path);
// ...then clean it up
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
{
File.Delete(filePath);
new DirectoryInfo(path).Delete(recursive: true);
}
else
{
File.Delete(path);
}
}
internal static string CreateDacpac(SqlTestDb testdb)
{
var result = GetLiveAutoCompleteTestObjects();
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest");
string folderPath = Path.Combine(Path.GetTempPath(), "SchemaCompareTest");
Directory.CreateDirectory(folderPath);
var extractParams = new ExtractParams
@@ -52,6 +59,34 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
return extractParams.PackageFilePath;
}
internal static string CreateProject(SqlTestDb testdb, string projectName)
{
var result = GetLiveAutoCompleteTestObjects();
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest", projectName);
Directory.CreateDirectory(folderPath);
File.Create(Path.Combine(folderPath, projectName + ".sqlproj")).Close();
var extractParams = new ExtractParams
{
DatabaseName = testdb.DatabaseName,
ExtractTarget = DacExtractTarget.Flat,
PackageFilePath = folderPath,
ApplicationName = "test",
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new();
ExtractOperation operation = new(extractParams, result.ConnectionInfo);
service.PerformOperation(operation, TaskExecutionMode.Execute);
return folderPath;
}
internal static string[] GetProjectScripts(string projectPath)
{
return Directory.GetFiles(projectPath, "*.sql", SearchOption.AllDirectories);
}
internal static string CreateScmpPath()
{
var result = GetLiveAutoCompleteTestObjects();