mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Feature/batch line info (#56)
* inital pipe of line numbers and getting text from workspace services * tests compile * Fixed bug regarding tests using connections on mac * updated tests * fixed workspace service and fixed tests * integrated feedback
This commit is contained in:
@@ -197,7 +197,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
// try to get information about the connected SQL Server instance
|
// try to get information about the connected SQL Server instance
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ReliableConnectionHelper.ServerInfo serverInfo = ReliableConnectionHelper.GetServerVersion(connectionInfo.SqlConnection);
|
var connection = connectionInfo.SqlConnection as ReliableSqlConnection;
|
||||||
|
if (connection != null)
|
||||||
|
{
|
||||||
|
ReliableConnectionHelper.ServerInfo serverInfo = ReliableConnectionHelper.GetServerVersion(connection.GetUnderlyingConnection());
|
||||||
response.ServerInfo = new Contracts.ServerInfo()
|
response.ServerInfo = new Contracts.ServerInfo()
|
||||||
{
|
{
|
||||||
ServerMajorVersion = serverInfo.ServerMajorVersion,
|
ServerMajorVersion = serverInfo.ServerMajorVersion,
|
||||||
@@ -212,6 +215,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
OsVersion = serverInfo.OsVersion
|
OsVersion = serverInfo.OsVersion
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
response.Messages = ex.ToString();
|
response.Messages = ex.ToString();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal Batch(string batchText, int startLine, IFileStreamFactory outputFileFactory)
|
internal Batch(string batchText, int startLine, int startColumn, int endLine, int endColumn, IFileStreamFactory outputFileFactory)
|
||||||
{
|
{
|
||||||
// Sanity check for input
|
// Sanity check for input
|
||||||
Validate.IsNotNullOrEmptyString(nameof(batchText), batchText);
|
Validate.IsNotNullOrEmptyString(nameof(batchText), batchText);
|
||||||
@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
|
|
||||||
// Initialize the internal state
|
// Initialize the internal state
|
||||||
BatchText = batchText;
|
BatchText = batchText;
|
||||||
StartLine = startLine - 1; // -1 to make sure that the line number of the batch is 0-indexed, since SqlParser gives 1-indexed line numbers
|
Selection = new SelectionData(startLine, startColumn, endLine, endColumn);
|
||||||
HasExecuted = false;
|
HasExecuted = false;
|
||||||
resultSets = new List<ResultSet>();
|
resultSets = new List<ResultSet>();
|
||||||
resultMessages = new List<string>();
|
resultMessages = new List<string>();
|
||||||
@@ -111,9 +111,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The 0-indexed line number that this batch started on
|
/// The range from the file that is this batch
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal int StartLine { get; set; }
|
internal SelectionData Selection { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -253,9 +253,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
SqlError sqlError = error as SqlError;
|
SqlError sqlError = error as SqlError;
|
||||||
if (sqlError != null)
|
if (sqlError != null)
|
||||||
{
|
{
|
||||||
int lineNumber = sqlError.LineNumber + StartLine;
|
int lineNumber = sqlError.LineNumber + Selection.StartLine;
|
||||||
string message = SR.QueryServiceErrorFormat(sqlError.Number, sqlError.Class, sqlError.State,
|
string message = string.Format("Msg {0}, Level {1}, State {2}, Line {3}{4}{5}",
|
||||||
lineNumber, Environment.NewLine, sqlError.Message);
|
sqlError.Number, sqlError.Class, sqlError.State, lineNumber,
|
||||||
|
Environment.NewLine, sqlError.Message);
|
||||||
resultMessages.Add(message);
|
resultMessages.Add(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The selection from the file for this batch
|
||||||
|
/// </summary>
|
||||||
|
public SelectionData Selection { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Any messages that came back from the server during execution of the batch
|
/// Any messages that came back from the server during execution of the batch
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -7,15 +7,30 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
|||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Container class for a selection range from file
|
||||||
|
/// </summary>
|
||||||
|
public class SelectionData {
|
||||||
|
public int StartLine { get; set; }
|
||||||
|
public int StartColumn { get; set; }
|
||||||
|
public int EndLine { get; set; }
|
||||||
|
public int EndColumn { get; set; }
|
||||||
|
public SelectionData(int startLine, int startColumn, int endLine, int endColumn) {
|
||||||
|
StartLine = startLine;
|
||||||
|
StartColumn = startColumn;
|
||||||
|
EndLine = endLine;
|
||||||
|
EndColumn = endColumn;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parameters for the query execute request
|
/// Parameters for the query execute request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class QueryExecuteParams
|
public class QueryExecuteParams
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The text of the query to execute
|
/// The selection from the document
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string QueryText { get; set; }
|
public SelectionData QuerySelection { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// URI for the editor that is asking for the query execute
|
/// URI for the editor that is asking for the query execute
|
||||||
|
|||||||
@@ -86,7 +86,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
});
|
});
|
||||||
// NOTE: We only want to process batches that have statements (ie, ignore comments and empty lines)
|
// NOTE: We only want to process batches that have statements (ie, ignore comments and empty lines)
|
||||||
Batches = parseResult.Script.Batches.Where(b => b.Statements.Count > 0)
|
Batches = parseResult.Script.Batches.Where(b => b.Statements.Count > 0)
|
||||||
.Select(b => new Batch(b.Sql, b.StartLocation.LineNumber, outputFileFactory)).ToArray();
|
.Select(b => new Batch(b.Sql,
|
||||||
|
b.StartLocation.LineNumber - 1,
|
||||||
|
b.StartLocation.ColumnNumber - 1,
|
||||||
|
b.EndLocation.LineNumber - 1,
|
||||||
|
b.EndLocation.ColumnNumber - 1,
|
||||||
|
outputFileFactory)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
@@ -113,7 +118,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
Id = index,
|
Id = index,
|
||||||
HasError = batch.HasError,
|
HasError = batch.HasError,
|
||||||
Messages = batch.ResultMessages.ToArray(),
|
Messages = batch.ResultMessages.ToArray(),
|
||||||
ResultSetSummaries = batch.ResultSummaries
|
ResultSetSummaries = batch.ResultSummaries,
|
||||||
|
Selection = batch.Selection
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
|
||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||||
@@ -38,11 +39,13 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
private QueryExecutionService()
|
private QueryExecutionService()
|
||||||
{
|
{
|
||||||
ConnectionService = ConnectionService.Instance;
|
ConnectionService = ConnectionService.Instance;
|
||||||
|
WorkspaceService = WorkspaceService<SqlToolsSettings>.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal QueryExecutionService(ConnectionService connService)
|
internal QueryExecutionService(ConnectionService connService, WorkspaceService<SqlToolsSettings> workspaceService)
|
||||||
{
|
{
|
||||||
ConnectionService = connService;
|
ConnectionService = connService;
|
||||||
|
WorkspaceService = workspaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -78,6 +81,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ConnectionService ConnectionService { get; set; }
|
private ConnectionService ConnectionService { get; set; }
|
||||||
|
|
||||||
|
private WorkspaceService<SqlToolsSettings> WorkspaceService { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal storage of active queries, lazily constructed as a threadsafe dictionary
|
/// Internal storage of active queries, lazily constructed as a threadsafe dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -111,7 +116,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Register a handler for when the configuration changes
|
// Register a handler for when the configuration changes
|
||||||
WorkspaceService<SqlToolsSettings>.Instance.RegisterConfigChangeCallback((oldSettings, newSettings, eventContext) =>
|
WorkspaceService.RegisterConfigChangeCallback((oldSettings, newSettings, eventContext) =>
|
||||||
{
|
{
|
||||||
Settings.QueryExecutionSettings.Update(newSettings.QueryExecutionSettings);
|
Settings.QueryExecutionSettings.Update(newSettings.QueryExecutionSettings);
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
@@ -403,10 +408,36 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the current settings for executing the query with
|
// Retrieve the current settings for executing the query with
|
||||||
QueryExecutionSettings settings = WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.QueryExecutionSettings;
|
QueryExecutionSettings settings = WorkspaceService.CurrentSettings.QueryExecutionSettings;
|
||||||
|
|
||||||
|
// Get query text from the workspace.
|
||||||
|
ScriptFile queryFile = WorkspaceService.Workspace.GetFile(executeParams.OwnerUri);
|
||||||
|
|
||||||
|
string queryText;
|
||||||
|
|
||||||
|
if (executeParams.QuerySelection != null)
|
||||||
|
{
|
||||||
|
string[] queryTextArray = queryFile.GetLinesInRange(
|
||||||
|
new BufferRange(
|
||||||
|
new BufferPosition(
|
||||||
|
executeParams.QuerySelection.StartLine + 1,
|
||||||
|
executeParams.QuerySelection.StartColumn + 1
|
||||||
|
),
|
||||||
|
new BufferPosition(
|
||||||
|
executeParams.QuerySelection.EndLine + 1,
|
||||||
|
executeParams.QuerySelection.EndColumn + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
queryText = queryTextArray.Aggregate((a, b) => a + '\r' + '\n' + b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryText = queryFile.Contents;
|
||||||
|
}
|
||||||
|
|
||||||
// If we can't add the query now, it's assumed the query is in progress
|
// If we can't add the query now, it's assumed the query is in progress
|
||||||
Query newQuery = new Query(executeParams.QueryText, connectionInfo, settings, BufferFileFactory);
|
Query newQuery = new Query(queryText, connectionInfo, settings, BufferFileFactory);
|
||||||
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
|
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
|
||||||
{
|
{
|
||||||
await requestContext.SendResult(new QueryExecuteResult
|
await requestContext.SendResult(new QueryExecuteResult
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
|||||||
/// Gets or sets a string containing the full contents of the file.
|
/// Gets or sets a string containing the full contents of the file.
|
||||||
/// Setter for testing purposes only
|
/// Setter for testing purposes only
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Contents
|
public virtual string Contents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a default constructor for testing
|
/// Add a default constructor for testing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal ScriptFile()
|
public ScriptFile()
|
||||||
{
|
{
|
||||||
ClientFilePath = "test.sql";
|
ClientFilePath = "test.sql";
|
||||||
}
|
}
|
||||||
@@ -171,11 +171,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a range of lines from the file's contents.
|
/// Gets a range of lines from the file's contents. Virtual method to allow for
|
||||||
|
/// mocking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bufferRange">The buffer range from which lines will be extracted.</param>
|
/// <param name="bufferRange">The buffer range from which lines will be extracted.</param>
|
||||||
/// <returns>An array of strings from the specified range of the file.</returns>
|
/// <returns>An array of strings from the specified range of the file.</returns>
|
||||||
public string[] GetLinesInRange(BufferRange bufferRange)
|
public virtual string[] GetLinesInRange(BufferRange bufferRange)
|
||||||
{
|
{
|
||||||
this.ValidatePosition(bufferRange.Start);
|
this.ValidatePosition(bufferRange.Start);
|
||||||
this.ValidatePosition(bufferRange.End);
|
this.ValidatePosition(bufferRange.End);
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an open file in the workspace. If the file isn't open but
|
/// Gets an open file in the workspace. If the file isn't open but
|
||||||
/// exists on the filesystem, load and return it.
|
/// exists on the filesystem, load and return it. Virtual method to
|
||||||
|
/// allow for mocking
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filePath">The file path at which the script resides.</param>
|
/// <param name="filePath">The file path at which the script resides.</param>
|
||||||
/// <exception cref="FileNotFoundException">
|
/// <exception cref="FileNotFoundException">
|
||||||
@@ -59,7 +60,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// <paramref name="filePath"/> contains a null or empty string.
|
/// <paramref name="filePath"/> contains a null or empty string.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public ScriptFile GetFile(string filePath)
|
public virtual ScriptFile GetFile(string filePath)
|
||||||
{
|
{
|
||||||
Validate.IsNotNullOrWhitespaceString("filePath", filePath);
|
Validate.IsNotNullOrWhitespaceString("filePath", filePath);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
|
|
||||||
#region Singleton Instance Implementation
|
#region Singleton Instance Implementation
|
||||||
|
|
||||||
private static readonly Lazy<WorkspaceService<TConfig>> instance = new Lazy<WorkspaceService<TConfig>>(() => new WorkspaceService<TConfig>());
|
private static Lazy<WorkspaceService<TConfig>> instance = new Lazy<WorkspaceService<TConfig>>(() => new WorkspaceService<TConfig>());
|
||||||
|
|
||||||
public static WorkspaceService<TConfig> Instance
|
public static WorkspaceService<TConfig> Instance
|
||||||
{
|
{
|
||||||
@@ -52,8 +52,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
public Workspace Workspace { get; private set; }
|
/// <summary>
|
||||||
|
/// Workspace object for the service. Virtual to allow for mocking
|
||||||
|
/// </summary>
|
||||||
|
public virtual Workspace Workspace { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current settings for the workspace
|
||||||
|
/// </summary>
|
||||||
public TConfig CurrentSettings { get; internal set; }
|
public TConfig CurrentSettings { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ using System;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -18,10 +21,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void CancelInProgressQueryTest()
|
public void CancelInProgressQueryTest()
|
||||||
{
|
{
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.Setup(file => file.GetLinesInRange(It.IsAny<BufferRange>()))
|
||||||
|
.Returns(new string[] { Common.StandardQuery });
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
|
|
||||||
// If:
|
// If:
|
||||||
// ... I request a query (doesn't matter what kind) and execute it
|
// ... I request a query (doesn't matter what kind) and execute it
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.GetSubSectionDocument(), OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest =
|
var executeRequest =
|
||||||
RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
@@ -45,10 +57,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void CancelExecutedQueryTest()
|
public void CancelExecutedQueryTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request a query (doesn't matter what kind) and wait for execution
|
// ... I request a query (doesn't matter what kind) and wait for execution
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams {QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri};
|
var executeParams = new QueryExecuteParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
|
||||||
var executeRequest =
|
var executeRequest =
|
||||||
RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
@@ -71,9 +91,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void CancelNonExistantTest()
|
public void CancelNonExistantTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// If:
|
// If:
|
||||||
// ... I request to cancel a query that doesn't exist
|
// ... I request to cancel a query that doesn't exist
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false, workspaceService.Object);
|
||||||
var cancelParams = new QueryCancelParams {OwnerUri = "Doesn't Exist"};
|
var cancelParams = new QueryCancelParams {OwnerUri = "Doesn't Exist"};
|
||||||
QueryCancelResult result = null;
|
QueryCancelResult result = null;
|
||||||
var cancelRequest = GetQueryCancelResultContextMock(qcr => result = qcr, null);
|
var cancelRequest = GetQueryCancelResultContextMock(qcr => result = qcr, null);
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ using Microsoft.SqlServer.Management.SqlParser.Binder;
|
|||||||
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
|
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
|
||||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
|
||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Moq.Protected;
|
using Moq.Protected;
|
||||||
@@ -29,6 +31,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
{
|
{
|
||||||
public class Common
|
public class Common
|
||||||
{
|
{
|
||||||
|
public const SelectionData WholeDocument = null;
|
||||||
|
|
||||||
public const string StandardQuery = "SELECT * FROM sys.objects";
|
public const string StandardQuery = "SELECT * FROM sys.objects";
|
||||||
|
|
||||||
public const string InvalidQuery = "SELECT *** FROM sys.objects";
|
public const string InvalidQuery = "SELECT *** FROM sys.objects";
|
||||||
@@ -72,9 +76,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SelectionData GetSubSectionDocument()
|
||||||
|
{
|
||||||
|
return new SelectionData(0, 0, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
public static Batch GetBasicExecutedBatch()
|
public static Batch GetBasicExecutedBatch()
|
||||||
{
|
{
|
||||||
Batch batch = new Batch(StandardQuery, 1, GetFileStreamFactory());
|
Batch batch = new Batch(StandardQuery, 0, 0, 2, 2, GetFileStreamFactory());
|
||||||
batch.Execute(CreateTestConnection(new[] {StandardTestData}, false), CancellationToken.None).Wait();
|
batch.Execute(CreateTestConnection(new[] {StandardTestData}, false), CancellationToken.None).Wait();
|
||||||
return batch;
|
return batch;
|
||||||
}
|
}
|
||||||
@@ -272,7 +281,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QueryExecutionService GetPrimedExecutionService(ISqlConnectionFactory factory, bool isConnected)
|
public static QueryExecutionService GetPrimedExecutionService(ISqlConnectionFactory factory, bool isConnected, WorkspaceService<SqlToolsSettings> workspaceService)
|
||||||
{
|
{
|
||||||
var connectionService = new ConnectionService(factory);
|
var connectionService = new ConnectionService(factory);
|
||||||
if (isConnected)
|
if (isConnected)
|
||||||
@@ -283,7 +292,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
OwnerUri = OwnerUri
|
OwnerUri = OwnerUri
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return new QueryExecutionService(connectionService) {BufferFileStreamFactory = GetFileStreamFactory()};
|
return new QueryExecutionService(connectionService, workspaceService) {BufferFileStreamFactory = GetFileStreamFactory()};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ using System;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -18,17 +21,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void DisposeExecutedQuery()
|
public void DisposeExecutedQuery()
|
||||||
{
|
{
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns("doesn't matter");
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request a query (doesn't matter what kind)
|
// ... I request a query (doesn't matter what kind)
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams {QueryText = "Doesn'tMatter", OwnerUri = Common.OwnerUri};
|
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
|
||||||
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
// ... And then I dispose of the query
|
// ... And then I dispose of the query
|
||||||
var disposeParams = new QueryDisposeParams {OwnerUri = Common.OwnerUri};
|
var disposeParams = new QueryDisposeParams {OwnerUri = Common.OwnerUri};
|
||||||
QueryDisposeResult result = null;
|
QueryDisposeResult result = null;
|
||||||
var disposeRequest = GetQueryDisposeResultContextMock(qdr => result = qdr, null);
|
var disposeRequest = GetQueryDisposeResultContextMock(qdr => {
|
||||||
|
result = qdr;
|
||||||
|
}, null);
|
||||||
queryService.HandleDisposeRequest(disposeParams, disposeRequest.Object).Wait();
|
queryService.HandleDisposeRequest(disposeParams, disposeRequest.Object).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -42,9 +54,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryDisposeMissingQuery()
|
public void QueryDisposeMissingQuery()
|
||||||
{
|
{
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// If:
|
// If:
|
||||||
// ... I attempt to dispose a query that doesn't exist
|
// ... I attempt to dispose a query that doesn't exist
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false, workspaceService.Object);
|
||||||
var disposeParams = new QueryDisposeParams {OwnerUri = Common.OwnerUri};
|
var disposeParams = new QueryDisposeParams {OwnerUri = Common.OwnerUri};
|
||||||
QueryDisposeResult result = null;
|
QueryDisposeResult result = null;
|
||||||
var disposeRequest = GetQueryDisposeResultContextMock(qdr => result = qdr, null);
|
var disposeRequest = GetQueryDisposeResultContextMock(qdr => result = qdr, null);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
public void BatchCreationTest()
|
public void BatchCreationTest()
|
||||||
{
|
{
|
||||||
// If I create a new batch...
|
// If I create a new batch...
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 2, 2, Common.GetFileStreamFactory());
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
// ... The text of the batch should be stored
|
// ... The text of the batch should be stored
|
||||||
@@ -45,14 +46,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
Assert.Empty(batch.ResultMessages);
|
Assert.Empty(batch.ResultMessages);
|
||||||
|
|
||||||
// ... The start line of the batch should be 0
|
// ... The start line of the batch should be 0
|
||||||
Assert.Equal(0, batch.StartLine);
|
Assert.Equal(0, batch.Selection.StartLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BatchExecuteNoResultSets()
|
public void BatchExecuteNoResultSets()
|
||||||
{
|
{
|
||||||
// If I execute a query that should get no result sets
|
// If I execute a query that should get no result sets
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 2, 2, Common.GetFileStreamFactory());
|
||||||
batch.Execute(GetConnection(Common.CreateTestConnectionInfo(null, false)), CancellationToken.None).Wait();
|
batch.Execute(GetConnection(Common.CreateTestConnectionInfo(null, false)), CancellationToken.None).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -82,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
ConnectionInfo ci = Common.CreateTestConnectionInfo(new[] { Common.StandardTestData }, false);
|
ConnectionInfo ci = Common.CreateTestConnectionInfo(new[] { Common.StandardTestData }, false);
|
||||||
|
|
||||||
// If I execute a query that should get one result set
|
// If I execute a query that should get one result set
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 2, 2, Common.GetFileStreamFactory());
|
||||||
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -115,7 +116,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
ConnectionInfo ci = Common.CreateTestConnectionInfo(dataset, false);
|
ConnectionInfo ci = Common.CreateTestConnectionInfo(dataset, false);
|
||||||
|
|
||||||
// If I execute a query that should get two result sets
|
// If I execute a query that should get two result sets
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 1, 1, Common.GetFileStreamFactory());
|
||||||
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -161,7 +162,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
ConnectionInfo ci = Common.CreateTestConnectionInfo(null, true);
|
ConnectionInfo ci = Common.CreateTestConnectionInfo(null, true);
|
||||||
|
|
||||||
// If I execute a batch that is invalid
|
// If I execute a batch that is invalid
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 2, 2, Common.GetFileStreamFactory());
|
||||||
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -183,7 +184,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
ConnectionInfo ci = Common.CreateTestConnectionInfo(new[] { Common.StandardTestData }, false);
|
ConnectionInfo ci = Common.CreateTestConnectionInfo(new[] { Common.StandardTestData }, false);
|
||||||
|
|
||||||
// If I execute a batch
|
// If I execute a batch
|
||||||
Batch batch = new Batch(Common.StandardQuery, 1, Common.GetFileStreamFactory());
|
Batch batch = new Batch(Common.StandardQuery, 0, 0, 2, 2, Common.GetFileStreamFactory());
|
||||||
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
batch.Execute(GetConnection(ci), CancellationToken.None).Wait();
|
||||||
|
|
||||||
// Then:
|
// Then:
|
||||||
@@ -213,7 +214,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
// ... I create a batch that has an empty query
|
// ... I create a batch that has an empty query
|
||||||
// Then:
|
// Then:
|
||||||
// ... It should throw an exception
|
// ... It should throw an exception
|
||||||
Assert.Throws<ArgumentException>(() => new Batch(query, 1, Common.GetFileStreamFactory()));
|
Assert.Throws<ArgumentException>(() => new Batch(query, 0, 0, 2, 2, Common.GetFileStreamFactory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -223,7 +224,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
// ... I create a batch that has no file stream factory
|
// ... I create a batch that has no file stream factory
|
||||||
// Then:
|
// Then:
|
||||||
// ... It should throw an exception
|
// ... It should throw an exception
|
||||||
Assert.Throws<ArgumentNullException>(() => new Batch("stuff", 1, null));
|
Assert.Throws<ArgumentNullException>(() => new Batch("stuff", 0, 0, 2, 2, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -420,10 +421,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
// ... Default settings are stored in the workspace service
|
// ... Default settings are stored in the workspace service
|
||||||
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings = new SqlToolsSettings();
|
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings = new SqlToolsSettings();
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a valid query with no results
|
// ... I request to execute a valid query with no results
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var queryParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
|
|
||||||
QueryExecuteResult result = null;
|
QueryExecuteResult result = null;
|
||||||
QueryExecuteCompleteParams completeParams = null;
|
QueryExecuteCompleteParams completeParams = null;
|
||||||
@@ -452,10 +460,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteValidResultsTest()
|
public void QueryExecuteValidResultsTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a valid query with results
|
// ... I request to execute a valid query with results
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(new[] { Common.StandardTestData }, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(new[] { Common.StandardTestData }, false), true,
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QueryText = Common.StandardQuery };
|
workspaceService.Object);
|
||||||
|
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument };
|
||||||
|
|
||||||
QueryExecuteResult result = null;
|
QueryExecuteResult result = null;
|
||||||
QueryExecuteCompleteParams completeParams = null;
|
QueryExecuteCompleteParams completeParams = null;
|
||||||
@@ -485,10 +502,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteUnconnectedUriTest()
|
public void QueryExecuteUnconnectedUriTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a query using a file URI that isn't connected
|
// ... I request to execute a query using a file URI that isn't connected
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), false, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = "notConnected", QueryText = Common.StandardQuery };
|
var queryParams = new QueryExecuteParams { OwnerUri = "notConnected", QuerySelection = Common.WholeDocument };
|
||||||
|
|
||||||
QueryExecuteResult result = null;
|
QueryExecuteResult result = null;
|
||||||
var requestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(qer => result = qer, QueryExecuteCompleteEvent.Type, null, null);
|
var requestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(qer => result = qer, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
@@ -508,10 +527,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteInProgressTest()
|
public void QueryExecuteInProgressTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
|
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a query
|
// ... I request to execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QueryText = Common.StandardQuery };
|
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument };
|
||||||
|
|
||||||
// Note, we don't care about the results of the first request
|
// Note, we don't care about the results of the first request
|
||||||
var firstRequestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var firstRequestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
@@ -537,10 +565,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteCompletedTest()
|
public void QueryExecuteCompletedTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
|
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a query
|
// ... I request to execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QueryText = Common.StandardQuery };
|
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument };
|
||||||
|
|
||||||
// Note, we don't care about the results of the first request
|
// Note, we don't care about the results of the first request
|
||||||
var firstRequestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var firstRequestContext = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
@@ -565,14 +602,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("")]
|
|
||||||
[InlineData(null)]
|
[InlineData(null)]
|
||||||
public void QueryExecuteMissingQueryTest(string query)
|
public void QueryExecuteMissingSelectionTest(SelectionData selection)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns("");
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a query with a missing query string
|
// ... I request to execute a query with a missing query string
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QueryText = query };
|
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QuerySelection = selection };
|
||||||
|
|
||||||
QueryExecuteResult result = null;
|
QueryExecuteResult result = null;
|
||||||
var requestContext =
|
var requestContext =
|
||||||
@@ -594,10 +638,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteInvalidQueryTest()
|
public void QueryExecuteInvalidQueryTest()
|
||||||
{
|
{
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I request to execute a query that is invalid
|
// ... I request to execute a query that is invalid
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, true), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, true), true, workspaceService.Object);
|
||||||
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QueryText = Common.StandardQuery };
|
var queryParams = new QueryExecuteParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument };
|
||||||
|
|
||||||
QueryExecuteResult result = null;
|
QueryExecuteResult result = null;
|
||||||
QueryExecuteCompleteParams complete = null;
|
QueryExecuteCompleteParams complete = null;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ using System.Runtime.InteropServices;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -25,9 +28,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsCsvSuccessTest()
|
public void SaveResultsAsCsvSuccessTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
@@ -63,9 +74,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsCsvExceptionTest()
|
public void SaveResultsAsCsvExceptionTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
|
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
@@ -95,9 +115,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsCsvQueryNotFoundTest()
|
public void SaveResultsAsCsvQueryNotFoundTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
@@ -125,9 +147,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsJsonSuccessTest()
|
public void SaveResultsAsJsonSuccessTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
@@ -162,9 +192,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsJsonExceptionTest()
|
public void SaveResultsAsJsonExceptionTest()
|
||||||
{
|
{
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
@@ -194,9 +231,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SaveResultsAsJsonQueryNotFoundTest()
|
public void SaveResultsAsJsonQueryNotFoundTest()
|
||||||
{
|
{
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// Execute a query
|
// Execute a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
var executeRequest = GetQueryExecuteResultContextMock(null, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -130,11 +132,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task SubsetServiceValidTest()
|
public async Task SubsetServiceValidTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I have a query that has results (doesn't matter what)
|
// ... I have a query that has results (doesn't matter what)
|
||||||
var queryService = Common.GetPrimedExecutionService(
|
var queryService = Common.GetPrimedExecutionService(
|
||||||
Common.CreateMockFactory(new[] {Common.StandardTestData}, false), true);
|
Common.CreateMockFactory(new[] {Common.StandardTestData}, false), true,
|
||||||
var executeParams = new QueryExecuteParams {QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri};
|
workspaceService.Object);
|
||||||
|
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
|
||||||
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
|
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
|
||||||
|
|
||||||
@@ -156,9 +167,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SubsetServiceMissingQueryTest()
|
public void SubsetServiceMissingQueryTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// If:
|
// If:
|
||||||
// ... I ask for a set of results for a file that hasn't executed a query
|
// ... I ask for a set of results for a file that hasn't executed a query
|
||||||
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true);
|
var queryService = Common.GetPrimedExecutionService(Common.CreateMockFactory(null, false), true, workspaceService.Object);
|
||||||
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
|
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
|
||||||
QueryExecuteSubsetResult result = null;
|
QueryExecuteSubsetResult result = null;
|
||||||
var subsetRequest = GetQuerySubsetResultContextMock(qesr => result = qesr, null);
|
var subsetRequest = GetQuerySubsetResultContextMock(qesr => result = qesr, null);
|
||||||
@@ -176,11 +189,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SubsetServiceUnexecutedQueryTest()
|
public void SubsetServiceUnexecutedQueryTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Set up file for returning the query
|
||||||
|
var fileMock = new Mock<ScriptFile>();
|
||||||
|
fileMock.SetupGet(file => file.Contents).Returns(Common.StandardQuery);
|
||||||
|
// Set up workspace mock
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
|
workspaceService.Setup(service => service.Workspace.GetFile(It.IsAny<string>()))
|
||||||
|
.Returns(fileMock.Object);
|
||||||
// If:
|
// If:
|
||||||
// ... I have a query that hasn't finished executing (doesn't matter what)
|
// ... I have a query that hasn't finished executing (doesn't matter what)
|
||||||
var queryService = Common.GetPrimedExecutionService(
|
var queryService = Common.GetPrimedExecutionService(
|
||||||
Common.CreateMockFactory(new[] { Common.StandardTestData }, false), true);
|
Common.CreateMockFactory(new[] { Common.StandardTestData }, false), true,
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
workspaceService.Object);
|
||||||
|
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
queryService.ActiveQueries[Common.OwnerUri].HasExecuted = false;
|
queryService.ActiveQueries[Common.OwnerUri].HasExecuted = false;
|
||||||
@@ -203,11 +225,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void SubsetServiceOutOfRangeSubsetTest()
|
public void SubsetServiceOutOfRangeSubsetTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var workspaceService = new Mock<WorkspaceService<SqlToolsSettings>>();
|
||||||
// If:
|
// If:
|
||||||
// ... I have a query that doesn't have any result sets
|
// ... I have a query that doesn't have any result sets
|
||||||
var queryService = Common.GetPrimedExecutionService(
|
var queryService = Common.GetPrimedExecutionService(
|
||||||
Common.CreateMockFactory(null, false), true);
|
Common.CreateMockFactory(null, false), true,
|
||||||
var executeParams = new QueryExecuteParams { QueryText = Common.StandardQuery, OwnerUri = Common.OwnerUri };
|
workspaceService.Object);
|
||||||
|
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||||
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
var executeRequest = RequestContextMocks.SetupRequestContextMock<QueryExecuteResult, QueryExecuteCompleteParams>(null, QueryExecuteCompleteEvent.Type, null, null);
|
||||||
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user