mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Removing script as feature from service layer to sqlcore (#2189)
This commit is contained in:
@@ -7,9 +7,8 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.CoreSql.ObjectExplorer;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions;
|
||||
using Microsoft.SqlTools.SqlCore.ObjectExplorer;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
|
||||
{
|
||||
public class AsyncScriptAsScriptingOperationTests
|
||||
{
|
||||
public static IEnumerable<TestCaseData> ScriptAsTestCases
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new TestCaseData(
|
||||
"CREATE TABLE testTable1 (c1 int)",
|
||||
new ScriptingParams()
|
||||
{
|
||||
ScriptDestination = "ToEditor",
|
||||
ScriptingObjects = new List<ScriptingObject>()
|
||||
{
|
||||
new ScriptingObject()
|
||||
{
|
||||
Name = "testTable1",
|
||||
Schema = "dbo",
|
||||
Type = "Table",
|
||||
|
||||
}
|
||||
},
|
||||
Operation = ScriptingOperationType.Select,
|
||||
ScriptOptions = new ScriptOptions()
|
||||
{
|
||||
ScriptCreateDrop = "ScriptSelect"
|
||||
}
|
||||
},
|
||||
new List<string>() { "SELECT TOP (1000) [c1]" });
|
||||
|
||||
yield return new TestCaseData(
|
||||
"CREATE TABLE testTable1 (c1 int)",
|
||||
new ScriptingParams()
|
||||
{
|
||||
ScriptDestination = "ToEditor",
|
||||
ScriptingObjects = new List<ScriptingObject>()
|
||||
{
|
||||
new ScriptingObject()
|
||||
{
|
||||
Name = "testTable1",
|
||||
Schema = "dbo",
|
||||
Type = "Table"
|
||||
}
|
||||
},
|
||||
Operation = ScriptingOperationType.Delete,
|
||||
ScriptOptions = new ScriptOptions()
|
||||
{
|
||||
ScriptCreateDrop = "ScriptDrop"
|
||||
}
|
||||
},
|
||||
new List<string> { "DROP TABLE [dbo].[testTable1]" }
|
||||
);
|
||||
|
||||
yield return new TestCaseData(
|
||||
@"CREATE TABLE testTable1 (c1 int)
|
||||
GO
|
||||
CREATE CLUSTERED INDEX [ClusteredIndex-1] ON [dbo].[testTable1]
|
||||
(
|
||||
[c1] ASC
|
||||
)
|
||||
GO
|
||||
",
|
||||
new ScriptingParams()
|
||||
{
|
||||
ScriptDestination = "ToEditor",
|
||||
ScriptingObjects = new List<ScriptingObject>()
|
||||
{
|
||||
new ScriptingObject()
|
||||
{
|
||||
Name = "testTable1",
|
||||
Schema = "dbo",
|
||||
Type = "Table"
|
||||
}
|
||||
},
|
||||
Operation = ScriptingOperationType.Create,
|
||||
ScriptOptions = new ScriptOptions()
|
||||
{
|
||||
ScriptCreateDrop = "ScriptCreate"
|
||||
}
|
||||
},
|
||||
new List<string> { "CREATE TABLE [dbo].[testTable1]", "CREATE CLUSTERED INDEX [ClusteredIndex-1] ON [dbo].[testTable1]" }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource("ScriptAsTestCases")]
|
||||
public async Task TestCommonScenarios(
|
||||
string query, ScriptingParams scriptingParams, List<string> expectedScriptContents)
|
||||
{
|
||||
var testDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, query, "ScriptingTests");
|
||||
scriptingParams.ConnectionString = testDb.ConnectionString;
|
||||
|
||||
var actualScript = await AsyncScriptAsScriptingOperation.GetScriptAsScript(scriptingParams, null);
|
||||
|
||||
foreach(var expectedStr in expectedScriptContents)
|
||||
{
|
||||
Assert.That(actualScript, Does.Contain(expectedStr));
|
||||
}
|
||||
|
||||
await testDb.CleanupAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
|
||||
{
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
|
||||
@@ -20,6 +20,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
|
||||
using Microsoft.SqlTools.ServiceLayer.TestDriver.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
|
||||
@@ -12,6 +12,8 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
using NUnit.Framework;
|
||||
using Assert = NUnit.Framework.Assert;
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting;
|
||||
using Microsoft.SqlTools.SqlCore.Scripting.Contracts;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Scripting
|
||||
@@ -451,7 +452,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Scripting
|
||||
{
|
||||
for (int i = 0; i < TestObjects.Length; i++)
|
||||
{
|
||||
Assert.AreEqual(Scripter.ScriptingUtils.QuoteObjectName(TestObjects[i]), ExpectedObjects[i]);
|
||||
Assert.AreEqual(ScriptingHelper.QuoteObjectName(TestObjects[i]), ExpectedObjects[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user