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:
Udeesha Gautam
2019-08-09 14:25:47 -07:00
committed by GitHub
parent d42e3626cb
commit 68145d5e7c
9 changed files with 177 additions and 24 deletions

View File

@@ -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()