Task/batch parser wrapper tests (#314)

* added more batch parser tests

* fixed merge conflicts

* change debug type to portable

* fixed imports according to review
This commit is contained in:
Aditya Bist
2017-04-21 11:59:20 -07:00
committed by GitHub
parent 8206c70994
commit 06eddd57f4
7 changed files with 480 additions and 185 deletions

View File

@@ -1,64 +1,64 @@
{ {
"name": "Microsoft.SqlTools.Credentials", "name": "Microsoft.SqlTools.Credentials",
"version": "1.0.0-*", "version": "1.0.0-*",
"buildOptions": { "buildOptions": {
"debugType": "portable", "debugType": "portable",
"emitEntryPoint": true, "emitEntryPoint": true,
"embed": [ "embed": [
"../Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx", "../Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx",
"../Microsoft.SqlTools.ServiceLayer/Localization/sr.resx" "../Microsoft.SqlTools.ServiceLayer/Localization/sr.resx"
] ]
}, },
"configurations": { "configurations": {
"Integration": { "Integration": {
"buildOptions": { "buildOptions": {
"define": [ "define": [
"WINDOWS_ONLY_BUILD" "WINDOWS_ONLY_BUILD"
], ],
"emitEntryPoint": true "emitEntryPoint": true
} }
} }
}, },
"dependencies": { "dependencies": {
"Newtonsoft.Json": "9.0.1", "Newtonsoft.Json": "9.0.1",
"System.Security.SecureString": "4.0.0", "System.Security.SecureString": "4.0.0",
"System.Collections.Specialized": "4.0.1", "System.Collections.Specialized": "4.0.1",
"System.ComponentModel.TypeConverter": "4.1.0", "System.ComponentModel.TypeConverter": "4.1.0",
"System.Diagnostics.Contracts": "4.0.1", "System.Diagnostics.Contracts": "4.0.1",
"System.Diagnostics.TraceSource": "4.0.0", "System.Diagnostics.TraceSource": "4.0.0",
"NETStandard.Library": "1.6.0", "NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.2", "Microsoft.NETCore.Runtime.CoreCLR": "1.0.2",
"Microsoft.NETCore.DotNetHostPolicy": "1.0.1", "Microsoft.NETCore.DotNetHostPolicy": "1.0.1",
"Microsoft.DiaSymReader.Native": "1.4.1", "Microsoft.DiaSymReader.Native": "1.4.1",
"System.Diagnostics.Process": "4.1.0", "System.Diagnostics.Process": "4.1.0",
"System.Threading.Thread": "4.0.0", "System.Threading.Thread": "4.0.0",
"System.Runtime.Loader": "4.0.0", "System.Runtime.Loader": "4.0.0",
"System.Composition": "1.0.31-beta-24326-02", "System.Composition": "1.0.31-beta-24326-02",
"Microsoft.Extensions.DependencyModel": "1.0.0", "Microsoft.Extensions.DependencyModel": "1.0.0",
"Microsoft.SqlTools.Hosting": { "Microsoft.SqlTools.Hosting": {
"target": "project" "target": "project"
} }
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.0": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"version": "1.0.0" "version": "1.0.0"
} }
}, },
"imports": "dnxcore50" "imports": "dnxcore50"
} }
}, },
"runtimes": { "runtimes": {
"win7-x64": {}, "win7-x64": {},
"win7-x86": {}, "win7-x86": {},
"osx.10.11-x64": {}, "osx.10.11-x64": {},
"ubuntu.14.04-x64": {}, "ubuntu.14.04-x64": {},
"ubuntu.16.04-x64": {}, "ubuntu.16.04-x64": {},
"centos.7-x64": {}, "centos.7-x64": {},
"rhel.7.2-x64": {}, "rhel.7.2-x64": {},
"debian.8-x64": {}, "debian.8-x64": {},
"fedora.23-x64": {}, "fedora.23-x64": {},
"opensuse.13.2-x64": {} "opensuse.13.2-x64": {}
} }
} }

