query/executeString (#217)

This is a small API addition that allows us to execute queries directly as strings. This will make it easier to execute queries outside the confines of a workspace like VS Code.

* Refactor execution requests and events are now named less redundantly and moved into a separate namespace for organization. This is the bulk of the changes.
    * QueryExecuteBatchNotification -> ExecuteRequests/BatchEvents
    * QueryExecuteMessageNotification -> ExecuteRequests/MessageEvent
    * QueryExecuteCompleteNotification -> ExecuteRequests/QueryCompleteEvent
    * QueryExecuteResultSetCompleteNotification -> ExecuteRequests/ResultSetEvents
    * QueryExecuteSubsetRequest -> SubsetRequest.cs
* Creating an inheritance pattern where
    * `ExecuteRequestParamsBase` has execution options and ID for a query execute request
    * `ExecuteDocumentSelectionParams` inherits from `ExecuteRequestParamsBase` and provides a document selection
    * `ExecuteStringParams`  inherits from `ExecuteRequestParamsBase` and provides the query text
* Adding a helper method to get SQL text based on request type
* Through the AWESOME POWER OF POLYMORPHISM, we are able to create a request for executing straight SQL basically for free.
* **Breaking change:** query/execute => query/executeDocumentSelection to make it more obvious what is expected.
* Adding unit tests for the code that gets SQL text

* Refactoring of execute contracts into their own namespace

* Refactoring application

* Adding new request for executing queries as strings

* Adding forgotten string request

* Changing the logic for checking the request param types

* Removing redundant declarations
This commit is contained in:
Benjamin Russell
2017-01-30 15:24:12 -08:00
committed by GitHub
parent 41d38b2107
commit 857b526553
22 changed files with 428 additions and 274 deletions

View File

@@ -4,13 +4,13 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{ {
/// <summary> /// <summary>
/// Parameters to be sent back as part of a QueryExecuteBatchCompleteEvent to indicate that a /// Parameters to be sent back as part of a batch start or complete event to indicate that a
/// batch of a query completed. /// batch of a query started or completed.
/// </summary> /// </summary>
public class QueryExecuteBatchNotificationParams public class BatchEventParams
{ {
/// <summary> /// <summary>
/// Summary of the batch that just completed /// Summary of the batch that just completed
@@ -23,17 +23,17 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public string OwnerUri { get; set; } public string OwnerUri { get; set; }
} }
public class QueryExecuteBatchCompleteEvent public class BatchCompleteEvent
{ {
public static readonly public static readonly
EventType<QueryExecuteBatchNotificationParams> Type = EventType<BatchEventParams> Type =
EventType<QueryExecuteBatchNotificationParams>.Create("query/batchComplete"); EventType<BatchEventParams>.Create("query/batchComplete");
} }
public class QueryExecuteBatchStartEvent public class BatchStartEvent
{ {
public static readonly public static readonly
EventType<QueryExecuteBatchNotificationParams> Type = EventType<BatchEventParams> Type =
EventType<QueryExecuteBatchNotificationParams>.Create("query/batchStart"); EventType<BatchEventParams>.Create("query/batchStart");
} }
} }

View File

@@ -0,0 +1,27 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
/// <summary>
/// Parameters for executing a query from a document open in the workspace
/// </summary>
public class ExecuteDocumentSelectionParams : ExecuteRequestParamsBase
{
/// <summary>
/// The selection from the document
/// </summary>
public SelectionData QuerySelection { get; set; }
}
public class ExecuteDocumentSelectionRequest
{
public static readonly
RequestType<ExecuteDocumentSelectionParams, ExecuteRequestResult> Type =
RequestType<ExecuteDocumentSelectionParams, ExecuteRequestResult>.Create("query/executeDocumentSelection");
}
}

View File

@@ -0,0 +1,23 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
/// <summary>
/// Basic parameters that are required for executing a query
/// </summary>
public abstract class ExecuteRequestParamsBase
{
/// <summary>
/// URI for the editor that is asking for the query execute
/// </summary>
public string OwnerUri { get; set; }
/// <summary>
/// Execution plan options
/// </summary>
public ExecutionPlanOptions ExecutionPlanOptions { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
/// <summary>
/// Parameters for the query execute result
/// </summary>
public class ExecuteRequestResult
{
}
}

View File

@@ -0,0 +1,27 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
/// <summary>
/// Parameters for executing a query directly
/// </summary>
public class ExecuteStringParams : ExecuteRequestParamsBase
{
/// <summary>
/// The query to execute
/// </summary>
public string Query { get; set; }
}
public class ExecuteStringRequest
{
public static readonly
RequestType<ExecuteStringParams, ExecuteRequestResult> Type =
RequestType<ExecuteStringParams, ExecuteRequestResult>.Create("query/executeString");
}
}

View File

@@ -5,12 +5,12 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{ {
/// <summary> /// <summary>
/// Parameters to be sent back with a message notification /// Parameters to be sent back with a message notification
/// </summary> /// </summary>
public class QueryExecuteMessageParams public class MessageParams
{ {
/// <summary> /// <summary>
/// URI for the editor that owns the query /// URI for the editor that owns the query
@@ -23,10 +23,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public ResultMessage Message { get; set; } public ResultMessage Message { get; set; }
} }
public class QueryExecuteMessageEvent public class MessageEvent
{ {
public static readonly public static readonly
EventType<QueryExecuteMessageParams> Type = EventType<MessageParams> Type =
EventType<QueryExecuteMessageParams>.Create("query/message"); EventType<MessageParams>.Create("query/message");
} }
} }

View File

@@ -5,12 +5,12 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{ {
/// <summary> /// <summary>
/// Parameters to be sent back with a query execution complete event /// Parameters to be sent back with a query execution complete event
/// </summary> /// </summary>
public class QueryExecuteCompleteParams public class QueryCompleteParams
{ {
/// <summary> /// <summary>
/// URI for the editor that owns the query /// URI for the editor that owns the query
@@ -23,10 +23,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public BatchSummary[] BatchSummaries { get; set; } public BatchSummary[] BatchSummaries { get; set; }
} }
public class QueryExecuteCompleteEvent public class QueryCompleteEvent
{ {
public static readonly public static readonly
EventType<QueryExecuteCompleteParams> Type = EventType<QueryCompleteParams> Type =
EventType<QueryExecuteCompleteParams>.Create("query/complete"); EventType<QueryCompleteParams>.Create("query/complete");
} }
} }

View File

