mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Feature/sqlcmd : Enable running scripts with SQLCMD variables - Part 1 (#839)
* Part1 : Changes to make cmdcmd script to work with parameters in script * Stop SQL intellisense for SQLCMD * Adding test for Intellisense handling of SQLCMD page * Removing unintentional spacing changes caused by formatting * Updating with smaller CR comments. Will discuss regarding script vs other options in batch info * Removing unintentional change * Adding latest PR comments
This commit is contained in:
@@ -338,6 +338,42 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify whether the batchParser execute SqlCmd successfully
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void VerifyRunSqlCmd()
|
||||
{
|
||||
using (ExecutionEngine executionEngine = new ExecutionEngine())
|
||||
{
|
||||
const string sqlCmdQuery = @"
|
||||
:setvar __var1 1
|
||||
:setvar __var2 2
|
||||
:setvar __IsSqlCmdEnabled " + "\"True\"" + @"
|
||||
GO
|
||||
IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
|
||||
BEGIN
|
||||
PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
|
||||
SET NOEXEC ON;
|
||||
END
|
||||
GO
|
||||
select $(__var1) + $(__var2) as col
|
||||
GO";
|
||||
|
||||
using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
|
||||
{
|
||||
con.Open();
|
||||
var condition = new ExecutionEngineConditions() { IsSqlCmd = true };
|
||||
TestExecutor testExecutor = new TestExecutor(sqlCmdQuery, con, condition);
|
||||
testExecutor.Run();
|
||||
|
||||
Assert.True(testExecutor.ResultCountQueue.Count >= 1);
|
||||
Assert.True(testExecutor.ErrorMessageQueue.Count == 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verify whether the executionEngine execute Batch
|
||||
[Fact]
|
||||
public void VerifyExecuteBatch()
|
||||
|
||||
Reference in New Issue
Block a user