diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteBatchNotifications.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/BatchEvents.cs
similarity index 55%
rename from src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteBatchNotifications.cs
rename to src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/BatchEvents.cs
index 42877b6d..d911ac9a 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteBatchNotifications.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/BatchEvents.cs
@@ -4,13 +4,13 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
-namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
+namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
///
- /// Parameters to be sent back as part of a QueryExecuteBatchCompleteEvent to indicate that a
- /// batch of a query completed.
+ /// Parameters to be sent back as part of a batch start or complete event to indicate that a
+ /// batch of a query started or completed.
///
- public class QueryExecuteBatchNotificationParams
+ public class BatchEventParams
{
///
/// Summary of the batch that just completed
@@ -23,17 +23,17 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public string OwnerUri { get; set; }
}
- public class QueryExecuteBatchCompleteEvent
+ public class BatchCompleteEvent
{
public static readonly
- EventType Type =
- EventType.Create("query/batchComplete");
+ EventType Type =
+ EventType.Create("query/batchComplete");
}
- public class QueryExecuteBatchStartEvent
+ public class BatchStartEvent
{
public static readonly
- EventType Type =
- EventType.Create("query/batchStart");
+ EventType Type =
+ EventType.Create("query/batchStart");
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteDocumentSelectionRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteDocumentSelectionRequest.cs
new file mode 100644
index 00000000..cb965d2c
--- /dev/null
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteDocumentSelectionRequest.cs
@@ -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
+{
+ ///
+ /// Parameters for executing a query from a document open in the workspace
+ ///
+ public class ExecuteDocumentSelectionParams : ExecuteRequestParamsBase
+ {
+ ///
+ /// The selection from the document
+ ///
+ public SelectionData QuerySelection { get; set; }
+ }
+
+ public class ExecuteDocumentSelectionRequest
+ {
+ public static readonly
+ RequestType Type =
+ RequestType.Create("query/executeDocumentSelection");
+ }
+}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestParamsBase.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestParamsBase.cs
new file mode 100644
index 00000000..77e82320
--- /dev/null
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestParamsBase.cs
@@ -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
+{
+ ///
+ /// Basic parameters that are required for executing a query
+ ///
+ public abstract class ExecuteRequestParamsBase
+ {
+ ///
+ /// URI for the editor that is asking for the query execute
+ ///
+ public string OwnerUri { get; set; }
+
+ ///
+ /// Execution plan options
+ ///
+ public ExecutionPlanOptions ExecutionPlanOptions { get; set; }
+ }
+}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestResult.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestResult.cs
new file mode 100644
index 00000000..23c40a67
--- /dev/null
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteRequestResult.cs
@@ -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
+{
+ ///
+ /// Parameters for the query execute result
+ ///
+ public class ExecuteRequestResult
+ {
+ }
+}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteStringRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteStringRequest.cs
new file mode 100644
index 00000000..883808ab
--- /dev/null
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ExecuteStringRequest.cs
@@ -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
+{
+ ///
+ /// Parameters for executing a query directly
+ ///
+ public class ExecuteStringParams : ExecuteRequestParamsBase
+ {
+ ///
+ /// The query to execute
+ ///
+ public string Query { get; set; }
+ }
+
+ public class ExecuteStringRequest
+ {
+ public static readonly
+ RequestType Type =
+ RequestType.Create("query/executeString");
+ }
+}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteMessageNotification.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/MessageEvent.cs
similarity index 77%
rename from src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteMessageNotification.cs
rename to src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/MessageEvent.cs
index e65f90d0..f655e72f 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteMessageNotification.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/MessageEvent.cs
@@ -5,12 +5,12 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
-namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
+namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
///
/// Parameters to be sent back with a message notification
///
- public class QueryExecuteMessageParams
+ public class MessageParams
{
///
/// URI for the editor that owns the query
@@ -23,10 +23,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public ResultMessage Message { get; set; }
}
- public class QueryExecuteMessageEvent
+ public class MessageEvent
{
public static readonly
- EventType Type =
- EventType.Create("query/message");
+ EventType Type =
+ EventType.Create("query/message");
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteCompleteNotification.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/QueryCompleteEvent.cs
similarity index 77%
rename from src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteCompleteNotification.cs
rename to src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/QueryCompleteEvent.cs
index 90c8c7b3..ec73d7d7 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteCompleteNotification.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/QueryCompleteEvent.cs
@@ -5,12 +5,12 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
-namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
+namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
///
/// Parameters to be sent back with a query execution complete event
///
- public class QueryExecuteCompleteParams
+ public class QueryCompleteParams
{
///
/// URI for the editor that owns the query
@@ -23,10 +23,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
public BatchSummary[] BatchSummaries { get; set; }
}
- public class QueryExecuteCompleteEvent
+ public class QueryCompleteEvent
{
public static readonly
- EventType Type =
- EventType.Create("query/complete");
+ EventType Type =
+ EventType.Create("query/complete");
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteResultSetCompleteNotification.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ResultSetEvents.cs
similarity index 57%
rename from src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteResultSetCompleteNotification.cs
rename to src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ResultSetEvents.cs
index c8eeb00b..8da94cd0 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteResultSetCompleteNotification.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ExecuteRequests/ResultSetEvents.cs
@@ -4,19 +4,22 @@
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
-namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
+namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
{
- public class QueryExecuteResultSetCompleteParams
+ ///
+ /// Parameters to return when a result set is started or completed
+ ///
+ public class ResultSetEventParams
{
public ResultSetSummary ResultSetSummary { get; set; }
public string OwnerUri { get; set; }
}
- public class QueryExecuteResultSetCompleteEvent
+ public class ResultSetCompleteEvent
{
public static readonly
- EventType Type =
- EventType.Create("query/resultSetComplete");
+ EventType Type =
+ EventType.Create("query/resultSetComplete");
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteRequest.cs
deleted file mode 100644
index 304825f1..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteRequest.cs
+++ /dev/null
@@ -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
-{
- ///
- /// Parameters for the query execute request
- ///
- public class QueryExecuteParams
- {
- ///
- /// The selection from the document
- ///
- public SelectionData QuerySelection { get; set; }
-
- ///
- /// URI for the editor that is asking for the query execute
- ///
- public string OwnerUri { get; set; }
-
- ///
- /// Execution plan options
- ///
- public ExecutionPlanOptions ExecutionPlanOptions { get; set; }
-
- }
-
- ///
- /// Parameters for the query execute result
- ///
- public class QueryExecuteResult
- {
- }
-
- public class QueryExecuteRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("query/execute");
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteSubsetRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/SubsetRequest.cs
similarity index 86%
rename from src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteSubsetRequest.cs
rename to src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/SubsetRequest.cs
index 2c861502..f9fd2e5d 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/QueryExecuteSubsetRequest.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/SubsetRequest.cs
@@ -10,7 +10,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
///
/// Parameters for a query result subset retrieval request
///
- public class QueryExecuteSubsetParams
+ public class SubsetParams
{
///
/// URI for the file that owns the query to look up the results for
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
///
/// Parameters for the result of a subset retrieval request
///
- public class QueryExecuteSubsetResult
+ public class SubsetResult
{
///
/// 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 class QueryExecuteSubsetRequest
+ public class SubsetRequest
{
public static readonly
- RequestType Type =
- RequestType.Create("query/subset");
+ RequestType Type =
+ RequestType.Create("query/subset");
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs
index 0b884f7c..4db65d8e 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs
@@ -5,12 +5,12 @@
using System;
using System.Collections.Concurrent;
using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Utility;
@@ -26,15 +26,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
{
#region Singleton Instance Implementation
- private static readonly Lazy instance = new Lazy(() => new QueryExecutionService());
+ private static readonly Lazy LazyInstance = new Lazy(() => new QueryExecutionService());
///
/// Singleton instance of the query execution service
///
- public static QueryExecutionService Instance
- {
- get { return instance.Value; }
- }
+ public static QueryExecutionService Instance => LazyInstance.Value;
private QueryExecutionService()
{
@@ -120,8 +117,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
public void InitializeService(ServiceHost serviceHost)
{
// Register handlers for requests
- serviceHost.SetRequestHandler(QueryExecuteRequest.Type, HandleExecuteRequest);
- serviceHost.SetRequestHandler(QueryExecuteSubsetRequest.Type, HandleResultSubsetRequest);
+ serviceHost.SetRequestHandler(ExecuteDocumentSelectionRequest.Type, HandleExecuteRequest);
+ serviceHost.SetRequestHandler(ExecuteStringRequest.Type, HandleExecuteRequest);
+ serviceHost.SetRequestHandler(SubsetRequest.Type, HandleResultSubsetRequest);
serviceHost.SetRequestHandler(QueryDisposeRequest.Type, HandleDisposeRequest);
serviceHost.SetRequestHandler(QueryCancelRequest.Type, HandleCancelRequest);
serviceHost.SetRequestHandler(SaveResultsAsCsvRequest.Type, HandleSaveResultsAsCsvRequest);
@@ -146,23 +144,23 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
#region Request Handlers
///
- /// Handles request to execute the query
+ /// Handles request to execute a selection of a document in the workspace service
///
- public async Task HandleExecuteRequest(QueryExecuteParams executeParams,
- RequestContext requestContext)
+ public async Task HandleExecuteRequest(ExecuteRequestParamsBase executeDocumentSelectionParams,
+ RequestContext requestContext)
{
// Get a query new active query
- Query newQuery = await CreateAndActivateNewQuery(executeParams, requestContext);
+ Query newQuery = await CreateAndActivateNewQuery(executeDocumentSelectionParams, requestContext);
// Execute the query -- asynchronously
- ExecuteAndCompleteQuery(executeParams, requestContext, newQuery);
+ ExecuteAndCompleteQuery(executeDocumentSelectionParams, requestContext, newQuery);
}
///
/// Handles a request to get a subset of the results of this query
///
- public async Task HandleResultSubsetRequest(QueryExecuteSubsetParams subsetParams,
- RequestContext requestContext)
+ public async Task HandleResultSubsetRequest(SubsetParams subsetParams,
+ RequestContext requestContext)
{
try
{
@@ -170,7 +168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
Query query;
if (!ActiveQueries.TryGetValue(subsetParams.OwnerUri, out query))
{
- await requestContext.SendResult(new QueryExecuteSubsetResult
+ await requestContext.SendResult(new SubsetResult
{
Message = SR.QueryServiceRequestsNoQuery
});
@@ -178,7 +176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
}
// Retrieve the requested subset and return it
- var result = new QueryExecuteSubsetResult
+ var result = new SubsetResult
{
Message = null,
ResultSubset = await query.GetSubset(subsetParams.BatchIndex,
@@ -189,7 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
catch (InvalidOperationException ioe)
{
// Return the error as a result
- await requestContext.SendResult(new QueryExecuteSubsetResult
+ await requestContext.SendResult(new SubsetResult
{
Message = ioe.Message
});
@@ -197,7 +195,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
catch (ArgumentOutOfRangeException aoore)
{
// Return the error as a result
- await requestContext.SendResult(new QueryExecuteSubsetResult
+ await requestContext.SendResult(new SubsetResult
{
Message = aoore.Message
});
@@ -342,7 +340,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
#region Private Helpers
- private async Task CreateAndActivateNewQuery(QueryExecuteParams executeParams, RequestContext requestContext)
+ private async Task CreateAndActivateNewQuery(ExecuteRequestParamsBase executeParams, RequestContext requestContext)
{
try
{
@@ -368,34 +366,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Apply execution parameter settings
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
- Query newQuery = new Query(queryText, connectionInfo, settings, BufferFileFactory);
+ Query newQuery = new Query(GetSqlText(executeParams), connectionInfo, settings, BufferFileFactory);
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
{
await requestContext.SendError(SR.QueryServiceQueryInProgress);
@@ -404,7 +376,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
}
// Send the result stating that the query was successfully started
- await requestContext.SendResult(new QueryExecuteResult());
+ await requestContext.SendResult(new ExecuteRequestResult());
return newQuery;
}
@@ -415,7 +387,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
}
}
- private static void ExecuteAndCompleteQuery(QueryExecuteParams executeParams, RequestContext requestContext, Query query)
+ private static void ExecuteAndCompleteQuery(ExecuteRequestParamsBase executeDocumentSelectionParams, RequestContext requestContext, Query query)
{
// Skip processing if the query is null
if (query == null)
@@ -427,24 +399,24 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
Query.QueryAsyncEventHandler callback = async q =>
{
// Send back the results
- QueryExecuteCompleteParams eventParams = new QueryExecuteCompleteParams
+ QueryCompleteParams eventParams = new QueryCompleteParams
{
- OwnerUri = executeParams.OwnerUri,
+ OwnerUri = executeDocumentSelectionParams.OwnerUri,
BatchSummaries = q.BatchSummaries
};
- await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams);
+ await requestContext.SendEvent(QueryCompleteEvent.Type, eventParams);
};
Query.QueryAsyncErrorEventHandler errorCallback = async errorMessage =>
{
// Send back the error message
- QueryExecuteCompleteParams eventParams = new QueryExecuteCompleteParams
+ QueryCompleteParams eventParams = new QueryCompleteParams
{
- OwnerUri = executeParams.OwnerUri,
+ OwnerUri = executeDocumentSelectionParams.OwnerUri,
//Message = errorMessage
};
- await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams);
+ await requestContext.SendEvent(QueryCompleteEvent.Type, eventParams);
};
query.QueryCompleted += callback;
@@ -454,48 +426,48 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Setup the batch callbacks
Batch.BatchAsyncEventHandler batchStartCallback = async b =>
{
- QueryExecuteBatchNotificationParams eventParams = new QueryExecuteBatchNotificationParams
+ BatchEventParams eventParams = new BatchEventParams
{
BatchSummary = b.Summary,
- OwnerUri = executeParams.OwnerUri
+ OwnerUri = executeDocumentSelectionParams.OwnerUri
};
- await requestContext.SendEvent(QueryExecuteBatchStartEvent.Type, eventParams);
+ await requestContext.SendEvent(BatchStartEvent.Type, eventParams);
};
query.BatchStarted += batchStartCallback;
Batch.BatchAsyncEventHandler batchCompleteCallback = async b =>
{
- QueryExecuteBatchNotificationParams eventParams = new QueryExecuteBatchNotificationParams
+ BatchEventParams eventParams = new BatchEventParams
{
BatchSummary = b.Summary,
- OwnerUri = executeParams.OwnerUri
+ OwnerUri = executeDocumentSelectionParams.OwnerUri
};
- await requestContext.SendEvent(QueryExecuteBatchCompleteEvent.Type, eventParams);
+ await requestContext.SendEvent(BatchCompleteEvent.Type, eventParams);
};
query.BatchCompleted += batchCompleteCallback;
Batch.BatchAsyncMessageHandler batchMessageCallback = async m =>
{
- QueryExecuteMessageParams eventParams = new QueryExecuteMessageParams
+ MessageParams eventParams = new MessageParams
{
Message = m,
- OwnerUri = executeParams.OwnerUri
+ OwnerUri = executeDocumentSelectionParams.OwnerUri
};
- await requestContext.SendEvent(QueryExecuteMessageEvent.Type, eventParams);
+ await requestContext.SendEvent(MessageEvent.Type, eventParams);
};
query.BatchMessageSent += batchMessageCallback;
// Setup the ResultSet completion callback
ResultSet.ResultSetAsyncEventHandler resultCallback = async r =>
{
- QueryExecuteResultSetCompleteParams eventParams = new QueryExecuteResultSetCompleteParams
+ ResultSetEventParams eventParams = new ResultSetEventParams
{
ResultSetSummary = r.Summary,
- OwnerUri = executeParams.OwnerUri
+ OwnerUri = executeDocumentSelectionParams.OwnerUri
};
- await requestContext.SendEvent(QueryExecuteResultSetCompleteEvent.Type, eventParams);
+ await requestContext.SendEvent(ResultSetCompleteEvent.Type, eventParams);
};
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
#region IDisposable Implementation
diff --git a/test/Microsoft.SqlTools.ServiceLayer.PerfTests/Tests/QueryExecutionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.PerfTests/Tests/QueryExecutionTests.cs
index f76780c6..fe2d5a00 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.PerfTests/Tests/QueryExecutionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.PerfTests/Tests/QueryExecutionTests.cs
@@ -7,6 +7,7 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit;
@@ -70,13 +71,13 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{
await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
- var queryParams = new QueryExecuteParams
+ var queryParams = new ExecuteDocumentSelectionParams
{
OwnerUri = queryTempFile.FilePath,
QuerySelection = null
};
- var result = await testService.Driver.SendRequest(QueryExecuteRequest.Type, queryParams);
+ var result = await testService.Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
if (result != null)
{
TestTimer timer = new TestTimer() { PrintResult = true };
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
index 0d3c1ce5..2af1f6f2 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
@@ -157,9 +158,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
///
/// Request the active SQL script is parsed for errors
///
- public async Task RequestQueryExecuteSubset(QueryExecuteSubsetParams subsetParams)
+ public async Task RequestQueryExecuteSubset(SubsetParams subsetParams)
{
- return await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams);
+ return await Driver.SendRequest(SubsetRequest.Type, subsetParams);
}
///
@@ -276,21 +277,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
///
/// Run a query using a given connection bound to a URI
///
- public async Task RunQueryAndWaitToComplete(string ownerUri, string query, int timeoutMilliseconds = 5000)
+ public async Task RunQueryAndWaitToComplete(string ownerUri, string query, int timeoutMilliseconds = 5000)
{
// Write the query text to a backing file
WriteToFile(ownerUri, query);
- var queryParams = new QueryExecuteParams
+ var queryParams = new ExecuteDocumentSelectionParams
{
OwnerUri = ownerUri,
QuerySelection = null
};
- var result = await Driver.SendRequest(QueryExecuteRequest.Type, queryParams);
+ var result = await Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
if (result != null)
{
- var eventResult = await Driver.WaitForEvent(QueryExecuteCompleteEvent.Type, timeoutMilliseconds);
+ var eventResult = await Driver.WaitForEvent(QueryCompleteEvent.Type, timeoutMilliseconds);
return eventResult;
}
else
@@ -301,19 +302,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
///
/// 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.
///
- public async Task RunQueryAsync(string ownerUri, string query, int timeoutMilliseconds = 5000)
+ public async Task RunQueryAsync(string ownerUri, string query, int timeoutMilliseconds = 5000)
{
WriteToFile(ownerUri, query);
- var queryParams = new QueryExecuteParams
+ var queryParams = new ExecuteDocumentSelectionParams
{
OwnerUri = ownerUri,
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)
@@ -408,16 +409,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
///
/// Request a subset of results from a query
///
- public async Task ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount)
+ public async Task ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount)
{
- var subsetParams = new QueryExecuteSubsetParams();
+ var subsetParams = new SubsetParams();
subsetParams.OwnerUri = ownerUri;
subsetParams.BatchIndex = batchIndex;
subsetParams.ResultSetIndex = resultSetIndex;
subsetParams.RowsStartIndex = rowStartIndex;
subsetParams.RowsCount = rowCount;
- var result = await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams);
+ var result = await Driver.SendRequest(SubsetRequest.Type, subsetParams);
return result;
}
@@ -425,9 +426,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
/// Waits for a message to be returned by the service
///
/// A message from the service layer
- public async Task WaitForMessage()
+ public async Task WaitForMessage()
{
- return await Driver.WaitForEvent(QueryExecuteMessageEvent.Type);
+ return await Driver.WaitForEvent(MessageEvent.Type);
}
public void WriteToFile(string ownerUri, string query)
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/CancelTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/CancelTests.cs
index c48e17e2..fb3b0e94 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/CancelTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/CancelTests.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
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
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var executeParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
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
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var executeParams = new QueryExecuteParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri};
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Common.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Common.cs
index 04d0c7f1..4005736e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Common.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Common.cs
@@ -14,6 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
@@ -96,6 +97,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
public static Query GetBasicExecutedQuery(QueryExecutionSettings querySettings)
{
ConnectionInfo ci = CreateTestConnectionInfo(new[] {StandardTestData}, false);
+
// 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
ConnectionService.Instance.OwnerToConnectionMap[ci.OwnerUri] = ci;
@@ -145,8 +147,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
return output.ToArray();
}
- public static async Task AwaitExecution(QueryExecutionService service, QueryExecuteParams qeParams,
- RequestContext requestContext)
+ public static async Task AwaitExecution(QueryExecutionService service, ExecuteDocumentSelectionParams qeParams,
+ RequestContext requestContext)
{
await service.HandleExecuteRequest(qeParams, requestContext);
if (service.ActiveQueries.ContainsKey(qeParams.OwnerUri) && service.ActiveQueries[qeParams.OwnerUri].ExecutionTask != null)
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs
index 1ddc420b..43c4115c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs
@@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
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)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
@@ -90,8 +91,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// If:
// ... I execute some bogus query
- var queryParams = new QueryExecuteParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
- var requestContext = RequestContextMocks.Create(null);
+ var queryParams = new ExecuteDocumentSelectionParams { QuerySelection = Common.WholeDocument, OwnerUri = Common.OwnerUri };
+ var requestContext = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(queryParams, requestContext.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Execution/ServiceIntegrationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Execution/ServiceIntegrationTests.cs
index 6c26f60f..10c22bf5 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Execution/ServiceIntegrationTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/Execution/ServiceIntegrationTests.cs
@@ -3,30 +3,108 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using System;
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.Test.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace;
+using Moq;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
{
public class ServiceIntegrationTests
{
+ #region Get SQL Tests
+
[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().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(() => 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:
// ... 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 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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardMessageValidator()
- .AddEventValidation(QueryExecuteCompleteEvent.Type, p =>
+ .AddEventValidation(QueryCompleteEvent.Type, p =>
{
// Validate OwnerURI matches
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
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.AddStandardMessageValidator()
@@ -78,9 +156,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, 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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.AddStandardResultSetValidator()
@@ -106,9 +184,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
var dataset = new[] {Common.StandardTestData, Common.StandardTestData};
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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.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 dataSet = new[] {Common.StandardTestData};
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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.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
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
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()
+ var efv = new EventFlowValidator()
.AddErrorValidation(Assert.NotEmpty)
.Complete();
await Common.AwaitExecution(queryService, queryParams, efv.Object);
@@ -188,15 +266,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a query
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
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
- var firstRequestContext = RequestContextMocks.Create(null);
+ var firstRequestContext = RequestContextMocks.Create(null);
await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object);
// ... And then I request another query without waiting for the first to complete
queryService.ActiveQueries[Common.OwnerUri].HasExecuted = false; // Simulate query hasn't finished
- var efv = new EventFlowValidator()
+ var efv = new EventFlowValidator()
.AddErrorValidation(Assert.NotEmpty)
.Complete();
await Common.AwaitExecution(queryService, queryParams, efv.Object);
@@ -216,14 +294,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// ... I request to execute a query
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
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
- var firstRequestContext = RequestContextMocks.Create(null);
+ var firstRequestContext = RequestContextMocks.Create(null);
await Common.AwaitExecution(queryService, queryParams, firstRequestContext.Object);
// ... And then I request another query after waiting for the first to complete
- var efv = new EventFlowValidator()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.AddStandardBatchCompleteValidator()
@@ -250,9 +328,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
// If:
// ... I request to execute a query with a missing query string
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()
+ var efv = new EventFlowValidator()
.AddErrorValidation(Assert.NotEmpty)
.Complete();
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
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
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()
+ var efv = new EventFlowValidator()
.AddStandardQueryResultValidator()
.AddStandardBatchStartValidator()
.AddStandardBatchCompleteValidator()
@@ -290,6 +368,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
Assert.Equal(1, queryService.ActiveQueries.Count);
}
+ #endregion
+
private static WorkspaceService GetDefaultWorkspaceService(string query)
{
WorkspaceService.Instance.CurrentSettings = new SqlToolsSettings();
@@ -300,8 +380,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static class EventFlowValidatorExtensions
{
- public static EventFlowValidator AddStandardQueryResultValidator(
- this EventFlowValidator efv)
+ public static EventFlowValidator AddStandardQueryResultValidator(
+ this EventFlowValidator efv)
{
// We just need to makes sure we get a result back, there's no params to validate
return efv.AddResultValidation(Assert.NotNull);
@@ -310,7 +390,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator AddStandardBatchStartValidator(
this EventFlowValidator efv)
{
- return efv.AddEventValidation(QueryExecuteBatchStartEvent.Type, p =>
+ return efv.AddEventValidation(BatchStartEvent.Type, p =>
{
// Validate OwnerURI and batch summary is returned
Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -321,7 +401,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator AddStandardBatchCompleteValidator(
this EventFlowValidator efv)
{
- return efv.AddEventValidation(QueryExecuteBatchCompleteEvent.Type, p =>
+ return efv.AddEventValidation(BatchCompleteEvent.Type, p =>
{
// Validate OwnerURI and result summary are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -332,7 +412,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator AddStandardMessageValidator(
this EventFlowValidator efv)
{
- return efv.AddEventValidation(QueryExecuteMessageEvent.Type, p =>
+ return efv.AddEventValidation(MessageEvent.Type, p =>
{
// Validate OwnerURI and message are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -343,7 +423,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator AddStandardResultSetValidator(
this EventFlowValidator efv)
{
- return efv.AddEventValidation(QueryExecuteResultSetCompleteEvent.Type, p =>
+ return efv.AddEventValidation(ResultSetCompleteEvent.Type, p =>
{
// Validate OwnerURI and summary are returned
Assert.Equal(Common.OwnerUri, p.OwnerUri);
@@ -354,7 +434,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
public static EventFlowValidator AddStandardQueryCompleteValidator(
this EventFlowValidator efv, int expectedBatches)
{
- return efv.AddEventValidation(QueryExecuteCompleteEvent.Type, p =>
+ return efv.AddEventValidation(QueryCompleteEvent.Type, p =>
{
Assert.Equal(Common.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummaries);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecutionPlanTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecutionPlanTests.cs
index c03becfb..1d01a50e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecutionPlanTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecutionPlanTests.cs
@@ -4,11 +4,11 @@
//
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Xunit;
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
}
[Fact]
- public void ExecutionPlanInvalid()
+ public async Task ExecutionPlanInvalid()
{
// Setup:
// ... I have a batch that has been executed
@@ -50,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// Then:
// ... It should throw an exception
- Assert.ThrowsAsync(async () => await planResultSet.GetExecutionPlan());
+ await Assert.ThrowsAsync(() => planResultSet.GetExecutionPlan());
}
#endregion
@@ -73,7 +73,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
}
[Fact]
- public void BatchExecutionPlanInvalidTest()
+ public async Task BatchExecutionPlanInvalidTest()
{
// Setup:
// ... I have a batch that has been executed without an execution plan
@@ -81,13 +81,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// If:
// ... I ask for an invalid execution plan
- Assert.ThrowsAsync(async () => await b.GetExecutionPlan(0));
+ await Assert.ThrowsAsync(() => b.GetExecutionPlan(0));
}
[Theory]
[InlineData(-1)] // Invalid result set, too low
[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
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
// Then:
// ... It should throw an exception
- Assert.ThrowsAsync(async () => await b.GetExecutionPlan(resultSetIndex));
+ await Assert.ThrowsAsync(() => b.GetExecutionPlan(resultSetIndex));
}
#endregion
@@ -105,14 +105,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
[Theory]
[InlineData(-1)] // Invalid batch, too low
[InlineData(2)] // Invalid batch, too high
- public void QueryExecutionPlanInvalidParamsTest(int batchIndex)
+ public async Task QueryExecutionPlanInvalidParamsTest(int batchIndex)
{
// Setup query settings
- QueryExecutionSettings querySettings = new QueryExecutionSettings();
- querySettings.ExecutionPlanOptions = new ExecutionPlanOptions()
- {
- IncludeActualExecutionPlanXml = false,
- IncludeEstimatedExecutionPlanXml = true
+ QueryExecutionSettings querySettings = new QueryExecutionSettings
+ {
+ ExecutionPlanOptions = new ExecutionPlanOptions
+ {
+ IncludeActualExecutionPlanXml = false,
+ IncludeEstimatedExecutionPlanXml = true
+ }
};
// 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
// Then:
// ... It should throw an exception
- Assert.ThrowsAsync(async () => await q.GetExecutionPlan(batchIndex, 0));
+ await Assert.ThrowsAsync(() => q.GetExecutionPlan(batchIndex, 0));
}
#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
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.GetExecutionPlanTestData()}, true, false, workspaceService);
- var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
- executeParams.ExecutionPlanOptions = new ExecutionPlanOptions()
- {
- IncludeActualExecutionPlanXml = false,
- IncludeEstimatedExecutionPlanXml = true
+ var executeParams = new ExecuteDocumentSelectionParams
+ {
+ QuerySelection = null,
+ OwnerUri = Common.OwnerUri,
+ ExecutionPlanOptions = new ExecutionPlanOptions
+ {
+ IncludeActualExecutionPlanXml = false,
+ IncludeEstimatedExecutionPlanXml = true
+ }
};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
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 executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator()
- .AddErrorValidation(r =>
- {
- // Then: It should return a populated error
- Assert.NotNull(r);
- }).Complete();
+ .AddErrorValidation(Assert.NotNull).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
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)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] { Common.GetExecutionPlanTestData() }, true, false, workspaceService);
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- executeParams.ExecutionPlanOptions = new ExecutionPlanOptions()
- {
- IncludeActualExecutionPlanXml = false,
- IncludeEstimatedExecutionPlanXml = true
+ var executeParams = new ExecuteDocumentSelectionParams
+ {
+ QuerySelection = null,
+ OwnerUri = Common.OwnerUri,
+ ExecutionPlanOptions = new ExecutionPlanOptions
+ {
+ IncludeActualExecutionPlanXml = false,
+ IncludeEstimatedExecutionPlanXml = true
+ }
};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
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
var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator()
- .AddErrorValidation(r =>
- {
- // Then: It should return a populated error
- Assert.NotNull(r);
- }).Complete();
+ .AddErrorValidation(Assert.NotNull).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
executionPlanRequest.Validate();
}
@@ -214,24 +216,24 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that doesn't have any result sets
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- executeParams.ExecutionPlanOptions = new ExecutionPlanOptions()
- {
- IncludeActualExecutionPlanXml = false,
- IncludeEstimatedExecutionPlanXml = true
+ var executeParams = new ExecuteDocumentSelectionParams
+ {
+ QuerySelection = null,
+ OwnerUri = Common.OwnerUri,
+ ExecutionPlanOptions = new ExecutionPlanOptions
+ {
+ IncludeActualExecutionPlanXml = false,
+ IncludeEstimatedExecutionPlanXml = true
+ }
};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... And I then ask for an execution plan from a result set
var executionPlanParams = new QueryExecutionPlanParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
var executionPlanRequest = new EventFlowValidator()
- .AddErrorValidation(r =>
- {
- // Then: It should return a populated error
- Assert.NotNull(r);
- }).Complete();
+ .AddErrorValidation(Assert.NotNull).Complete();
await queryService.HandleExecutionPlanRequest(executionPlanParams, executionPlanRequest.Object);
executionPlanRequest.Validate();
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SaveResults/ServiceIntegrationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SaveResults/ServiceIntegrationTests.cs
index 1fee4fc7..131011fd 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SaveResults/ServiceIntegrationTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SaveResults/ServiceIntegrationTests.cs
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
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);
// ... The query execution service has executed a query with results
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
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);
// ... The query execution service has executed a query with results
- var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
+ var executeRequest = RequestContextMocks.Create(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
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);
// ... The query execution service has executed a query with results
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
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);
// ... The query execution service has executed a query with results
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await qes.HandleExecuteRequest(executeParams, executeRequest.Object);
await qes.ActiveQueries[Common.OwnerUri].ExecutionTask;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs
index 7011768d..28f12d74 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
using Xunit;
@@ -131,14 +132,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I have a query that has results (doesn't matter what)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, workspaceService);
- var executeParams = new QueryExecuteParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... 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 subsetRequest = new EventFlowValidator()
+ var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
+ var subsetRequest = new EventFlowValidator()
.AddResultValidation(r =>
{
// 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
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var subsetParams = new QueryExecuteSubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
- var subsetRequest = new EventFlowValidator()
+ var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
+ var subsetRequest = new EventFlowValidator()
.AddResultValidation(r =>
{
// 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)
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, workspaceService);
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
queryService.ActiveQueries[Common.OwnerUri].Batches[0].ResultSets[0].hasBeenRead = false;
// ... 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 subsetRequest = new EventFlowValidator()
+ var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
+ var subsetRequest = new EventFlowValidator()
.AddResultValidation(r =>
{
// 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
var workspaceService = Common.GetPrimedWorkspaceService(Common.StandardQuery);
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
- var executeParams = new QueryExecuteParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
- var executeRequest = RequestContextMocks.Create(null);
+ var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
+ var executeRequest = RequestContextMocks.Create(null);
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
await queryService.ActiveQueries[Common.OwnerUri].ExecutionTask;
// ... 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 subsetRequest = new EventFlowValidator()
+ var subsetParams = new SubsetParams { OwnerUri = Common.OwnerUri, RowsCount = 1, ResultSetIndex = 0, RowsStartIndex = 0 };
+ var subsetRequest = new EventFlowValidator()
.AddResultValidation(r =>
{
// Then: There should be an error message and no subset
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
index 61e20caa..43262e19 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
@@ -84,7 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
// Run n queries at once
- var queryTasks = new Task[queryCount];
+ var queryTasks = new Task[queryCount];
for (int i = 0; i < queryCount; i++)
{
queryTasks[i] = TestService.RunQuery(ownerUris[i].FilePath, query);
@@ -160,7 +160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
await TestService.RunQuery(queryTempFile.FilePath, query);
// Spawn several tasks for subset requests
- var subsetTasks = new Task[100];
+ var subsetTasks = new Task[100];
for (int i = 0; i < 100; i++)
{
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,
BatchIndex = 0,
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
index be5d2e39..5781ccf6 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
@@ -19,6 +19,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
+using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
{
@@ -121,7 +122,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
// Setup events to queue for testing
this.QueueEventsForType(ConnectionCompleteNotification.Type);
this.QueueEventsForType(IntelliSenseReadyNotification.Type);
- this.QueueEventsForType(QueryExecuteCompleteEvent.Type);
+ this.QueueEventsForType(QueryCompleteEvent.Type);
this.QueueEventsForType(PublishDiagnosticsNotification.Type);
}