@@ -4,19 +4,22 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{ {
public class QueryExecuteResultSetCompleteParams /// <summary>
/// Parameters to return when a result set is started or completed
/// </summary>
public class ResultSetEventParams
{ {
public ResultSetSummary ResultSetSummary { get; set; } public ResultSetSummary ResultSetSummary { get; set; }
public string OwnerUri { get; set; } public string OwnerUri { get; set; }
} }
public class QueryExecuteResultSetCompleteEvent public class ResultSetCompleteEvent
{ {
public static readonly public static readonly
EventType<QueryExecuteResultSetCompleteParams> Type = EventType<ResultSetEventParams> Type =
EventType<QueryExecuteResultSetCompleteParams>.Create("query/resultSetComplete"); EventType<ResultSetEventParams>.Create("query/resultSetComplete");
} }
} }

View File

@@ -1,45 +0,0 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
{
/// <summary>
/// Parameters for the query execute request
/// </summary>
public class QueryExecuteParams
{
/// <summary>
/// The selection from the document
/// </summary>
public SelectionData QuerySelection { get; set; }
/// <summary>
/// URI for the editor that is asking for the query execute
/// </summary>
public string OwnerUri { get; set; }
/// <summary>
/// Execution plan options
/// </summary>
public ExecutionPlanOptions ExecutionPlanOptions { get; set; }
}
/// <summary>
/// Parameters for the query execute result
/// </summary>
public class QueryExecuteResult
{
}
public class QueryExecuteRequest
{
public static readonly
RequestType<QueryExecuteParams, QueryExecuteResult> Type =
RequestType<QueryExecuteParams, QueryExecuteResult>.Create("query/execute");
}
}

View File

@@ -10,7 +10,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
/// <summary> /// <summary>
/// Parameters for a query result subset retrieval request /// Parameters for a query result subset retrieval request
/// </summary> /// </summary>
public class QueryExecuteSubsetParams public class SubsetParams
{ {
/// <summary> /// <summary>
/// URI for the file that owns the query to look up the results for /// URI for the file that owns the query to look up the results for
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
/// <summary> /// <summary>
/// Parameters for the result of a subset retrieval request /// Parameters for the result of a subset retrieval request
/// </summary> /// </summary>
public class QueryExecuteSubsetResult public class SubsetResult
{ {
/// <summary> /// <summary>
/// Subset request error messages. Optional, can be set to null to indicate no errors /// Subset request error messages. Optional, can be set to null to indicate no errors
@@ -57,10 +57,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public ResultSetSubset ResultSubset { get; set; } public ResultSetSubset ResultSubset { get; set; }
} }
public class QueryExecuteSubsetRequest public class SubsetRequest
{ {
public static readonly public static readonly
RequestType<QueryExecuteSubsetParams, QueryExecuteSubsetResult> Type = RequestType<SubsetParams, SubsetResult> Type =
RequestType<QueryExecuteSubsetParams, QueryExecuteSubsetResult>.Create("query/subset"); RequestType<SubsetParams, SubsetResult>.Create("query/subset");
} }
} }

View File

