Convert most tools service tests to nunit (#1037)

* Remove xunit dependency from testdriver

* swap expected/actual as needed

* Convert Test.Common to nunit

* port hosting unit tests to nunit

* port batchparser integration tests to nunit

* port testdriver.tests to nunit

* fix target to copy dependency

* port servicelayer unittests to nunit

* more unit test fixes

* port integration tests to nunit

* fix test method type

* try using latest windows build for PRs

* reduce test memory use
This commit is contained in:
David Shiflet
2020-08-05 13:43:14 -04:00
committed by GitHub
parent bf4911795f
commit 839acf67cd
205 changed files with 4146 additions and 4329 deletions

View File

@@ -3,6 +3,4 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: NUnit.Framework.NonParallelizable]

View File

@@ -7,10 +7,11 @@ using System;
using System.IO;
using Microsoft.SqlTools.ServiceLayer.BatchParser;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
[TestFixture]
public class BatchParserSqlCmdTests : IDisposable
{
private BatchParserSqlCmd bpcmd;
@@ -41,62 +42,62 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
}
[Fact]
[Test]
public void CheckSetVariable()
{
Assert.Equal(bpcmd.InternalVariables.Count, 3);
Assert.AreEqual(3, bpcmd.InternalVariables.Count);
bpcmd.SetVariable(testPOS, "variable4", "test4");
bpcmd.SetVariable(testPOS, "variable5", "test5");
bpcmd.SetVariable(testPOS, "variable6", "test6");
Assert.Equal(bpcmd.InternalVariables.Count, 6);
Assert.AreEqual(6, bpcmd.InternalVariables.Count);
}
[Fact]
[Test]
public void CheckSetNullValueVariable()
{
Assert.Equal(bpcmd.InternalVariables.Count, 3);
Assert.AreEqual(3, bpcmd.InternalVariables.Count);
bpcmd.SetVariable(testPOS, "variable4", "test4");
Assert.Equal(bpcmd.InternalVariables.Count, 4);
Assert.AreEqual(4, bpcmd.InternalVariables.Count);
bpcmd.SetVariable(testPOS, "variable4", null);
Assert.Equal(bpcmd.InternalVariables.Count, 3);
Assert.AreEqual(3, bpcmd.InternalVariables.Count);
}
[Fact]
[Test]
public void CheckGetVariable()
{
string value = bpcmd.GetVariable(testPOS, "variable1");
Assert.Equal("test1", value);
Assert.AreEqual("test1", value);
value = bpcmd.GetVariable(testPOS, "variable2");
Assert.Equal("test2", value);
Assert.AreEqual("test2", value);
value = bpcmd.GetVariable(testPOS, "variable3");
Assert.Equal("test3", value);
Assert.AreEqual("test3", value);
}
[Fact]
[Test]
public void CheckGetNullVariable()
{
Assert.Null(bpcmd.GetVariable(testPOS, "variable6"));
}
[Fact]
[Test]
public void CheckInclude()
{
TextReader textReader = null;
string outString = "out";
var result = bpcmd.Include(null, out textReader, out outString);
Assert.Equal(result, BatchParserAction.Abort);
Assert.AreEqual(BatchParserAction.Abort, result);
}
[Fact]
[Test]
public void CheckOnError()
{
var errorActionChanged = bpcmd.ErrorActionChanged;
var action = new OnErrorAction();
var result = bpcmd.OnError(null, action);
Assert.Equal(result, BatchParserAction.Continue);
Assert.AreEqual(BatchParserAction.Continue, result);
}
[Fact]
[Test]
public void CheckConnectionChangedDelegate()
{
var initial = bpcmd.ConnectionChanged;
@@ -104,7 +105,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
Assert.Null(bpcmd.ConnectionChanged);
}
[Fact]
[Test]
public void CheckVariableSubstitutionDisabled()
{
bpcmd.DisableVariableSubstitution();

View File

@@ -14,12 +14,13 @@ using Microsoft.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Text;
using Xunit;
using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Connection;
using System.Threading.Tasks;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
[TestFixture]
public class BatchParserTests : BaselinedTest
{
public BatchParserTests()
@@ -34,7 +35,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
TestInitialize();
}
[Fact]
[Test]
public void VerifyThrowOnUnresolvedVariable()
{
string script = "print '$(NotDefined)'";
@@ -59,7 +60,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
/// Variable parameter in powershell: Specifies, as a string array, a sqlcmd scripting variable
/// for use in the sqlcmd script, and sets a value for the variable.
/// </summary>
[Fact]
[Test]
public void VerifyVariableResolverUsingVaribleParameter()
{
string query = @" Invoke-Sqlcmd -Query ""SELECT `$(calcOne)"" -Variable ""calcOne = 10 + 20"" ";
@@ -79,7 +80,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
// Verify the starting identifier of Both parameter and variable are same.
[Fact]
[Test]
public void VerifyVariableResolverIsStartIdentifierChar()
{
// instead of using variable calcOne, I purposely used In-variable 0alcOne
@@ -100,7 +101,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
// Verify all the characters inside variable are valid Identifier.
[Fact]
[Test]
public void VerifyVariableResolverIsIdentifierChar()
{
// instead of using variable calcOne, I purposely used In-variable 0alcOne
@@ -121,7 +122,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
// Verify the execution by passing long value , Except a exception.
[Fact]
[Test]
public void VerifyInvalidNumber()
{
string query = @" SELECT 1+1
@@ -144,7 +145,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
// Verify the Batch execution is executed successfully.
[Fact]
[Test]
public void VerifyExecute()
{
Batch batch = new Batch(sqlText: "SELECT 1+1", isResultExpected: true, execTimeout: 15);
@@ -152,13 +153,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo))
{
var executionResult = batch.Execute(sqlConn, ShowPlanType.AllShowPlan);
Assert.Equal<ScriptExecutionResult>(ScriptExecutionResult.Success, executionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executionResult);
}
}
// Verify the exeception is handled by passing invalid keyword.
[Fact]
[Test]
public void VerifyHandleExceptionMessage()
{
Batch batch = new Batch(sqlText: "SEL@ECT 1+1", isResultExpected: true, execTimeout: 15);
@@ -169,11 +170,11 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
ScriptExecutionResult finalResult = (batch.RowsAffected > 0) ? ScriptExecutionResult.Success : ScriptExecutionResult.Failure;
Assert.Equal<ScriptExecutionResult>(finalResult, ScriptExecutionResult.Failure);
Assert.AreEqual(ScriptExecutionResult.Failure, finalResult);
}
// Verify the passing query has valid text.
[Fact]
[Test]
public void VerifyHasValidText()
{
Batch batch = new Batch(sqlText: null, isResultExpected: true, execTimeout: 15);
@@ -185,11 +186,11 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
}
finalResult = (batch.RowsAffected > 0) ? ScriptExecutionResult.Success : ScriptExecutionResult.Failure;
Assert.Equal<ScriptExecutionResult>(finalResult, ScriptExecutionResult.Failure);
Assert.AreEqual(ScriptExecutionResult.Failure, finalResult);
}
// Verify the cancel functionality is working fine.
[Fact]
[Test]
public void VerifyCancel()
{
ScriptExecutionResult result = ScriptExecutionResult.All;
@@ -200,14 +201,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
batch.Cancel();
result = batch.Execute(sqlConn, ShowPlanType.AllShowPlan);
}
Assert.Equal<ScriptExecutionResult>(result, ScriptExecutionResult.Cancel);
Assert.AreEqual(ScriptExecutionResult.Cancel, result);
}
//
/// <summary>
/// Verify whether lexer can consume token for SqlCmd variable
/// </summary>
[Fact]
[Test]
public void VerifyLexerSetState()
{
try
@@ -229,7 +230,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
// This test case is to verify that, Powershell's Invoke-SqlCmd handles ":!!if" in an inconsistent way
// Inconsistent way means, instead of throwing an exception as "Command Execute is not supported." it was throwing "Incorrect syntax near ':'."
[Fact]
[Test]
public void VerifySqlCmdExecute()
{
string query = ":!!if exist foo.txt del foo.txt";
@@ -247,12 +248,12 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
var exception = Assert.Throws<BatchParserException>(() => p.Parse());
// Verify the message should be "Command Execute is not supported."
Assert.Equal("Command Execute is not supported.", exception.Message);
Assert.AreEqual("Command Execute is not supported.", exception.Message);
}
}
// This test case is to verify that, Lexer type for :!!If was set to "Text" instead of "Execute"
[Fact]
[Test]
public void VerifyLexerTypeOfSqlCmdIFisExecute()
{
string query = ":!!if exist foo.txt del foo.txt";
@@ -264,33 +265,26 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
type = lexer.CurrentTokenType;
}
// we are expecting the lexer type should to be Execute.
Assert.Equal("Execute", type.ToString());
Assert.AreEqual("Execute", type.ToString());
}
// Verify the custom exception functionality by raising user defined error.
[Fact]
[Test]
public void VerifyCustomBatchParserException()
{
string message = "This is userDefined Error";
Token token = new Token(LexerTokenType.Text, new PositionStruct(), new PositionStruct(), message, "test");
BatchParserException batchParserException = new BatchParserException(ErrorCode.VariableNotDefined, token, message);
try
{
throw new BatchParserException(ErrorCode.UnrecognizedToken, token, "test");
}
catch (Exception ex)
{
Assert.Equal(batchParserException.ErrorCode.ToString(), ErrorCode.VariableNotDefined.ToString());
Assert.Equal(message, batchParserException.Text);
Assert.Equal(LexerTokenType.Text.ToString(), batchParserException.TokenType.ToString());
Assert.IsType<BatchParserException>(ex);
}
BatchParserException batchParserException = new BatchParserException(ErrorCode.VariableNotDefined, token, message);
Assert.AreEqual(batchParserException.ErrorCode.ToString(), ErrorCode.VariableNotDefined.ToString());
Assert.AreEqual(message, batchParserException.Text);
Assert.AreEqual(LexerTokenType.Text.ToString(), batchParserException.TokenType.ToString());
}
// Verify whether the executionEngine execute script
[Fact]
[Test]
public void VerifyExecuteScript()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -305,13 +299,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
ScriptExecutionResult result = (testExecutor.ExecutionResult == ScriptExecutionResult.Success) ? ScriptExecutionResult.Success : ScriptExecutionResult.Failure;
Assert.Equal<ScriptExecutionResult>(ScriptExecutionResult.Success, result);
Assert.AreEqual(ScriptExecutionResult.Success, result);
}
}
}
// Verify whether the batchParser execute SqlCmd.
//[Fact] // This Testcase should execute and pass, But it is failing now.
//[Test] // This Testcase should execute and pass, But it is failing now.
public void VerifyIsSqlCmd()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -330,7 +324,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
/// <summary>
/// Verify whether the batchParser execute SqlCmd successfully
/// </summary>
[Fact]
[Test]
public void VerifyRunSqlCmd()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -365,7 +359,7 @@ GO";
/// <summary>
/// Verify whether the batchParser parsed :connect command successfully
/// </summary>
[Fact]
[Test]
public void VerifyConnectSqlCmd()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -374,14 +368,15 @@ GO";
string serverName = liveConnection.ConnectionInfo.ConnectionDetails.ServerName;
string userName = liveConnection.ConnectionInfo.ConnectionDetails.UserName;
string password = liveConnection.ConnectionInfo.ConnectionDetails.Password;
var credentials = string.IsNullOrEmpty(userName) ? string.Empty : $"-U {userName} -P {password}";
string sqlCmdQuery = $@"
:Connect {serverName} -U {userName} -P {password}
:Connect {serverName}{credentials}
GO
select * from sys.databases where name = 'master'
GO";
string sqlCmdQueryIncorrect = $@"
:Connect {serverName} -u {userName} -p {password}
:Connect {serverName} -u uShouldbeUpperCase -p pShouldbeUpperCase
GO
select * from sys.databases where name = 'master'
GO";
@@ -390,17 +385,23 @@ GO";
using (TestExecutor testExecutor = new TestExecutor(sqlCmdQuery, sqlConn, condition))
{
testExecutor.Run();
Assert.True(testExecutor.ParserExecutionError == false, "Parse Execution error should be false");
Assert.True(testExecutor.ResultCountQueue.Count == 1, $"Unexpected number of ResultCount items - expected 1 but got {testExecutor.ResultCountQueue.Count}");
Assert.True(testExecutor.ErrorMessageQueue.Count == 0, $"Unexpected error messages from test executor : {string.Join(Environment.NewLine, testExecutor.ErrorMessageQueue)}");
Assert.Multiple(() =>
{
Assert.That(testExecutor.ParserExecutionError, Is.False, "Parse Execution error should be false");
Assert.That(testExecutor.ResultCountQueue.Count, Is.EqualTo(1), "Unexpected number of ResultCount items");
Assert.That(testExecutor.ErrorMessageQueue, Is.Empty, "Unexpected error messages from test executor");
});
}
using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo))
using (TestExecutor testExecutor = new TestExecutor(sqlCmdQueryIncorrect, sqlConn, condition))
{
testExecutor.Run();
Assert.True(testExecutor.ParserExecutionError == true, "Parse Execution error should be true");
Assert.Multiple(() =>
{
Assert.True(testExecutor.ParserExecutionError, "Parse Execution error should be true");
Assert.That(testExecutor.ErrorMessageQueue, Has.Member("Incorrect syntax was encountered while -u was being parsed."), "error message expected");
});
}
}
}
@@ -408,7 +409,7 @@ GO";
/// <summary>
/// Verify whether the batchParser parsed :on error successfully
/// </summary>
[Fact]
[Test]
public void VerifyOnErrorSqlCmd()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -443,7 +444,7 @@ GO";
/// <summary>
/// Verify whether the batchParser parses Include command i.e. :r successfully
/// </summary>
[Fact]
[Test]
public void VerifyIncludeSqlCmd()
{
string file = "VerifyIncludeSqlCmd_test.sql";
@@ -486,7 +487,7 @@ GO";
}
// Verify whether the executionEngine execute Batch
[Fact]
[Test]
public void VerifyExecuteBatch()
{
using (ExecutionEngine executionEngine = new ExecutionEngine())
@@ -498,7 +499,7 @@ GO";
var executionPromise = new TaskCompletionSource<bool>();
executionEngine.BatchParserExecutionFinished += (object sender, BatchParserExecutionFinishedEventArgs e) =>
{
Assert.Equal(ScriptExecutionResult.Success, e.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, e.ExecutionResult);
executionPromise.SetResult(true);
};
executionEngine.ExecuteBatch(new ScriptExecutionArgs(query, sqlConn, 15, new ExecutionEngineConditions(), new BatchParserMockEventHandler()));
@@ -508,7 +509,7 @@ GO";
}
}
[Fact]
[Test]
public void CanceltheBatch()
{
Batch batch = new Batch();
@@ -567,7 +568,7 @@ GO";
if (lexerError == false)
{
// Verify that all text from tokens can be recombined into original string
Assert.Equal<string>(inputText, roundtripTextBuilder.ToString());
Assert.AreEqual(inputText, roundtripTextBuilder.ToString());
}
}
}

