Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareTestUtils.cs
udeeshagautam f8cd355e61 Feature/schemacompare Exclude-Include and Options enhancement (#799)
* Initial code for Including/Excluding individual changes (no tests added yet)

* Adding Exclude include tests. Default options call and additional options tests.

* Taking PR comments

* Retry in test for reliability
2019-04-25 22:07:00 -07:00

73 lines
2.5 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.DacFx;
using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using NUnit.Framework;
using System;
using System.IO;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
internal static class SchemaCompareTestUtils
{
internal static void VerifyAndCleanup(string filePath)
{
// Verify it was created
Assert.True(File.Exists(filePath));
// Remove the file
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
internal static string CreateDacpac(SqlTestDb testdb)
{
var result = GetLiveAutoCompleteTestObjects();
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest");
Directory.CreateDirectory(folderPath);
var extractParams = new ExtractParams
{
DatabaseName = testdb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", testdb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new DacFxService();
ExtractOperation operation = new ExtractOperation(extractParams, result.ConnectionInfo);
service.PerformOperation(operation);
return extractParams.PackageFilePath;
}
internal static LiveConnectionHelper.TestConnectionResult GetLiveAutoCompleteTestObjects()
{
// Adding retry for reliability - otherwise it caused test to fail in lab
TestConnectionResult result = null;
int retry = 3;
while (retry > 0)
{
result = LiveConnectionHelper.InitLiveConnectionInfo();
if (result != null && result.ConnectionInfo != null)
{
return result;
}
System.Threading.Thread.Sleep(1000);
retry--;
}
return result;
}
}
}