View File

@@ -23,6 +23,7 @@ using Microsoft.SqlTools.Utility;
using ConnectionType = Microsoft.SqlTools.ServiceLayer.Connection.ConnectionType; using ConnectionType = Microsoft.SqlTools.ServiceLayer.Connection.ConnectionType;
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location; using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
namespace Microsoft.SqlTools.ServiceLayer.Scripting namespace Microsoft.SqlTools.ServiceLayer.Scripting
{ {
internal partial class Scripter internal partial class Scripter
@@ -151,6 +152,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
} }
StringComparison caseSensitivity = this.Database.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; StringComparison caseSensitivity = this.Database.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
// if declarationItem matches the selected token, script SMO using that type // if declarationItem matches the selected token, script SMO using that type
if (declarationItem.Title.Equals(tokenText, caseSensitivity)) if (declarationItem.Title.Equals(tokenText, caseSensitivity))
{ {
return GetDefinitionUsingDeclarationType(declarationItem.Type, declarationItem.DatabaseQualifiedName, tokenText, schemaName); return GetDefinitionUsingDeclarationType(declarationItem.Type, declarationItem.DatabaseQualifiedName, tokenText, schemaName);

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TestLocalizationConstant" xml:space="preserve">
<value>ES_LOCALIZATION</value>
</data>
</root>

View File

@@ -1,65 +1,120 @@
// //
// Copyright (c) Microsoft. All rights reserved. // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
using System; using System;
using Microsoft.SqlTools.ServiceLayer.BatchParser; using System.IO;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode; using Microsoft.SqlTools.ServiceLayer.BatchParser;
using Xunit; using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Moq;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser using Xunit;
{
public class BatchParserSqlCmdTests : IDisposable namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser
{ {
private BatchParserSqlCmd bpcmd; public class BatchParserSqlCmdTests : IDisposable
private PositionStruct testPOS; {
public BatchParserSqlCmdTests() private BatchParserSqlCmd bpcmd;
{ private PositionStruct testPOS;
bpcmd = new BatchParserSqlCmd(); public BatchParserSqlCmdTests()
testPOS = new PositionStruct(); {
bpcmd.SetVariable(testPOS, "variable1", "test1"); bpcmd = new BatchParserSqlCmd();
bpcmd.SetVariable(testPOS, "variable2", "test2"); testPOS = new PositionStruct();
bpcmd.SetVariable(testPOS, "variable3", "test3"); bpcmd.SetVariable(testPOS, "variable1", "test1");
} bpcmd.SetVariable(testPOS, "variable2", "test2");
bpcmd.SetVariable(testPOS, "variable3", "test3");
public void Dispose() }
{
Dispose(true); public void Dispose()
} {
Dispose(true);
private void Dispose(bool disposing) }
{
if (disposing) private void Dispose(bool disposing)
{ {
if (bpcmd != null) if (disposing)
{ {
bpcmd = null; if (bpcmd != null)
} {
} bpcmd = null;
} }
}
[Fact] }
public void CheckSetVariable()
{ [Fact]
Assert.Equal(bpcmd.InternalVariables.Count, 3); public void CheckSetVariable()
bpcmd.SetVariable(testPOS, "variable4", "test4"); {
bpcmd.SetVariable(testPOS, "variable5", "test5"); Assert.Equal(bpcmd.InternalVariables.Count, 3);
bpcmd.SetVariable(testPOS, "variable6", "test6"); bpcmd.SetVariable(testPOS, "variable4", "test4");
Assert.Equal(bpcmd.InternalVariables.Count, 6); bpcmd.SetVariable(testPOS, "variable5", "test5");
bpcmd.SetVariable(testPOS, "variable6", "test6");
} Assert.Equal(bpcmd.InternalVariables.Count, 6);
[Fact] bpcmd.SetVariable(testPOS, "variable1", null);
public void CheckGetVariable() }
{
string value = bpcmd.GetVariable(testPOS, "variable1"); [Fact]
Assert.Equal("test1", value); public void CheckSetNullValueVariable()
value = bpcmd.GetVariable(testPOS, "variable2"); {
Assert.Equal("test2", value); bpcmd.SetVariable(testPOS, "variable6", null);
value = bpcmd.GetVariable(testPOS, "variable3"); Assert.Equal(bpcmd.InternalVariables.Count, 5);
Assert.Equal("test3", value); }
} [Fact]
} public void CheckGetVariable()
} {
string value = bpcmd.GetVariable(testPOS, "variable1");
Assert.Equal("test1", value);
value = bpcmd.GetVariable(testPOS, "variable2");
Assert.Equal("test2", value);
value = bpcmd.GetVariable(testPOS, "variable3");
Assert.Equal("test3", value);
}
[Fact]
public void CheckGetNullVariable()
{
Assert.Null(bpcmd.GetVariable(testPOS, "variable6"));
}
[Fact]
public void CheckInclude()
{
TextReader textReader = null;
string outString = "out";
var result = bpcmd.Include(null, out textReader, out outString);
Assert.Equal(result, BatchParserAction.Abort);
}
[Fact]
public void CheckOnError()
{
var errorActionChanged = bpcmd.ErrorActionChanged;
var action = new OnErrorAction();
var result = bpcmd.OnError(null, action);
Assert.Equal(result, BatchParserAction.Continue);
bpcmd.ErrorActionChanged = null;
result = bpcmd.OnError(null, action);
Assert.NotEqual(result, BatchParserAction.Continue);
}
[Fact]
public void CheckConnectionChangedDelegate()
{
var initial = bpcmd.ConnectionChanged;
bpcmd.ConnectionChanged = null;
Assert.Null(bpcmd.ConnectionChanged);
}
[Fact]
public void CheckVariableSubstitutionDisabled()
{
bpcmd.DisableVariableSubstitution();
bpcmd.SetVariable(testPOS, "variable1", "test");
var result = bpcmd.GetVariable(testPOS, "variable1");
Assert.Null(result);
}
}
}

View File

@@ -1,51 +1,54 @@
using Microsoft.SqlTools.ServiceLayer.BatchParser; using Microsoft.SqlTools.ServiceLayer.BatchParser;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode; using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Xunit; using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser
{ {
public class BatchParserWrapperTests public class BatchParserWrapperTests
{ {
private BatchParserWrapper parserWrapper; [Fact]
public BatchParserWrapperTests() public void CheckSimpleSingleSQLBatchStatement()
{ {
parserWrapper = new BatchParserWrapper(); using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
} {
string sqlScript = "select * from sys.objects";
[Fact] var batches = parserWrapper.GetBatches(sqlScript);
public void CheckSimpleSingleSQLBatchStatement() Assert.Equal(1, batches.Count);
{ BatchDefinition batch = batches[0];
string sqlScript = "select * from sys.objects"; Assert.Equal(sqlScript, batch.BatchText);
var batches = parserWrapper.GetBatches(sqlScript); Assert.Equal(1, batch.StartLine);
Assert.Equal(1, batches.Count); Assert.Equal(1, batch.StartColumn);
BatchDefinition batch = batches[0]; Assert.Equal(2, batch.EndLine);
Assert.Equal(sqlScript, batch.BatchText); Assert.Equal(sqlScript.Length, batch.EndColumn);
Assert.Equal(1, batch.StartLine); }
Assert.Equal(1, batch.StartColumn); }
Assert.Equal(2, batch.EndLine);
Assert.Equal(sqlScript.Length, batch.EndColumn); [Fact]
} public void CheckComment()
{
[Fact] using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
public void CheckComment() {
{ string sqlScript = "-- this is a comment --";
string sqlScript = "-- this is a comment --"; var batches = parserWrapper.GetBatches(sqlScript);
var batches = parserWrapper.GetBatches(sqlScript); Assert.Equal(1, batches.Count);
Assert.Equal(1, batches.Count); BatchDefinition batch = batches[0];
BatchDefinition batch = batches[0]; Assert.Equal(sqlScript, batch.BatchText);
Assert.Equal(sqlScript, batch.BatchText); Assert.Equal(1, batch.StartLine);
Assert.Equal(1, batch.StartLine); Assert.Equal(1, batch.StartColumn);
Assert.Equal(1, batch.StartColumn); Assert.Equal(2, batch.EndLine);
Assert.Equal(2, batch.EndLine); Assert.Equal(sqlScript.Length, batch.EndColumn);
Assert.Equal(sqlScript.Length, batch.EndColumn); }
} }
[Fact] [Fact]
public void CheckNoOps() public void CheckNoOps()
{ {
string sqlScript = "GO"; using (BatchParserWrapper parserWrapper = new BatchParserWrapper())
var batches = parserWrapper.GetBatches(sqlScript); {
Assert.Equal(0, batches.Count); string sqlScript = "GO";
} var batches = parserWrapper.GetBatches(sqlScript);
} Assert.Equal(0, batches.Count);
} }
}
}
}

View File

@@ -12,8 +12,10 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility; using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
{ {
/// <summary> /// <summary>
@@ -297,6 +299,14 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage)); Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts)); Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
} }
[Fact]
public void ExecutionEngineTest_DiscardConnection()
{
ExecutionEngine engine = new ExecutionEngine();
Assert.True(ConnectionDiscardWrapper(engine));
}
#endregion #endregion
#region Different execution conditions #region Different execution conditions
@@ -456,6 +466,29 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
// However since that gets mapped to Failure anyhow, consider "Failure" as acceptable here // However since that gets mapped to Failure anyhow, consider "Failure" as acceptable here
Assert.True(executor.ExecutionResult.HasFlag(ScriptExecutionResult.Failure), "Expected failure when invalid connection is present" ); Assert.True(executor.ExecutionResult.HasFlag(ScriptExecutionResult.Failure), "Expected failure when invalid connection is present" );
} }
/// <summary>
/// Test with multiple conditions true
/// </summary>
[Fact]
public void TestExecutionEngineConditions()
{
string sqlStatement = "select * from sys.databases\ngo\nselect name from sys.databases\ngo\nprint 'test'\ngo";
ExecutionEngineConditions conditions = new ExecutionEngineConditions();
conditions.IsNoExec = true;
conditions.IsStatisticsIO = true;
conditions.IsStatisticsTime = true;
conditions.IsEstimatedShowPlan = true;
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions, false);
executor.Run();
//Get the expected values
List<string> batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
#endregion #endregion
#region SQL Commands #region SQL Commands
@@ -491,9 +524,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
{ {
TestExecutor executor = new TestExecutor(stmt, connection, conditions); TestExecutor executor = new TestExecutor(stmt, connection, conditions);
executor.Run(); executor.Run();
Assert.True(executor.ResultCountQueue.Count == 0);
//Assert.AreEqual(ScriptExecutionResult.Failure, executor.ExecutionResult);
//Assert.IsTrue(executor.ResultCountQueue.Count == 0);
} }
} }
@@ -501,7 +532,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
#region Threading #region Threading
/// <summary> /// <summary>
/// Test synchous cancel /// Test synchronous cancel
/// </summary> /// </summary>
[Fact] [Fact]
public void ExecutionEngineTest_SyncCancel() public void ExecutionEngineTest_SyncCancel()
@@ -657,6 +688,69 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
#endregion #endregion
#region Get/Set Methods
[Fact]
public void TestShowStatements()
{
Assert.NotNull(ExecutionEngineConditions.ShowPlanXmlStatement(true));
Assert.NotNull(ExecutionEngineConditions.ShowPlanAllStatement(true));
Assert.NotNull(ExecutionEngineConditions.ShowPlanTextStatement(true));
Assert.NotNull(ExecutionEngineConditions.StatisticsXmlStatement(true));
Assert.NotNull(ExecutionEngineConditions.StatisticsProfileStatement(true));
Assert.NotNull(ExecutionEngineConditions.ParseOnlyStatement(true));
Assert.NotNull(ExecutionEngineConditions.NoExecStatement(true));
Assert.NotNull(ExecutionEngineConditions.StatisticsIOStatement(true));
Assert.NotNull(ExecutionEngineConditions.StatisticsTimeStatement(true));
Assert.NotNull(ExecutionEngineConditions.ResetStatement);
}
[Fact]
public void TestExecutionEngineConditionsSetMethods()
{
ExecutionEngineConditions conditions = new ExecutionEngineConditions();
bool getValue = conditions.IsScriptExecutionTracked;
conditions.IsScriptExecutionTracked = !getValue;
Assert.Equal(conditions.IsScriptExecutionTracked, !getValue);
getValue = conditions.IsEstimatedShowPlan;
conditions.IsEstimatedShowPlan = !getValue;
Assert.Equal(conditions.IsEstimatedShowPlan, !getValue);
getValue = conditions.IsActualShowPlan;
conditions.IsActualShowPlan = !getValue;
Assert.Equal(conditions.IsActualShowPlan, !getValue);
getValue = conditions.IsSuppressProviderMessageHeaders;
conditions.IsSuppressProviderMessageHeaders = !getValue;
Assert.Equal(conditions.IsSuppressProviderMessageHeaders, !getValue);
getValue = conditions.IsNoExec;
conditions.IsNoExec = !getValue;
Assert.Equal(conditions.IsNoExec, !getValue);
getValue = conditions.IsStatisticsIO;
conditions.IsStatisticsIO = !getValue;
Assert.Equal(conditions.IsStatisticsIO, !getValue);
getValue = conditions.IsShowPlanText;
conditions.IsShowPlanText = !getValue;
Assert.Equal(conditions.IsShowPlanText, !getValue);
getValue = conditions.IsStatisticsTime;
conditions.IsStatisticsTime = !getValue;
Assert.Equal(conditions.IsStatisticsTime, !getValue);
getValue = conditions.IsSqlCmd;
conditions.IsSqlCmd = !getValue;
Assert.Equal(conditions.IsSqlCmd, !getValue);
conditions.BatchSeparator = "GO";
Assert.Equal(conditions.BatchSeparator, "GO");
}
#endregion
#region Private methods #region Private methods
/// <summary> /// <summary>
/// Connection to a database /// Connection to a database
@@ -782,6 +876,21 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
return isSame; return isSame;
} }
/// <summary>
/// Wrapper to test the Close method in ExecutionEngine
/// </summary>
/// <param name="engine"></param>
/// <returns></returns>
private bool ConnectionDiscardWrapper(ExecutionEngine engine)
{
if (engine == null)
{
return false;
}
engine.Close(false, true, true);
return true;
}
#endregion #endregion
} }
} }

View File

@@ -219,7 +219,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TSQLExecutionEngine
sqlStatement = batch; sqlStatement = batch;
conditions.IsHaltOnError = exeCondition.IsHaltOnError; conditions.IsHaltOnError = exeCondition.IsHaltOnError;
conditions.IsParseOnly = exeCondition.IsParseOnly; conditions.IsParseOnly = exeCondition.IsParseOnly;
conditions.IsTransactionWrapped = exeCondition.IsTransactionWrapped; conditions.IsTransactionWrapped = exeCondition.IsTransactionWrapped;
conditions.IsNoExec = exeCondition.IsNoExec;
conditions.IsStatisticsIO = exeCondition.IsStatisticsIO;
conditions.IsStatisticsTime = exeCondition.IsStatisticsTime;
_cancel = cancelExecution; _cancel = cancelExecution;
connection = conn; connection = conn;