View File

@@ -6,31 +6,32 @@
using System;
using Microsoft.SqlTools.ServiceLayer.BatchParser;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
[TestFixture]
public class BatchParserWrapperTests
{
[Fact]
[Test]
public void CheckSimpleSingleSQLBatchStatement()
{
using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
{
string sqlScript = "select * from sys.objects";
var batches = parserWrapper.GetBatches(sqlScript);
Assert.Equal(1, batches.Count);
Assert.AreEqual(1, batches.Count);
BatchDefinition batch = batches[0];
Assert.Equal(sqlScript, batch.BatchText);
Assert.Equal(1, batch.StartLine);
Assert.Equal(1, batch.StartColumn);
Assert.Equal(2, batch.EndLine);
Assert.Equal(sqlScript.Length + 1, batch.EndColumn);
Assert.Equal(1, batch.BatchExecutionCount);
Assert.AreEqual(sqlScript, batch.BatchText);
Assert.AreEqual(1, batch.StartLine);
Assert.AreEqual(1, batch.StartColumn);
Assert.AreEqual(2, batch.EndLine);
Assert.AreEqual(sqlScript.Length + 1, batch.EndColumn);
Assert.AreEqual(1, batch.BatchExecutionCount);
}
}
[Fact]
[Test]
public void CheckSimpleMultipleQLBatchStatement()
{
using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
@@ -44,48 +45,48 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
SELECT 'LastLine'";
var batches = parserWrapper.GetBatches(sqlScript);
// Each select statement is one batch , so we are expecting 4 batches.
Assert.Equal(4, batches.Count);
Assert.AreEqual(4, batches.Count);
}
}
[Fact]
[Test]
public void CheckSQLBatchStatementWithRepeatExecution()
{
using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
{
string sqlScript = "select * from sys.object" + Environment.NewLine + "GO 2";
var batches = parserWrapper.GetBatches(sqlScript);
Assert.Equal(1, batches.Count);
Assert.AreEqual(1, batches.Count);
BatchDefinition batch = batches[0];
Assert.Equal(2, batch.BatchExecutionCount);
Assert.AreEqual(2, batch.BatchExecutionCount);
}
}
[Fact]
[Test]
public void CheckComment()
{
using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
{
string sqlScript = "-- this is a comment --";
var batches = parserWrapper.GetBatches(sqlScript);
Assert.Equal(1, batches.Count);
Assert.AreEqual(1, batches.Count);
BatchDefinition batch = batches[0];
Assert.Equal(sqlScript, batch.BatchText);
Assert.Equal(1, batch.StartLine);
Assert.Equal(1, batch.StartColumn);
Assert.Equal(2, batch.EndLine);
Assert.Equal(sqlScript.Length + 1, batch.EndColumn);
Assert.AreEqual(sqlScript, batch.BatchText);
Assert.AreEqual(1, batch.StartLine);
Assert.AreEqual(1, batch.StartColumn);
Assert.AreEqual(2, batch.EndLine);
Assert.AreEqual(sqlScript.Length + 1, batch.EndColumn);
}
}
[Fact]
[Test]
public void CheckNoOps()
{
using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
{
string sqlScript = "GO";
var batches = parserWrapper.GetBatches(sqlScript);
Assert.Equal(0, batches.Count);
Assert.AreEqual(0, batches.Count);
}
}
}