@@ -5,12 +5,12 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Hosting; using Microsoft.SqlTools.ServiceLayer.Hosting;
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.QueryExecution.Contracts.ExecuteRequests;
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.Utility; using Microsoft.SqlTools.ServiceLayer.Utility;
@@ -26,15 +26,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
{ {
#region Singleton Instance Implementation #region Singleton Instance Implementation
private static readonly Lazy<QueryExecutionService> instance = new Lazy<QueryExecutionService>(() => new QueryExecutionService()); private static readonly Lazy<QueryExecutionService> LazyInstance = new Lazy<QueryExecutionService>(() => new QueryExecutionService());
/// <summary> /// <summary>
/// Singleton instance of the query execution service /// Singleton instance of the query execution service
/// </summary> /// </summary>
public static QueryExecutionService Instance public static QueryExecutionService Instance => LazyInstance.Value;
{
get { return instance.Value; }
}
private QueryExecutionService() private QueryExecutionService()
{ {
@@ -120,8 +117,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
public void InitializeService(ServiceHost serviceHost) public void InitializeService(ServiceHost serviceHost)
{ {
// Register handlers for requests // Register handlers for requests
serviceHost.SetRequestHandler(QueryExecuteRequest.Type, HandleExecuteRequest); serviceHost.SetRequestHandler(ExecuteDocumentSelectionRequest.Type, HandleExecuteRequest);
serviceHost.SetRequestHandler(QueryExecuteSubsetRequest.Type, HandleResultSubsetRequest); serviceHost.SetRequestHandler(ExecuteStringRequest.Type, HandleExecuteRequest);
serviceHost.SetRequestHandler(SubsetRequest.Type, HandleResultSubsetRequest);
serviceHost.SetRequestHandler(QueryDisposeRequest.Type, HandleDisposeRequest); serviceHost.SetRequestHandler(QueryDisposeRequest.Type, HandleDisposeRequest);
serviceHost.SetRequestHandler(QueryCancelRequest.Type, HandleCancelRequest); serviceHost.SetRequestHandler(QueryCancelRequest.Type, HandleCancelRequest);
serviceHost.SetRequestHandler(SaveResultsAsCsvRequest.Type, HandleSaveResultsAsCsvRequest); serviceHost.SetRequestHandler(SaveResultsAsCsvRequest.Type, HandleSaveResultsAsCsvRequest);
@@ -146,23 +144,23 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
#region Request Handlers #region Request Handlers
/// <summary> /// <summary>
/// Handles request to execute the query /// Handles request to execute a selection of a document in the workspace service
/// </summary> /// </summary>
public async Task HandleExecuteRequest(QueryExecuteParams executeParams, public async Task HandleExecuteRequest(ExecuteRequestParamsBase executeDocumentSelectionParams,
RequestContext<QueryExecuteResult> requestContext) RequestContext<ExecuteRequestResult> requestContext)
{ {
// Get a query new active query // Get a query new active query
Query newQuery = await CreateAndActivateNewQuery(executeParams, requestContext); Query newQuery = await CreateAndActivateNewQuery(executeDocumentSelectionParams, requestContext);
// Execute the query -- asynchronously // Execute the query -- asynchronously
ExecuteAndCompleteQuery(executeParams, requestContext, newQuery); ExecuteAndCompleteQuery(executeDocumentSelectionParams, requestContext, newQuery);
} }
/// <summary> /// <summary>
/// Handles a request to get a subset of the results of this query /// Handles a request to get a subset of the results of this query
/// </summary> /// </summary>
public async Task HandleResultSubsetRequest(QueryExecuteSubsetParams subsetParams, public async Task HandleResultSubsetRequest(SubsetParams subsetParams,
RequestContext<QueryExecuteSubsetResult> requestContext) RequestContext<SubsetResult> requestContext)
{ {
try try
{ {
@@ -170,7 +168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
Query query; Query query;
if (!ActiveQueries.TryGetValue(subsetParams.OwnerUri, out query)) if (!ActiveQueries.TryGetValue(subsetParams.OwnerUri, out query))
{ {
await requestContext.SendResult(new QueryExecuteSubsetResult await requestContext.SendResult(new SubsetResult
{ {
Message = SR.QueryServiceRequestsNoQuery Message = SR.QueryServiceRequestsNoQuery
}); });
@@ -178,7 +176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
} }
// Retrieve the requested subset and return it // Retrieve the requested subset and return it
var result = new QueryExecuteSubsetResult var result = new SubsetResult
{ {
Message = null, Message = null,
ResultSubset = await query.GetSubset(subsetParams.BatchIndex, ResultSubset = await query.GetSubset(subsetParams.BatchIndex,
@@ -189,7 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
catch (InvalidOperationException ioe) catch (InvalidOperationException ioe)
{ {
// Return the error as a result // Return the error as a result
await requestContext.SendResult(new QueryExecuteSubsetResult await requestContext.SendResult(new SubsetResult
{ {
Message = ioe.Message Message = ioe.Message
}); });
@@ -197,7 +195,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
catch (ArgumentOutOfRangeException aoore) catch (ArgumentOutOfRangeException aoore)
{ {
// Return the error as a result // Return the error as a result
await requestContext.SendResult(new QueryExecuteSubsetResult await requestContext.SendResult(new SubsetResult
{ {
Message = aoore.Message Message = aoore.Message
}); });
@@ -342,7 +340,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
#region Private Helpers #region Private Helpers
private async Task<Query> CreateAndActivateNewQuery(QueryExecuteParams executeParams, RequestContext<QueryExecuteResult> requestContext) private async Task<Query> CreateAndActivateNewQuery(ExecuteRequestParamsBase executeParams, RequestContext<ExecuteRequestResult> requestContext)
{ {
try try
{ {
@@ -368,34 +366,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Apply execution parameter settings // Apply execution parameter settings
settings.ExecutionPlanOptions = executeParams.ExecutionPlanOptions; settings.ExecutionPlanOptions = executeParams.ExecutionPlanOptions;
// 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(queryText, connectionInfo, settings, BufferFileFactory); Query newQuery = new Query(GetSqlText(executeParams), connectionInfo, settings, BufferFileFactory);
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery)) if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
{ {
await requestContext.SendError(SR.QueryServiceQueryInProgress); await requestContext.SendError(SR.QueryServiceQueryInProgress);
@@ -404,7 +376,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
} }
// Send the result stating that the query was successfully started // Send the result stating that the query was successfully started
await requestContext.SendResult(new QueryExecuteResult()); await requestContext.SendResult(new ExecuteRequestResult());
return newQuery; return newQuery;
} }
@@ -415,7 +387,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
} }
} }
private static void ExecuteAndCompleteQuery(QueryExecuteParams executeParams, RequestContext<QueryExecuteResult> requestContext, Query query) private static void ExecuteAndCompleteQuery(ExecuteRequestParamsBase executeDocumentSelectionParams, RequestContext<ExecuteRequestResult> requestContext, Query query)
{ {
// Skip processing if the query is null // Skip processing if the query is null
if (query == null) if (query == null)
@@ -427,24 +399,24 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
Query.QueryAsyncEventHandler callback = async q => Query.QueryAsyncEventHandler callback = async q =>
{ {
// Send back the results // Send back the results
QueryExecuteCompleteParams eventParams = new QueryExecuteCompleteParams QueryCompleteParams eventParams = new QueryCompleteParams
{ {
OwnerUri = executeParams.OwnerUri, OwnerUri = executeDocumentSelectionParams.OwnerUri,
BatchSummaries = q.BatchSummaries BatchSummaries = q.BatchSummaries
}; };
await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams); await requestContext.SendEvent(QueryCompleteEvent.Type, eventParams);
}; };
Query.QueryAsyncErrorEventHandler errorCallback = async errorMessage => Query.QueryAsyncErrorEventHandler errorCallback = async errorMessage =>
{ {
// Send back the error message // Send back the error message
QueryExecuteCompleteParams eventParams = new QueryExecuteCompleteParams QueryCompleteParams eventParams = new QueryCompleteParams
{ {
OwnerUri = executeParams.OwnerUri, OwnerUri = executeDocumentSelectionParams.OwnerUri,
//Message = errorMessage //Message = errorMessage
}; };
await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams); await requestContext.SendEvent(QueryCompleteEvent.Type, eventParams);
}; };
query.QueryCompleted += callback; query.QueryCompleted += callback;
@@ -454,48 +426,48 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Setup the batch callbacks // Setup the batch callbacks
Batch.BatchAsyncEventHandler batchStartCallback = async b => Batch.BatchAsyncEventHandler batchStartCallback = async b =>
{ {
QueryExecuteBatchNotificationParams eventParams = new QueryExecuteBatchNotificationParams BatchEventParams eventParams = new BatchEventParams
{ {
BatchSummary = b.Summary, BatchSummary = b.Summary,
OwnerUri = executeParams.OwnerUri OwnerUri = executeDocumentSelectionParams.OwnerUri
}; };
await requestContext.SendEvent(QueryExecuteBatchStartEvent.Type, eventParams); await requestContext.SendEvent(BatchStartEvent.Type, eventParams);
}; };
query.BatchStarted += batchStartCallback; query.BatchStarted += batchStartCallback;
Batch.BatchAsyncEventHandler batchCompleteCallback = async b => Batch.BatchAsyncEventHandler batchCompleteCallback = async b =>
{ {
QueryExecuteBatchNotificationParams eventParams = new QueryExecuteBatchNotificationParams BatchEventParams eventParams = new BatchEventParams
{ {
BatchSummary = b.Summary, BatchSummary = b.Summary,
OwnerUri = executeParams.OwnerUri OwnerUri = executeDocumentSelectionParams.OwnerUri
}; };
await requestContext.SendEvent(QueryExecuteBatchCompleteEvent.Type, eventParams); await requestContext.SendEvent(BatchCompleteEvent.Type, eventParams);
}; };
query.BatchCompleted += batchCompleteCallback; query.BatchCompleted += batchCompleteCallback;
Batch.BatchAsyncMessageHandler batchMessageCallback = async m => Batch.BatchAsyncMessageHandler batchMessageCallback = async m =>
{ {
QueryExecuteMessageParams eventParams = new QueryExecuteMessageParams MessageParams eventParams = new MessageParams
{ {
Message = m, Message = m,
OwnerUri = executeParams.OwnerUri OwnerUri = executeDocumentSelectionParams.OwnerUri
}; };
await requestContext.SendEvent(QueryExecuteMessageEvent.Type, eventParams); await requestContext.SendEvent(MessageEvent.Type, eventParams);
}; };
query.BatchMessageSent += batchMessageCallback; query.BatchMessageSent += batchMessageCallback;
// Setup the ResultSet completion callback // Setup the ResultSet completion callback
ResultSet.ResultSetAsyncEventHandler resultCallback = async r => ResultSet.ResultSetAsyncEventHandler resultCallback = async r =>
{ {
QueryExecuteResultSetCompleteParams eventParams = new QueryExecuteResultSetCompleteParams ResultSetEventParams eventParams = new ResultSetEventParams
{ {
ResultSetSummary = r.Summary, ResultSetSummary = r.Summary,
OwnerUri = executeParams.OwnerUri OwnerUri = executeDocumentSelectionParams.OwnerUri
}; };
await requestContext.SendEvent(QueryExecuteResultSetCompleteEvent.Type, eventParams); await requestContext.SendEvent(ResultSetCompleteEvent.Type, eventParams);
}; };
query.ResultSetCompleted += resultCallback; query.ResultSetCompleted += resultCallback;
@@ -539,6 +511,49 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
} }
} }
// Internal for testing purposes
internal string GetSqlText(ExecuteRequestParamsBase request)
{
// If it is a document selection, we'll retrieve the text from the document
ExecuteDocumentSelectionParams docRequest = request as ExecuteDocumentSelectionParams;
if (docRequest != null)
{
// Get the document from the parameters
ScriptFile queryFile = WorkspaceService.Workspace.GetFile(docRequest.OwnerUri);
// If a selection was not provided, use the entire document
if (docRequest.QuerySelection == null)
{
return queryFile.Contents;
}
// A selection was provided, so get the lines in the selected range
string[] queryTextArray = queryFile.GetLinesInRange(
new BufferRange(
new BufferPosition(
docRequest.QuerySelection.StartLine + 1,
docRequest.QuerySelection.StartColumn + 1
),
new BufferPosition(
docRequest.QuerySelection.EndLine + 1,
docRequest.QuerySelection.EndColumn + 1
)
)
);
return string.Join(Environment.NewLine, queryTextArray);
}
// If it is an ExecuteStringParams, return the text as is
ExecuteStringParams stringRequest = request as ExecuteStringParams;
if (stringRequest != null)
{
return stringRequest.Query;
}
// Note, this shouldn't be possible due to inheritance rules
throw new InvalidCastException("Invalid request type");
}
#endregion #endregion
#region IDisposable Implementation #region IDisposable Implementation

View File

@@ -7,6 +7,7 @@ using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit; using Xunit;
@@ -70,13 +71,13 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{ {
await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName); await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
var queryParams = new QueryExecuteParams var queryParams = new ExecuteDocumentSelectionParams
{ {
OwnerUri = queryTempFile.FilePath, OwnerUri = queryTempFile.FilePath,
QuerySelection = null QuerySelection = null
}; };
var result = await testService.Driver.SendRequest(QueryExecuteRequest.Type, queryParams); var result = await testService.Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
if (result != null) if (result != null)
{ {
TestTimer timer = new TestTimer() { PrintResult = true }; TestTimer timer = new TestTimer() { PrintResult = true };

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts; using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver; using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts; using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
@@ -157,9 +158,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// <summary> /// <summary>
/// Request the active SQL script is parsed for errors /// Request the active SQL script is parsed for errors
/// </summary> /// </summary>
public async Task<QueryExecuteSubsetResult> RequestQueryExecuteSubset(QueryExecuteSubsetParams subsetParams) public async Task<SubsetResult> RequestQueryExecuteSubset(SubsetParams subsetParams)
{ {
return await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams); return await Driver.SendRequest(SubsetRequest.Type, subsetParams);
} }
/// <summary> /// <summary>
@@ -276,21 +277,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// <summary> /// <summary>
/// Run a query using a given connection bound to a URI /// Run a query using a given connection bound to a URI
/// </summary> /// </summary>
public async Task<QueryExecuteCompleteParams> RunQueryAndWaitToComplete(string ownerUri, string query, int timeoutMilliseconds = 5000) public async Task<QueryCompleteParams> RunQueryAndWaitToComplete(string ownerUri, string query, int timeoutMilliseconds = 5000)
{ {
// Write the query text to a backing file // Write the query text to a backing file
WriteToFile(ownerUri, query); WriteToFile(ownerUri, query);
var queryParams = new QueryExecuteParams var queryParams = new ExecuteDocumentSelectionParams
{ {
OwnerUri = ownerUri, OwnerUri = ownerUri,
QuerySelection = null QuerySelection = null
}; };
var result = await Driver.SendRequest(QueryExecuteRequest.Type, queryParams); var result = await Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
if (result != null) if (result != null)
{ {
var eventResult = await Driver.WaitForEvent(QueryExecuteCompleteEvent.Type, timeoutMilliseconds); var eventResult = await Driver.WaitForEvent(QueryCompleteEvent.Type, timeoutMilliseconds);
return eventResult; return eventResult;
} }
else else
@@ -301,19 +302,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// <summary> /// <summary>
/// Run a query using a given connection bound to a URI. This method only waits for the initial response from query /// Run a query using a given connection bound to a URI. This method only waits for the initial response from query
/// execution (QueryExecuteResult). It is up to the caller to wait for the QueryExecuteCompleteEvent if they are interested. /// execution (QueryExecuteResult). It is up to the caller to wait for the QueryCompleteEvent if they are interested.
/// </summary> /// </summary>
public async Task<QueryExecuteResult> RunQueryAsync(string ownerUri, string query, int timeoutMilliseconds = 5000) public async Task<ExecuteRequestResult> RunQueryAsync(string ownerUri, string query, int timeoutMilliseconds = 5000)
{ {
WriteToFile(ownerUri, query); WriteToFile(ownerUri, query);
var queryParams = new QueryExecuteParams var queryParams = new ExecuteDocumentSelectionParams
{ {
OwnerUri = ownerUri, OwnerUri = ownerUri,
QuerySelection = null QuerySelection = null
}; };
return await Driver.SendRequest(QueryExecuteRequest.Type, queryParams); return await Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
} }
public async Task RunQuery(TestServerType serverType, string databaseName, string query) public async Task RunQuery(TestServerType serverType, string databaseName, string query)
@@ -408,16 +409,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// <summary> /// <summary>
/// Request a subset of results from a query /// Request a subset of results from a query
/// </summary> /// </summary>
public async Task<QueryExecuteSubsetResult> ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount) public async Task<SubsetResult> ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount)
{ {
var subsetParams = new QueryExecuteSubsetParams(); var subsetParams = new SubsetParams();
subsetParams.OwnerUri = ownerUri; subsetParams.OwnerUri = ownerUri;
subsetParams.BatchIndex = batchIndex; subsetParams.BatchIndex = batchIndex;
subsetParams.ResultSetIndex = resultSetIndex; subsetParams.ResultSetIndex = resultSetIndex;
subsetParams.RowsStartIndex = rowStartIndex; subsetParams.RowsStartIndex = rowStartIndex;
subsetParams.RowsCount = rowCount; subsetParams.RowsCount = rowCount;
var result = await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams); var result = await Driver.SendRequest(SubsetRequest.Type, subsetParams);
return result; return result;
} }
@@ -425,9 +426,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// Waits for a message to be returned by the service /// Waits for a message to be returned by the service
/// </summary> /// </summary>
/// <returns>A message from the service layer</returns> /// <returns>A message from the service layer</returns>
public async Task<QueryExecuteMessageParams> WaitForMessage() public async Task<MessageParams> WaitForMessage()
{ {
return await Driver.WaitForEvent(QueryExecuteMessageEvent.Type); return await Driver.WaitForEvent(MessageEvent.Type);
} }
public void WriteToFile(string ownerUri, string query) public void WriteToFile(string ownerUri, string query)

View File

@@ -5,6 +5,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
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;
@@ -22,8 +23,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... 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 workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -51,8 +52,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... 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 workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executeParams = new QueryExecuteParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri}; var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;

View File

@@ -14,6 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
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;
@@ -96,6 +97,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
public static Query GetBasicExecutedQuery(QueryExecutionSettings querySettings) public static Query GetBasicExecutedQuery(QueryExecutionSettings querySettings)
{ {
ConnectionInfo ci = CreateTestConnectionInfo(new[] {StandardTestData}, false); ConnectionInfo ci = CreateTestConnectionInfo(new[] {StandardTestData}, false);
// Query won't be able to request a new query DbConnection unless the ConnectionService has a // Query won't be able to request a new query DbConnection unless the ConnectionService has a
// ConnectionInfo with the same URI as the query, so we will manually set it // ConnectionInfo with the same URI as the query, so we will manually set it
ConnectionService.Instance.OwnerToConnectionMap[ci.OwnerUri] = ci; ConnectionService.Instance.OwnerToConnectionMap[ci.OwnerUri] = ci;
@@ -145,8 +147,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
return output.ToArray(); return output.ToArray();
} }
public static async Task AwaitExecution(QueryExecutionService service, QueryExecuteParams qeParams, public static async Task AwaitExecution(QueryExecutionService service, ExecuteDocumentSelectionParams qeParams,
RequestContext<QueryExecuteResult> requestContext) RequestContext<ExecuteRequestResult> requestContext)
{ {
await service.HandleExecuteRequest(qeParams, requestContext); await service.HandleExecuteRequest(qeParams, requestContext);
if (service.ActiveQueries.ContainsKey(qeParams.OwnerUri) && service.ActiveQueries[qeParams.OwnerUri].ExecutionTask != null) if (service.ActiveQueries.ContainsKey(qeParams.OwnerUri) && service.ActiveQueries[qeParams.OwnerUri].ExecutionTask != null)

View File

@@ -6,6 +6,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
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;
@@ -39,8 +40,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I request a query (doesn't matter what kind) // ... I request a query (doesn't matter what kind)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri}; var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -90,8 +91,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// If: // If:
// ... I execute some bogus query // ... I execute some bogus query
var queryParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri }; var queryParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
var requestContext = RequestContextMocks.Create<QueryExecuteResult>(null); var requestContext = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(queryParams, requestContext.Object); await queryService.HandleExecuteRequest(queryParams, requestContext.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;

View File

@@ -3,30 +3,108 @@
// 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.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
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 Moq;
using Xunit; using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
{ {
public class ServiceIntegrationTests public class ServiceIntegrationTests
{ {
#region Get SQL Tests
[Fact] [Fact]
public async Task QueryExecuteAllBatchesNoOp() public void GetSqlTextFromDocumentRequestFull()
{
// Setup:
// ... Create a workspace service with a multi-line constructed query
// ... Create a query execution service without a connection service (we won't be
// executing queries), and the previously created workspace service
string query = string.Format("{0}{1}GO{1}{0}", Common.StandardQuery, Environment.NewLine);
var workspaceService = GetDefaultWorkspaceService(query);
var queryService = new QueryExecutionService(null, workspaceService);
// If: I attempt to get query text from execute document params (entire document)
var queryParams = new ExecuteDocumentSelectionParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should match the constructed query
Assert.Equal(query, queryText);
}
[Fact]
public void GetSqlTextFromDocumentRequestPartial()
{
// Setup:
// ... Create a workspace service with a multi-line constructed query
string query = string.Format("{0}{1}GO{1}{0}", Common.StandardQuery, Environment.NewLine);
var workspaceService = GetDefaultWorkspaceService(query);
var queryService = new QueryExecutionService(null, workspaceService);
// If: I attempt to get query text from execute document params (partial document)
var queryParams = new ExecuteDocumentSelectionParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.SubsectionDocument};
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should be a subset of the constructed query
Assert.Contains(queryText, query);
}
[Fact]
public void GetSqlTextFromStringRequest()
{
// Setup:
// ... Create a query execution service without a connection service or workspace
// service (we won't execute code that uses either
var queryService = new QueryExecutionService(null, null);
// If: I attempt to get query text from execute string params
var queryParams = new ExecuteStringParams {OwnerUri = Common.OwnerUri, Query = Common.StandardQuery};
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should match the standard query
Assert.Equal(Common.StandardQuery, queryText);
}
[Fact]
public void GetSqlTextFromInvalidType()
{
// Setup:
// ... Mock up an implementation of ExecuteRequestParamsBase
// ... Create a query execution service without a connection service or workspace
// service (we won't execute code that uses either
var mockParams = new Mock<ExecuteRequestParamsBase>().Object;
var queryService = new QueryExecutionService(null, null);
// If: I attempt to get query text from the mock params
// Then: It should throw an exception
Assert.Throws<InvalidCastException>(() => queryService.GetSqlText(mockParams));
}
#endregion
#region Execution Tests
// NOTE: In order to limit test duplication, we're running the ExecuteDocumentSelection
// version of execute query. The code paths are almost identical.
[Fact]
private async Task QueryExecuteAllBatchesNoOp()
{ {
// If: // If:
// ... I request to execute a valid query with all batches as no op // ... I request to execute a valid query with all batches as no op
var workspaceService = GetDefaultWorkspaceService(string.Format("{0}\r\nGO\r\n{0}", Common.NoOpQuery)); var workspaceService = GetDefaultWorkspaceService(string.Format("{0}\r\nGO\r\n{0}", Common.NoOpQuery));
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var queryParams = new QueryExecuteParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri}; var queryParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardMessageValidator() .AddStandardMessageValidator()
.AddEventValidation(QueryExecuteCompleteEvent.Type, p => .AddEventValidation(QueryCompleteEvent.Type, p =>
{ {
// Validate OwnerURI matches // Validate OwnerURI matches
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -50,9 +128,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a valid query with no results // ... I request to execute a valid query with no results
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var queryParams = new QueryExecuteParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri}; var queryParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardMessageValidator() .AddStandardMessageValidator()
@@ -78,9 +156,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false,
workspaceService); workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardResultSetValidator() .AddStandardResultSetValidator()
@@ -106,9 +184,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var dataset = new[] {Common.StandardTestData, Common.StandardTestData}; var dataset = new[] {Common.StandardTestData, Common.StandardTestData};
var queryService = Common.GetPrimedExecutionService(dataset, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(dataset, true, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardResultSetValidator() .AddStandardResultSetValidator()
@@ -134,9 +212,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
var workspaceService = GetDefaultWorkspaceService(string.Format("{0}\r\nGO\r\n{0}", Common.StandardQuery)); var workspaceService = GetDefaultWorkspaceService(string.Format("{0}\r\nGO\r\n{0}", Common.StandardQuery));
var dataSet = new[] {Common.StandardTestData}; var dataSet = new[] {Common.StandardTestData};
var queryService = Common.GetPrimedExecutionService(dataSet, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(dataSet, true, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardResultSetValidator() .AddStandardResultSetValidator()
@@ -166,9 +244,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... 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 workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, false, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, false, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = "notConnected", QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = "notConnected", QuerySelection = Common.WholeDocument};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddErrorValidation<string>(Assert.NotEmpty) .AddErrorValidation<string>(Assert.NotEmpty)
.Complete(); .Complete();
await Common.AwaitExecution(queryService, queryParams, efv.Object); await Common.AwaitExecution(queryService, queryParams, efv.Object);
@@ -188,15 +266,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a query // ... I request to execute a query
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { 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.Create<QueryExecuteResult>(null); var firstRequestContext = RequestContextMocks.Create<ExecuteRequestResult>(null);
await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object); await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object);
// ... And then I request another query without waiting for the first to complete // ... And then I request another query without waiting for the first to complete
queryService.ActiveQueries[Common.OwnerUri].HasExecuted = false; // Simulate query hasn't finished queryService.ActiveQueries[Common.OwnerUri].HasExecuted = false; // Simulate query hasn't finished
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddErrorValidation<string>(Assert.NotEmpty) .AddErrorValidation<string>(Assert.NotEmpty)
.Complete(); .Complete();
await Common.AwaitExecution(queryService, queryParams, efv.Object); await Common.AwaitExecution(queryService, queryParams, efv.Object);
@@ -216,14 +294,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a query // ... I request to execute a query
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams { 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.Create<QueryExecuteResult>(null); var firstRequestContext = RequestContextMocks.Create<ExecuteRequestResult>(null);
await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object); await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object);
// ... And then I request another query after waiting for the first to complete // ... And then I request another query after waiting for the first to complete
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardBatchCompleteValidator() .AddStandardBatchCompleteValidator()
@@ -250,9 +328,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// 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(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = null}; var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = null};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddErrorValidation<string>(Assert.NotEmpty) .AddErrorValidation<string>(Assert.NotEmpty)
.Complete(); .Complete();
await queryService.HandleExecuteRequest(queryParams, efv.Object); await queryService.HandleExecuteRequest(queryParams, efv.Object);
@@ -272,9 +350,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a query that is invalid // ... I request to execute a query that is invalid
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery); var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, true, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, true, workspaceService);
var queryParams = new QueryExecuteParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument}; var queryParams = new ExecuteDocumentSelectionParams {OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
var efv = new EventFlowValidator<QueryExecuteResult>() var efv = new EventFlowValidator<ExecuteRequestResult>()
.AddStandardQueryResultValidator() .AddStandardQueryResultValidator()
.AddStandardBatchStartValidator() .AddStandardBatchStartValidator()
.AddStandardBatchCompleteValidator() .AddStandardBatchCompleteValidator()
@@ -290,6 +368,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
Assert.Equal(1, queryService.ActiveQueries.Count); Assert.Equal(1, queryService.ActiveQueries.Count);
} }
#endregion
private static WorkspaceService<SqlToolsSettings> GetDefaultWorkspaceService(string query) private static WorkspaceService<SqlToolsSettings> GetDefaultWorkspaceService(string query)
{ {
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings = new SqlToolsSettings(); WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings = new SqlToolsSettings();
@@ -300,8 +380,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static class EventFlowValidatorExtensions public static class EventFlowValidatorExtensions
{ {
public static EventFlowValidator<QueryExecuteResult> AddStandardQueryResultValidator( public static EventFlowValidator<ExecuteRequestResult> AddStandardQueryResultValidator(
this EventFlowValidator<QueryExecuteResult> efv) this EventFlowValidator<ExecuteRequestResult> efv)
{ {
// We just need to makes sure we get a result back, there's no params to validate // We just need to makes sure we get a result back, there's no params to validate
return efv.AddResultValidation(Assert.NotNull); return efv.AddResultValidation(Assert.NotNull);
@@ -310,7 +390,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator<TRequestContext> AddStandardBatchStartValidator<TRequestContext>( public static EventFlowValidator<TRequestContext> AddStandardBatchStartValidator<TRequestContext>(
this EventFlowValidator<TRequestContext> efv) this EventFlowValidator<TRequestContext> efv)
{ {
return efv.AddEventValidation(QueryExecuteBatchStartEvent.Type, p => return efv.AddEventValidation(BatchStartEvent.Type, p =>
{ {
// Validate OwnerURI and batch summary is returned // Validate OwnerURI and batch summary is returned
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -321,7 +401,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator<TRequestContext> AddStandardBatchCompleteValidator<TRequestContext>( public static EventFlowValidator<TRequestContext> AddStandardBatchCompleteValidator<TRequestContext>(
this EventFlowValidator<TRequestContext> efv) this EventFlowValidator<TRequestContext> efv)
{ {
return efv.AddEventValidation(QueryExecuteBatchCompleteEvent.Type, p => return efv.AddEventValidation(BatchCompleteEvent.Type, p =>
{ {
// Validate OwnerURI and result summary are returned // Validate OwnerURI and result summary are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -332,7 +412,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator<TRequestContext> AddStandardMessageValidator<TRequestContext>( public static EventFlowValidator<TRequestContext> AddStandardMessageValidator<TRequestContext>(
this EventFlowValidator<TRequestContext> efv) this EventFlowValidator<TRequestContext> efv)
{ {
return efv.AddEventValidation(QueryExecuteMessageEvent.Type, p => return efv.AddEventValidation(MessageEvent.Type, p =>
{ {
// Validate OwnerURI and message are returned // Validate OwnerURI and message are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -343,7 +423,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator<TRequestContext> AddStandardResultSetValidator<TRequestContext>( public static EventFlowValidator<TRequestContext> AddStandardResultSetValidator<TRequestContext>(
this EventFlowValidator<TRequestContext> efv) this EventFlowValidator<TRequestContext> efv)
{ {
return efv.AddEventValidation(QueryExecuteResultSetCompleteEvent.Type, p => return efv.AddEventValidation(ResultSetCompleteEvent.Type, p =>
{ {
// Validate OwnerURI and summary are returned // Validate OwnerURI and summary are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -354,7 +434,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator<TRequestContext> AddStandardQueryCompleteValidator<TRequestContext>( public static EventFlowValidator<TRequestContext> AddStandardQueryCompleteValidator<TRequestContext>(
this EventFlowValidator<TRequestContext> efv, int expectedBatches) this EventFlowValidator<TRequestContext> efv, int expectedBatches)
{ {
return efv.AddEventValidation(QueryExecuteCompleteEvent.Type, p => return efv.AddEventValidation(QueryCompleteEvent.Type, p =>
{ {
Assert.Equal(Common.OwnerUri, p.OwnerUri); Assert.Equal(Common.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummaries); Assert.NotNull(p.BatchSummaries);

View File

@@ -4,11 +4,11 @@
// //
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Utility; using Microsoft.SqlTools.ServiceLayer.Test.Utility;
using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Xunit; using Xunit;
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
} }
[Fact] [Fact]
public void ExecutionPlanInvalid() public async Task ExecutionPlanInvalid()
{ {
// Setup: // Setup:
// ... I have a batch that has been executed // ... I have a batch that has been executed
@@ -50,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// Then: // Then:
// ... It should throw an exception // ... It should throw an exception
Assert.ThrowsAsync<Exception>(async () => await planResultSet.GetExecutionPlan()); await Assert.ThrowsAsync<Exception>(() => planResultSet.GetExecutionPlan());
} }
#endregion #endregion
@@ -73,7 +73,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
} }
[Fact] [Fact]
public void BatchExecutionPlanInvalidTest() public async Task BatchExecutionPlanInvalidTest()
{ {
// Setup: // Setup:
// ... I have a batch that has been executed without an execution plan // ... I have a batch that has been executed without an execution plan
@@ -81,13 +81,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// If: // If:
// ... I ask for an invalid execution plan // ... I ask for an invalid execution plan
Assert.ThrowsAsync<Exception>(async () => await b.GetExecutionPlan(0)); await Assert.ThrowsAsync<Exception>(() => b.GetExecutionPlan(0));
} }
[Theory] [Theory]
[InlineData(-1)] // Invalid result set, too low [InlineData(-1)] // Invalid result set, too low
[InlineData(2)] // Invalid result set, too high [InlineData(2)] // Invalid result set, too high
public void BatchExecutionPlanInvalidParamsTest(int resultSetIndex) public async Task BatchExecutionPlanInvalidParamsTest(int resultSetIndex)
{ {
// If I have an executed batch which has an execution plan // If I have an executed batch which has an execution plan
Batch b = Common.GetExecutedBatchWithExecutionPlan(); Batch b = Common.GetExecutedBatchWithExecutionPlan();
@@ -95,7 +95,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... And I ask for an execution plan with an invalid result set index // ... And I ask for an execution plan with an invalid result set index
// Then: // Then:
// ... It should throw an exception // ... It should throw an exception
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await b.GetExecutionPlan(resultSetIndex)); await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => b.GetExecutionPlan(resultSetIndex));
} }
#endregion #endregion
@@ -105,14 +105,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
[Theory] [Theory]
[InlineData(-1)] // Invalid batch, too low [InlineData(-1)] // Invalid batch, too low
[InlineData(2)] // Invalid batch, too high [InlineData(2)] // Invalid batch, too high
public void QueryExecutionPlanInvalidParamsTest(int batchIndex) public async Task QueryExecutionPlanInvalidParamsTest(int batchIndex)
{ {
// Setup query settings // Setup query settings
QueryExecutionSettings querySettings = new QueryExecutionSettings(); QueryExecutionSettings querySettings = new QueryExecutionSettings
querySettings.ExecutionPlanOptions = new ExecutionPlanOptions() {
{ ExecutionPlanOptions = new ExecutionPlanOptions
IncludeActualExecutionPlanXml = false, {
IncludeEstimatedExecutionPlanXml = true IncludeActualExecutionPlanXml = false,
IncludeEstimatedExecutionPlanXml = true
}
}; };
// If I have an executed query // If I have an executed query
@@ -121,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... And I ask for a subset with an invalid result set index // ... And I ask for a subset with an invalid result set index
// Then: // Then:
// ... It should throw an exception // ... It should throw an exception
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await q.GetExecutionPlan(batchIndex, 0)); await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => q.GetExecutionPlan(batchIndex, 0));
} }
#endregion #endregion
@@ -136,13 +138,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that has results in the form of an execution plan // ... I have a query that has results in the form of an execution plan
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.GetExecutionPlanTestData()}, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(new[] {Common.GetExecutionPlanTestData()}, true, false, workspaceService);
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri}; var executeParams = new ExecuteDocumentSelectionParams
executeParams.ExecutionPlanOptions = new ExecutionPlanOptions() {
{ QuerySelection = null,
IncludeActualExecutionPlanXml = false, OwnerUri = Common.OwnerUri,
IncludeEstimatedExecutionPlanXml = true ExecutionPlanOptions = new ExecutionPlanOptions
{
IncludeActualExecutionPlanXml = false,
IncludeEstimatedExecutionPlanXml = true
}
}; };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -168,11 +174,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 }; var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>() var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>()
.AddErrorValidation<string>(r => .AddErrorValidation<string>(Assert.NotNull).Complete();
{
// Then: It should return a populated error
Assert.NotNull(r);
}).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object); await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
executionPlanRequest.Validate(); executionPlanRequest.Validate();
} }
@@ -184,13 +186,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... 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 workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] { Common.GetExecutionPlanTestData() }, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(new[] { Common.GetExecutionPlanTestData() }, true, false, workspaceService);
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams
executeParams.ExecutionPlanOptions = new ExecutionPlanOptions() {
{ QuerySelection = null,
IncludeActualExecutionPlanXml = false, OwnerUri = Common.OwnerUri,
IncludeEstimatedExecutionPlanXml = true ExecutionPlanOptions = new ExecutionPlanOptions
{
IncludeActualExecutionPlanXml = false,
IncludeEstimatedExecutionPlanXml = true
}
}; };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
queryService.ActiveQueries[Common.OwnerUri].Batches[0].ResultSets[0].hasBeenRead = false; queryService.ActiveQueries[Common.OwnerUri].Batches[0].ResultSets[0].hasBeenRead = false;
@@ -198,11 +204,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... And I then ask for a valid execution plan from it // ... And I then ask for a valid execution plan from it
var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 }; var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>() var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>()
.AddErrorValidation<string>(r => .AddErrorValidation<string>(Assert.NotNull).Complete();
{
// Then: It should return a populated error
Assert.NotNull(r);
}).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object); await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
executionPlanRequest.Validate(); executionPlanRequest.Validate();
} }
@@ -214,24 +216,24 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that doesn't have any result sets // ... I have a query that doesn't have any result sets
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams
executeParams.ExecutionPlanOptions = new ExecutionPlanOptions() {
{ QuerySelection = null,
IncludeActualExecutionPlanXml = false, OwnerUri = Common.OwnerUri,
IncludeEstimatedExecutionPlanXml = true ExecutionPlanOptions = new ExecutionPlanOptions
{
IncludeActualExecutionPlanXml = false,
IncludeEstimatedExecutionPlanXml = true
}
}; };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... And I then ask for an execution plan from a result set // ... And I then ask for an execution plan from a result set
var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 }; var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>() var executionPlanRequest = new EventFlowValidator<QueryExecutionPlanResult>()
.AddErrorValidation<string>(r => .AddErrorValidation<string>(Assert.NotNull).Complete();
{
// Then: It should return a populated error
Assert.NotNull(r);
}).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object); await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
executionPlanRequest.Validate(); executionPlanRequest.Validate();
} }

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
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;
@@ -59,8 +60,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage); QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage);
// ... The query execution service has executed a query with results // ... The query execution service has executed a query with results
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object); await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
await qes.ActiveQueries[Common.OwnerUri].ExecutionTask; await qes.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -105,8 +106,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage); QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage);
// ... The query execution service has executed a query with results // ... The query execution service has executed a query with results
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri}; var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object); await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
await qes.ActiveQueries[Common.OwnerUri].ExecutionTask; await qes.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -176,8 +177,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage); QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage);
// ... The query execution service has executed a query with results // ... The query execution service has executed a query with results
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object); await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
await qes.ActiveQueries[Common.OwnerUri].ExecutionTask; await qes.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -222,8 +223,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage); QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage);
// ... The query execution service has executed a query with results // ... The query execution service has executed a query with results
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object); await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
await qes.ActiveQueries[Common.OwnerUri].ExecutionTask; await qes.ActiveQueries[Common.OwnerUri].ExecutionTask;

View File

@@ -9,6 +9,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Utility; using Microsoft.SqlTools.ServiceLayer.Test.Utility;
using Xunit; using Xunit;
@@ -131,14 +132,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that has results (doesn't matter what) // ... I have a query that has results (doesn't matter what)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, workspaceService);
var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri}; var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... And I then ask for a valid set of results from it // ... And I then ask for a valid set of results from it
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 }; var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
var subsetRequest = new EventFlowValidator<QueryExecuteSubsetResult>() var subsetRequest = new EventFlowValidator<SubsetResult>()
.AddResultValidation(r => .AddResultValidation(r =>
{ {
// Then: Messages should be null and subset should not be null // Then: Messages should be null and subset should not be null
@@ -156,8 +157,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... 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 workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 }; var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
var subsetRequest = new EventFlowValidator<QueryExecuteSubsetResult>() var subsetRequest = new EventFlowValidator<SubsetResult>()
.AddResultValidation(r => .AddResultValidation(r =>
{ {
// Then: Messages should not be null and the subset should be null // Then: Messages should not be null and the subset should be null
@@ -175,15 +176,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... 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 workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, workspaceService);
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
queryService.ActiveQueries[Common.OwnerUri].Batches[0].ResultSets[0].hasBeenRead = false; queryService.ActiveQueries[Common.OwnerUri].Batches[0].ResultSets[0].hasBeenRead = false;
// ... And I then ask for a valid set of results from it // ... And I then ask for a valid set of results from it
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 }; var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
var subsetRequest = new EventFlowValidator<QueryExecuteSubsetResult>() var subsetRequest = new EventFlowValidator<SubsetResult>()
.AddResultValidation(r => .AddResultValidation(r =>
{ {
// Then: There should not be a subset and message should not be null // Then: There should not be a subset and message should not be null
@@ -201,14 +202,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that doesn't have any result sets // ... I have a query that doesn't have any result sets
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery); var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri }; var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
var executeRequest = RequestContextMocks.Create<QueryExecuteResult>(null); var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object); await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask; await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... And I then ask for a set of results from it // ... And I then ask for a set of results from it
var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 }; var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
var subsetRequest = new EventFlowValidator<QueryExecuteSubsetResult>() var subsetRequest = new EventFlowValidator<SubsetResult>()
.AddResultValidation(r => .AddResultValidation(r =>
{ {
// Then: There should be an error message and no subset // Then: There should be an error message and no subset

View File

@@ -84,7 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
} }
// Run n queries at once // Run n queries at once
var queryTasks = new Task<QueryExecuteCompleteParams>[queryCount]; var queryTasks = new Task<QueryCompleteParams>[queryCount];
for (int i = 0; i < queryCount; i++) for (int i = 0; i < queryCount; i++)
{ {
queryTasks[i] = TestService.RunQuery(ownerUris[i].FilePath, query); queryTasks[i] = TestService.RunQuery(ownerUris[i].FilePath, query);
@@ -160,7 +160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
await TestService.RunQuery(queryTempFile.FilePath, query); await TestService.RunQuery(queryTempFile.FilePath, query);
// Spawn several tasks for subset requests // Spawn several tasks for subset requests
var subsetTasks = new Task<QueryExecuteSubsetResult>[100]; var subsetTasks = new Task<SubsetResult>[100];
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
subsetTasks[i] = TestService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 100); subsetTasks[i] = TestService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 100);
@@ -259,7 +259,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
} }
} }
var subsetRequest = new QueryExecuteSubsetParams() var subsetRequest = new SubsetParams()
{ {
OwnerUri = queryTempFile.FilePath, OwnerUri = queryTempFile.FilePath,
BatchIndex = 0, BatchIndex = 0,

View File

@@ -19,6 +19,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts; using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts; using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
{ {
@@ -121,7 +122,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
// Setup events to queue for testing // Setup events to queue for testing
this.QueueEventsForType(ConnectionCompleteNotification.Type); this.QueueEventsForType(ConnectionCompleteNotification.Type);
this.QueueEventsForType(IntelliSenseReadyNotification.Type); this.QueueEventsForType(IntelliSenseReadyNotification.Type);
this.QueueEventsForType(QueryExecuteCompleteEvent.Type); this.QueueEventsForType(QueryCompleteEvent.Type);
this.QueueEventsForType(PublishDiagnosticsNotification.Type); this.QueueEventsForType(PublishDiagnosticsNotification.Type);
} }