From 18977a89dc34c80e1f2cd44468d02d308808906f Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Sat, 15 Jul 2017 10:14:32 -0700 Subject: [PATCH] Allow empty query string text (#415) * Allow empty query string text * Remove test that is no longer valid * Remove test that is no longer valid --- .../ExecutionEngineCode/ExecutionEngine.cs | 2 +- .../QueryExecution/Query.cs | 2 +- .../QueryExecution/Execution/QueryTests.cs | 11 -------- .../Execution/ServiceIntegrationTests.cs | 25 ------------------- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/BatchParser/ExecutionEngineCode/ExecutionEngine.cs b/src/Microsoft.SqlTools.ServiceLayer/BatchParser/ExecutionEngineCode/ExecutionEngine.cs index af68081a..6d524003 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/BatchParser/ExecutionEngineCode/ExecutionEngine.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/BatchParser/ExecutionEngineCode/ExecutionEngine.cs @@ -1050,7 +1050,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode /// public void ParseScript(string script, IBatchEventsHandler batchEventsHandler) { - Validate.IsNotNullOrEmptyString(nameof(script), script); + Validate.IsNotNull(nameof(script), script); Validate.IsNotNull(nameof(batchEventsHandler), batchEventsHandler); diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs index a03e4909..116e9111 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs @@ -90,7 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution public Query(string queryText, ConnectionInfo connection, QueryExecutionSettings settings, IFileStreamFactory outputFactory) { // Sanity check for input - Validate.IsNotNullOrEmptyString(nameof(queryText), queryText); + Validate.IsNotNull(nameof(queryText), queryText); Validate.IsNotNull(nameof(connection), connection); Validate.IsNotNull(nameof(settings), settings); Validate.IsNotNull(nameof(outputFactory), outputFactory); diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/QueryTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/QueryTests.cs index feeee314..da040ce9 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/QueryTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/QueryTests.cs @@ -35,17 +35,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution Assert.Throws(() => query.BatchSummaries); } - [Fact] - public void QueryExecuteNoQueryText() - { - // If: - // ... I create a query that has a null query text - // Then: - // ... It should throw an exception - Assert.Throws(() => - new Query(null, Common.CreateTestConnectionInfo(null, false), new QueryExecutionSettings(), MemoryFileSystem.GetFileStreamFactory())); - } - [Fact] public void QueryExecuteNoConnectionInfo() { diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/ServiceIntegrationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/ServiceIntegrationTests.cs index 929feb8b..2a37a1f1 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/ServiceIntegrationTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/Execution/ServiceIntegrationTests.cs @@ -396,31 +396,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution Assert.Equal(1, queryService.ActiveQueries.Count); } - [Fact] - public async Task QueryExecuteMissingSelectionTest() - { - // Given: - // ... A workspace with a standard query is configured - var workspaceService = Common.GetPrimedWorkspaceService(string.Empty); - - // If: - // ... I request to execute a query with a missing query string - var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService); - var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Constants.OwnerUri, QuerySelection = null}; - - var efv = new EventFlowValidator() - .AddStandardErrorValidation() - .Complete(); - await queryService.HandleExecuteRequest(queryParams, efv.Object); - - // Then: - // ... Am error should have been sent - efv.Validate(); - - // ... There should not be an active query - Assert.Empty(queryService.ActiveQueries); - } - [Fact] public async Task QueryExecuteInvalidQueryTest() {