View File

@@ -19,8 +19,9 @@
<PackageReference Include="System.Net.Http"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="nunit" />
<PackageReference Include="nunit3testadapter" />
<PackageReference Include="nunit.console" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />

View File

@@ -12,15 +12,16 @@ using Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
[TestFixture]
/// <summary>
///This is a test class for Microsoft.Data.Tools.Schema.Common.ExecutionEngine.ExecutionEngine and is intended
///to contain all Microsoft.Data.Tools.Schema.Common.ExecutionEngine.ExecutionEngine Unit Tests
///</summary>
public class ExecutionEngineTest : IDisposable
{
private SqlConnection connection;
@@ -29,11 +30,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Test Initialize And Cleanup
public ExecutionEngineTest()
{
TestInitialize();
}
[SetUp]
// Initialize the tests
public void TestInitialize()
{
@@ -80,7 +77,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
///A test for a simple SQL script
///</summary>
[Fact]
[Test]
public void ExecutionEngineTest_SimpleTest()
{
string sqlStatement = "SELECT * FROM sysobjects";
@@ -97,15 +94,15 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.Equal(1, executor.BatchFinshedEventCounter);
Assert.AreEqual(1, executor.BatchFinshedEventCounter);
}
/// <summary>
/// Test with a valid script using default execution condition
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_DefaultCondition_ValidScript()
{
string sqlStatement = "select * from sysobjects\nGo\n";
@@ -119,14 +116,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
// <summary>
// Test with multiple valid scripts in multiple batches
// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_MultiValidScripts()
{
string sqlStatement = "select * from sys.databases\ngo\nselect name from sys.databases\ngo\nprint 'test'\ngo";
@@ -143,14 +140,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
/// <summary>
/// Test with SQL comment
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_TestComment()
{
string sqlStatement = "/*test comments*/";
@@ -167,7 +164,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
@@ -178,7 +175,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with a invalid query using the default execution condition
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_DefaultCondition_InvalidScript()
{
string sqlStatement = "select ** from sysobjects";
@@ -192,17 +189,17 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.Equal(0, executor.BatchFinshedEventCounter);
Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
/// <summary>
/// Test with an invalid query using a defined execution condition
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_InvalidScriptWithCondition()
{
string sqlStatement = "select * from authors";
@@ -218,7 +215,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -227,7 +224,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with multiple invalid scripts in multiple batches
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_MultipleInvalidScript()
{
string sqlStatement = "select ** from products \ngo\n insert into products values (1,'abc')\n go \n";
@@ -244,7 +241,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -253,7 +250,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with invalid scripts within a single batch
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_MultipleInvalidScript_SingleBatch()
{
string sqlStatement = "select ** from products \n insert into products values (1,'abc')\n go \n";
@@ -270,7 +267,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -279,7 +276,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with mixed valid and invalid scripts
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_MixedValidandInvalidScript()
{
string sqlStatement = "SELECT * FROM Authors \n Go\n select * from sysobjects \n go\nif exists (select * from sysobjects where id = object_id('MyTab')) DROP TABLE MyTab2";
@@ -296,13 +293,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
[Fact]
[Test]
public void ExecutionEngineTest_DiscardConnection()
{
ExecutionEngine engine = new ExecutionEngine();
@@ -316,14 +313,16 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test HaltOnError execution condition
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_HaltOnError()
{
string sqlStatement = "select * from authors\n go\n select * from sysbojects \n go \n";
ExecutionEngineConditions conditions = new ExecutionEngineConditions();
conditions.IsTransactionWrapped = true;
conditions.IsParseOnly = false;
conditions.IsHaltOnError = true;
ExecutionEngineConditions conditions = new ExecutionEngineConditions
{
IsTransactionWrapped = true,
IsParseOnly = false,
IsHaltOnError = true
};
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
@@ -332,7 +331,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.True(executor.ResultCountQueue.Count == 0);
@@ -341,7 +340,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// HaltOnError with a single batch
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_HaltOnError_OneBatch()
{
string sqlStatement = "select * from authors\n go 30\n";
@@ -357,17 +356,17 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.True(executor.ResultCountQueue.Count == 0);
Assert.Equal(0, executor.BatchFinshedEventCounter);
Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
/// <summary>
/// Test ParseOnly execution condition with valid scripts
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_ParseOnly_ValidScript()
{
string sqlStatement = "select * from sysobjects";
@@ -379,15 +378,15 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(executor.ResultCountQueue.Count == 0);
Assert.Equal(0, executor.BatchFinshedEventCounter);
Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
/// <summary>
/// Test HaltOnError execution condition with invalid scripts
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_ParseOnly_InvalidScript()
{
string sqlStatement = "select ** from authors";
@@ -403,7 +402,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(executor.ResultCountQueue.Count == 0);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
@@ -412,7 +411,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Parse script only without transaction wrapper
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_ParseOnly_ValidScriptWithoutTransaction()
{
string sqlStatement = "select * from sysobjects";
@@ -424,9 +423,9 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(executor.ResultCountQueue.Count == 0);
Assert.Equal(0, executor.BatchFinshedEventCounter);
Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
/// <summary>
@@ -443,13 +442,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions, -1);
executor.Run();
Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
}
/// <summary>
/// Test with invalid connection
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_InvalidConnection()
{
string sqlStatement = "select * from sysobjects\n go 100\n";
@@ -470,7 +469,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with multiple conditions true
/// </summary>
[Fact]
[Test]
public void TestExecutionEngineConditions()
{
string sqlStatement = "select * from sys.databases\ngo\nselect name from sys.databases\ngo\nprint 'test'\ngo";
@@ -486,7 +485,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
@@ -497,7 +496,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test with SQL commands
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_SQLCmds()
{
string[] sqlStatements = {
@@ -537,7 +536,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// <summary>
/// Test synchronous cancel
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_SyncCancel()
{
string sqlStatement = "waitfor delay '0:0:10'";
@@ -552,14 +551,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
executor.Run();
Assert.NotNull(executor.ScriptExecuteThread);
Assert.Equal(ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.True(executor.CancelEventFired);
}
/// <summary>
/// Test asynchronous cancel
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_ASyncCancel()
{
//string sqlStatement = "--This is a test\nSELECT * FROM sysobjects as t\nGO 50\n use pubsplus \n select * from titles\n go" ;
@@ -578,7 +577,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
Assert.Equal(ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
/// <summary>
@@ -604,13 +603,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
/// <summary>
/// Test async cancel when the execution is done
/// </summary>
[Fact]
[Test]
public void ExecutionEngineTest_ASyncCancelAfterExecutionDone()
{
string sqlStatement = "select 1";
@@ -628,13 +627,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
/// <summary>
/// Test multiple threads of execution engine with cancel operation
/// </summary>
[Fact]
[Test]
public async Task ExecutionEngineTest_MultiThreading_WithCancel()
{
string[] sqlStatement = { "waitfor delay '0:0:10'",
@@ -693,7 +692,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Get/Set Methods
[Fact]
[Test]
public void TestShowStatements()
{
Assert.NotNull(ExecutionEngineConditions.ShowPlanXmlStatement(true));
@@ -708,48 +707,48 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(ExecutionEngineConditions.ResetStatement);
}
[Fact]
[Test]
public void TestExecutionEngineConditionsSetMethods()
{
ExecutionEngineConditions conditions = new ExecutionEngineConditions();
bool getValue = conditions.IsScriptExecutionTracked;
conditions.IsScriptExecutionTracked = !getValue;
Assert.Equal(conditions.IsScriptExecutionTracked, !getValue);
Assert.AreEqual(conditions.IsScriptExecutionTracked, !getValue);
getValue = conditions.IsEstimatedShowPlan;
conditions.IsEstimatedShowPlan = !getValue;
Assert.Equal(conditions.IsEstimatedShowPlan, !getValue);
Assert.AreEqual(conditions.IsEstimatedShowPlan, !getValue);
getValue = conditions.IsActualShowPlan;
conditions.IsActualShowPlan = !getValue;
Assert.Equal(conditions.IsActualShowPlan, !getValue);
Assert.AreEqual(conditions.IsActualShowPlan, !getValue);
getValue = conditions.IsSuppressProviderMessageHeaders;
conditions.IsSuppressProviderMessageHeaders = !getValue;
Assert.Equal(conditions.IsSuppressProviderMessageHeaders, !getValue);
Assert.AreEqual(conditions.IsSuppressProviderMessageHeaders, !getValue);
getValue = conditions.IsNoExec;
conditions.IsNoExec = !getValue;
Assert.Equal(conditions.IsNoExec, !getValue);
Assert.AreEqual(conditions.IsNoExec, !getValue);
getValue = conditions.IsStatisticsIO;
conditions.IsStatisticsIO = !getValue;
Assert.Equal(conditions.IsStatisticsIO, !getValue);
Assert.AreEqual(conditions.IsStatisticsIO, !getValue);
getValue = conditions.IsShowPlanText;
conditions.IsShowPlanText = !getValue;
Assert.Equal(conditions.IsShowPlanText, !getValue);
Assert.AreEqual(conditions.IsShowPlanText, !getValue);
getValue = conditions.IsStatisticsTime;
conditions.IsStatisticsTime = !getValue;
Assert.Equal(conditions.IsStatisticsTime, !getValue);
Assert.AreEqual(conditions.IsStatisticsTime, !getValue);
getValue = conditions.IsSqlCmd;
conditions.IsSqlCmd = !getValue;
Assert.Equal(conditions.IsSqlCmd, !getValue);
Assert.AreEqual(conditions.IsSqlCmd, !getValue);
conditions.BatchSeparator = "GO";
Assert.Equal(conditions.BatchSeparator, "GO");
Assert.AreEqual("GO", conditions.BatchSeparator);
}
#endregion Get/Set Methods

View File

@@ -9,7 +9,8 @@ using Microsoft.Data.SqlClient;
using System.Threading;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Microsoft.SqlTools.Utility;
using System.Runtime.CompilerServices;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
internal class TestExecutor : IDisposable
@@ -17,9 +18,9 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Private variables
private string sqlStatement;
private ExecutionEngineConditions conditions = new ExecutionEngineConditions();
private BatchEventHandler eventHandler = new BatchEventHandler();
private SqlConnection connection = null;
private readonly ExecutionEngineConditions conditions = new ExecutionEngineConditions();
private readonly BatchEventHandler eventHandler = new BatchEventHandler();
private readonly SqlConnection connection;
private static Thread _executionThread;
private bool _syncCancel = true;
private bool _isFinished = false;
@@ -31,12 +32,12 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
private List<int> resultCounts = new List<int>();
private List<string> sqlMessages = new List<string>();
private List<string> errorMessage = new List<string>();
private readonly List<string> errorMessage = new List<string>();
private List<bool> batchFinished = new List<bool>();
private static ScriptExecutionResult execResult = ScriptExecutionResult.All;
private static List<string> batchScripts = new List<string>();
private static Thread exeThread = null;
private static bool parserExecutionError = false;
private bool parserExecutionError = false;
#endregion Private variables
@@ -322,10 +323,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
private static void OnBatchParserExecutionFinished(object sender, BatchParserExecutionFinishedEventArgs e)
{
Console.WriteLine("ON_BATCH_PARSER_EXECUTION_FINISHED : Done executing batch \n\t{0}\n\t with result... {1} ", e.Batch.Text, e.ExecutionResult);
if (execResult == ScriptExecutionResult.All)
execResult = e.ExecutionResult;
else
execResult = execResult | e.ExecutionResult;
if (execResult == ScriptExecutionResult.All)
{
execResult = e.ExecutionResult;
}
else
{
execResult |= e.ExecutionResult;
}
}
/// <summary>
@@ -333,11 +338,12 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnBatchParserExecutionError(object sender, BatchParserExecutionErrorEventArgs e)
private void OnBatchParserExecutionError(object sender, BatchParserExecutionErrorEventArgs e)
{
Console.WriteLine("ON_BATCH_PARSER_EXECUTION_ERROR : {0} found... at line {1}: {2}", e.MessageType.ToString(), e.Line.ToString(), e.Message);
Console.WriteLine("\t Error Description: " + e.Description);
parserExecutionError = true;
errorMessage.Add(e.Description);
}
/// <summary>
@@ -350,14 +356,18 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Console.WriteLine("ON_EXECUTION_FINISHED : Script execution done with result ..." + e.ExecutionResult);
_isFinished = true;
if (execResult == ScriptExecutionResult.All)
execResult = e.ExecutionResult;
else
execResult = execResult | e.ExecutionResult;
if (execResult == ScriptExecutionResult.All)
{
execResult = e.ExecutionResult;
}
else
{
execResult |= e.ExecutionResult;
}
resultCounts = eventHandler.ResultCounts;
sqlMessages = eventHandler.SqlMessages;
errorMessage = eventHandler.ErrorMessages;
errorMessage.AddRange(eventHandler.ErrorMessages);
}
#endregion ParserEvent

View File

@@ -8,7 +8,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility
{