mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 17:23:27 -05:00
Adding TestDbResultSet for Better Mocking (#231)
* Replacing the awful and inflexible Dictionary<string, string>[][] with a much better test data set class * Applying all changes * Removing unused RequestParamTests
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
@@ -59,9 +60,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
#endregion
|
||||
|
||||
public static Dictionary<string, string>[] StandardTestData
|
||||
public static TestResultSet StandardTestResultSet => new TestResultSet(StandardColumns, StandardRows);
|
||||
|
||||
public static TestResultSet[] StandardTestDataSet => new[] {StandardTestResultSet};
|
||||
|
||||
public static TestResultSet[] ExecutionPlanTestDataSet
|
||||
{
|
||||
get { return GetTestData(StandardRows, StandardColumns); }
|
||||
get
|
||||
{
|
||||
DbColumn[] columns = { new TestDbColumn("Microsoft SQL Server 2005 XML Showplan") };
|
||||
object[][] rows = { new object[] { "Execution Plan" } };
|
||||
return new[] {new TestResultSet(columns, rows)};
|
||||
}
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
@@ -69,20 +79,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
public static Batch GetBasicExecutedBatch()
|
||||
{
|
||||
Batch batch = new Batch(StandardQuery, SubsectionDocument, 1, GetFileStreamFactory(new Dictionary<string, byte[]>()));
|
||||
batch.Execute(CreateTestConnection(new[] {StandardTestData}, false), CancellationToken.None).Wait();
|
||||
batch.Execute(CreateTestConnection(StandardTestDataSet, false), CancellationToken.None).Wait();
|
||||
return batch;
|
||||
}
|
||||
|
||||
public static Batch GetExecutedBatchWithExecutionPlan()
|
||||
{
|
||||
Batch batch = new Batch(StandardQuery, SubsectionDocument, 1, GetFileStreamFactory(new Dictionary<string, byte[]>()));
|
||||
batch.Execute(CreateTestConnection(new[] {GetExecutionPlanTestData()}, false), CancellationToken.None).Wait();
|
||||
batch.Execute(CreateTestConnection(ExecutionPlanTestDataSet, false), CancellationToken.None).Wait();
|
||||
return batch;
|
||||
}
|
||||
|
||||
public static Query GetBasicExecutedQuery()
|
||||
{
|
||||
ConnectionInfo ci = CreateTestConnectionInfo(new[] {StandardTestData}, false);
|
||||
ConnectionInfo ci = CreateTestConnectionInfo(StandardTestDataSet, 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
|
||||
@@ -96,7 +106,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
public static Query GetBasicExecutedQuery(QueryExecutionSettings querySettings)
|
||||
{
|
||||
ConnectionInfo ci = CreateTestConnectionInfo(new[] {StandardTestData}, false);
|
||||
ConnectionInfo ci = CreateTestConnectionInfo(StandardTestDataSet, 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
|
||||
@@ -108,43 +118,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
return query;
|
||||
}
|
||||
|
||||
public static Dictionary<string, string>[] GetTestData(int columns, int rows)
|
||||
public static TestResultSet[] GetTestDataSet(int dataSets)
|
||||
{
|
||||
Dictionary<string, string>[] output = new Dictionary<string, string>[rows];
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
Dictionary<string, string> rowDictionary = new Dictionary<string, string>();
|
||||
for (int column = 0; column < columns; column++)
|
||||
{
|
||||
rowDictionary.Add(string.Format("column{0}", column), string.Format("val{0}{1}", column, row));
|
||||
}
|
||||
output[row] = rowDictionary;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
public static Dictionary<string, string>[] GetExecutionPlanTestData()
|
||||
{
|
||||
Dictionary<string, string>[] output = new Dictionary<string, string>[1];
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
Dictionary<string, string> rowDictionary = new Dictionary<string, string>();
|
||||
rowDictionary.Add(string.Format("Microsoft SQL Server 2005 XML Showplan", col), string.Format("Execution Plan", col, row));
|
||||
output[row] = rowDictionary;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static Dictionary<string, string>[][] GetTestDataSet(int dataSets)
|
||||
{
|
||||
List<Dictionary<string, string>[]> output = new List<Dictionary<string, string>[]>();
|
||||
for(int dataSet = 0; dataSet < dataSets; dataSet++)
|
||||
{
|
||||
output.Add(StandardTestData);
|
||||
}
|
||||
return output.ToArray();
|
||||
return Enumerable.Repeat(StandardTestResultSet, dataSets).ToArray();
|
||||
}
|
||||
|
||||
public static async Task AwaitExecution(QueryExecutionService service, ExecuteDocumentSelectionParams qeParams,
|
||||
@@ -183,7 +159,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
#region DbConnection Mocking
|
||||
|
||||
public static DbCommand CreateTestCommand(Dictionary<string, string>[][] data, bool throwOnRead)
|
||||
public static DbCommand CreateTestCommand(TestResultSet[] data, bool throwOnRead)
|
||||
{
|
||||
var commandMock = new Mock<DbCommand> { CallBase = true };
|
||||
var commandMockSetup = commandMock.Protected()
|
||||
@@ -205,7 +181,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
return commandMock.Object;
|
||||
}
|
||||
|
||||
public static DbConnection CreateTestConnection(Dictionary<string, string>[][] data, bool throwOnRead)
|
||||
public static DbConnection CreateTestConnection(TestResultSet[] data, bool throwOnRead)
|
||||
{
|
||||
var connectionMock = new Mock<DbConnection> { CallBase = true };
|
||||
connectionMock.Protected()
|
||||
@@ -219,7 +195,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
return connectionMock.Object;
|
||||
}
|
||||
|
||||
public static ISqlConnectionFactory CreateMockFactory(Dictionary<string, string>[][] data, bool throwOnRead)
|
||||
public static ISqlConnectionFactory CreateMockFactory(TestResultSet[] data, bool throwOnRead)
|
||||
{
|
||||
var mockFactory = new Mock<ISqlConnectionFactory>();
|
||||
mockFactory.Setup(factory => factory.CreateSqlConnection(It.IsAny<string>()))
|
||||
@@ -228,21 +204,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
return mockFactory.Object;
|
||||
}
|
||||
|
||||
public static ConnectionInfo CreateTestConnectionInfo(Dictionary<string, string>[][] data, bool throwOnRead)
|
||||
public static ConnectionInfo CreateTestConnectionInfo(TestResultSet[] data, bool throwOnRead)
|
||||
{
|
||||
return new ConnectionInfo(CreateMockFactory(data, throwOnRead), OwnerUri, StandardConnectionDetails);
|
||||
}
|
||||
|
||||
public static ConnectionInfo CreateConnectedConnectionInfo(Dictionary<string, string>[][] data, bool throwOnRead, string type = ConnectionType.Default)
|
||||
public static ConnectionInfo CreateConnectedConnectionInfo(TestResultSet[] data, bool throwOnRead, string type = ConnectionType.Default)
|
||||
{
|
||||
ConnectionService connectionService = ConnectionService.Instance;
|
||||
connectionService.OwnerToConnectionMap.Clear();
|
||||
connectionService.ConnectionFactory = CreateMockFactory(data, throwOnRead);
|
||||
|
||||
ConnectParams connectParams = new ConnectParams()
|
||||
ConnectParams connectParams = new ConnectParams
|
||||
{
|
||||
Connection = StandardConnectionDetails,
|
||||
OwnerUri = Common.OwnerUri,
|
||||
OwnerUri = OwnerUri,
|
||||
Type = type
|
||||
};
|
||||
|
||||
@@ -254,7 +230,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
#region Service Mocking
|
||||
|
||||
public static QueryExecutionService GetPrimedExecutionService(Dictionary<string, string>[][] data,
|
||||
public static QueryExecutionService GetPrimedExecutionService(TestResultSet[] data,
|
||||
bool isConnected, bool throwOnRead, WorkspaceService<SqlToolsSettings> workspaceService,
|
||||
out Dictionary<string, byte[]> storage)
|
||||
{
|
||||
@@ -273,7 +249,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
return new QueryExecutionService(connectionService.Object, workspaceService) { BufferFileStreamFactory = GetFileStreamFactory(storage) };
|
||||
}
|
||||
|
||||
public static QueryExecutionService GetPrimedExecutionService(Dictionary<string, string>[][] data, bool isConnected, bool throwOnRead, WorkspaceService<SqlToolsSettings> workspaceService)
|
||||
public static QueryExecutionService GetPrimedExecutionService(TestResultSet[] data, bool isConnected, bool throwOnRead, WorkspaceService<SqlToolsSettings> workspaceService)
|
||||
{
|
||||
Dictionary<string, byte[]> storage;
|
||||
return GetPrimedExecutionService(data, isConnected, throwOnRead, workspaceService, out storage);
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
{
|
||||
this.DataTypeName = dataTypeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DataTypeName = "int";
|
||||
this.DataType = typeof(int);
|
||||
}
|
||||
|
||||
if (columnSize.HasValue)
|
||||
{
|
||||
@@ -63,6 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// check various properties are either null or not null
|
||||
var column = new TestColumn();
|
||||
var wrapper = new DbColumnWrapper(column);
|
||||
Assert.NotNull(wrapper.DataTypeName);
|
||||
Assert.NotNull(wrapper.DataType);
|
||||
Assert.Null(wrapper.AllowDBNull);
|
||||
Assert.Null(wrapper.BaseCatalogName);
|
||||
@@ -77,12 +83,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
Assert.Null(wrapper.IsHidden);
|
||||
Assert.Null(wrapper.IsIdentity);
|
||||
Assert.Null(wrapper.IsKey);
|
||||
Assert.Null(wrapper. IsReadOnly);
|
||||
Assert.Null(wrapper.IsReadOnly);
|
||||
Assert.Null(wrapper.IsUnique);
|
||||
Assert.Null(wrapper.NumericPrecision);
|
||||
Assert.Null(wrapper.NumericScale);
|
||||
Assert.Null(wrapper.UdtAssemblyQualifiedName);
|
||||
Assert.Null(wrapper.DataTypeName);
|
||||
Assert.Null(wrapper.UdtAssemblyQualifiedName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
@@ -63,7 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I create a new resultset with a valid db data reader that has data
|
||||
// ... and I read it to the end
|
||||
DbDataReader mockReader = GetReader(new [] {Common.StandardTestData}, false, Common.StandardQuery);
|
||||
DbDataReader mockReader = GetReader(Common.StandardTestDataSet, false, Common.StandardQuery);
|
||||
var fileStreamFactory = Common.GetFileStreamFactory(new Dictionary<string, byte[]>());
|
||||
ResultSet resultSet = new ResultSet(mockReader, Common.Ordinal, Common.Ordinal, fileStreamFactory);
|
||||
resultSet.ResultCompletion += callback;
|
||||
@@ -92,13 +94,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
{
|
||||
// Setup:
|
||||
// ... Build a FOR XML or FOR JSON data set
|
||||
string columnName = string.Format("{0}_F52E2B61-18A1-11d1-B105-00805F49916B", forType);
|
||||
List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
|
||||
for(int i = 0; i < Common.StandardRows; i++)
|
||||
{
|
||||
data.Add(new Dictionary<string, string> { { columnName, "test data"} });
|
||||
}
|
||||
Dictionary<string, string>[][] dataSets = {data.ToArray()};
|
||||
DbColumn[] columns = {new TestDbColumn(string.Format("{0}_F52E2B61-18A1-11d1-B105-00805F49916B", forType))};
|
||||
object[][] rows = Enumerable.Repeat(new object[] {"test data"}, Common.StandardRows).ToArray();
|
||||
TestResultSet[] dataSets = {new TestResultSet(columns, rows) };
|
||||
|
||||
// ... Create a callback for resultset completion
|
||||
ResultSetSummary resultSummary = null;
|
||||
@@ -158,7 +156,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I create a new result set with a valid db data reader
|
||||
// ... And execute the result
|
||||
DbDataReader mockReader = GetReader(new[] {Common.StandardTestData}, false, Common.StandardQuery);
|
||||
DbDataReader mockReader = GetReader(Common.StandardTestDataSet, false, Common.StandardQuery);
|
||||
var fileStreamFactory = Common.GetFileStreamFactory(new Dictionary<string, byte[]>());
|
||||
ResultSet resultSet = new ResultSet(mockReader, Common.Ordinal, Common.Ordinal, fileStreamFactory);
|
||||
await resultSet.ReadResultToEnd(CancellationToken.None);
|
||||
@@ -179,7 +177,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I create a new result set with a valid db data reader
|
||||
// ... And execute the result set
|
||||
DbDataReader mockReader = GetReader(new[] { Common.StandardTestData }, false, Common.StandardQuery);
|
||||
DbDataReader mockReader = GetReader(Common.StandardTestDataSet, false, Common.StandardQuery);
|
||||
var fileStreamFactory = Common.GetFileStreamFactory(new Dictionary<string, byte[]>());
|
||||
ResultSet resultSet = new ResultSet(mockReader, Common.Ordinal, Common.Ordinal, fileStreamFactory);
|
||||
await resultSet.ReadResultToEnd(CancellationToken.None);
|
||||
@@ -197,7 +195,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
Assert.Equal(resultSet.Columns.Length, subset.Rows[0].Length);
|
||||
}
|
||||
|
||||
private static DbDataReader GetReader(Dictionary<string, string>[][] dataSet, bool throwOnRead, string query)
|
||||
private static DbDataReader GetReader(TestResultSet[] dataSet, bool throwOnRead, string query)
|
||||
{
|
||||
var info = Common.CreateTestConnectionInfo(dataSet, throwOnRead);
|
||||
var connection = info.Factory.CreateSqlConnection(ConnectionService.BuildConnectionString(info.ConnectionDetails));
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I request to execute a valid query with results
|
||||
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
|
||||
var queryService = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false,
|
||||
var queryService = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false,
|
||||
workspaceService);
|
||||
var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I request to execute a valid query with one batch and multiple result sets
|
||||
var workspaceService = GetDefaultWorkspaceService(Common.StandardQuery);
|
||||
var dataset = new[] {Common.StandardTestData, Common.StandardTestData};
|
||||
var dataset = new[] {Common.StandardTestResultSet, Common.StandardTestResultSet};
|
||||
var queryService = Common.GetPrimedExecutionService(dataset, true, false, workspaceService);
|
||||
var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
|
||||
|
||||
@@ -273,8 +273,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.Execution
|
||||
// If:
|
||||
// ... I request a to execute a valid query with multiple batches
|
||||
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 queryService = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, workspaceService);
|
||||
var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Common.OwnerUri, QuerySelection = Common.WholeDocument};
|
||||
|
||||
var efv = new EventFlowValidator<ExecuteRequestResult>()
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
// If:
|
||||
// ... 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 queryService = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, workspaceService);
|
||||
var executeParams = new ExecuteDocumentSelectionParams
|
||||
{
|
||||
QuerySelection = null,
|
||||
@@ -185,7 +185,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
// If:
|
||||
// ... 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 queryService = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, workspaceService);
|
||||
var executeParams = new ExecuteDocumentSelectionParams
|
||||
{
|
||||
QuerySelection = null,
|
||||
|
||||
@@ -12,6 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
@@ -66,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
// Setup:
|
||||
// ... Create a result set that has been executed
|
||||
ResultSet rs = new ResultSet(
|
||||
GetReader(new[] { Common.StandardTestData }, false, Common.StandardQuery),
|
||||
GetReader(Common.StandardTestDataSet, false, Common.StandardQuery),
|
||||
Common.Ordinal, Common.Ordinal,
|
||||
Common.GetFileStreamFactory(new Dictionary<string, byte[]>()));
|
||||
|
||||
@@ -93,7 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
|
||||
// ... Create a result set with dummy data and read to the end
|
||||
ResultSet rs = new ResultSet(
|
||||
GetReader(new[] {Common.StandardTestData}, false, Common.StandardQuery),
|
||||
GetReader(Common.StandardTestDataSet, false, Common.StandardQuery),
|
||||
Common.Ordinal, Common.Ordinal,
|
||||
resultFactory);
|
||||
await rs.ReadResultToEnd(CancellationToken.None);
|
||||
@@ -129,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
|
||||
// ... Create a result set with dummy data and read to the end
|
||||
ResultSet rs = new ResultSet(
|
||||
GetReader(new[] { Common.StandardTestData }, false, Common.StandardQuery),
|
||||
GetReader(Common.StandardTestDataSet, false, Common.StandardQuery),
|
||||
Common.Ordinal, Common.Ordinal,
|
||||
resultFactory);
|
||||
await rs.ReadResultToEnd(CancellationToken.None);
|
||||
@@ -178,7 +179,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
return mockFactory.Object;
|
||||
}
|
||||
|
||||
private static DbDataReader GetReader(Dictionary<string, string>[][] dataSet, bool throwOnRead, string query)
|
||||
private static DbDataReader GetReader(TestResultSet[] dataSet, bool throwOnRead, string query)
|
||||
{
|
||||
var info = Common.CreateTestConnectionInfo(dataSet, throwOnRead);
|
||||
var connection = info.Factory.CreateSqlConnection(ConnectionService.BuildConnectionString(info.ConnectionDetails));
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
// ... A working query and workspace service
|
||||
WorkspaceService<SqlToolsSettings> ws = Common.GetPrimedWorkspaceService(Common.StandardQuery);
|
||||
Dictionary<string, byte[]> storage;
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage);
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, ws, out storage);
|
||||
|
||||
// ... The query execution service has executed a query with results
|
||||
var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||
@@ -103,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
// ... A working query and workspace service
|
||||
WorkspaceService<SqlToolsSettings> ws = Common.GetPrimedWorkspaceService(Common.StandardQuery);
|
||||
Dictionary<string, byte[]> storage;
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] {Common.StandardTestData}, true, false, ws, out storage);
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, ws, out storage);
|
||||
|
||||
// ... The query execution service has executed a query with results
|
||||
var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
|
||||
@@ -174,7 +174,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
// ... A working query and workspace service
|
||||
WorkspaceService<SqlToolsSettings> ws = Common.GetPrimedWorkspaceService(Common.StandardQuery);
|
||||
Dictionary<string, byte[]> storage;
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage);
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage);
|
||||
|
||||
// ... The query execution service has executed a query with results
|
||||
var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||
@@ -220,7 +220,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.SaveResults
|
||||
// ... A working query and workspace service
|
||||
WorkspaceService<SqlToolsSettings> ws = Common.GetPrimedWorkspaceService(Common.StandardQuery);
|
||||
Dictionary<string, byte[]> storage;
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(new[] { Common.StandardTestData }, true, false, ws, out storage);
|
||||
QueryExecutionService qes = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, ws, out storage);
|
||||
|
||||
// ... The query execution service has executed a query with results
|
||||
var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
// Then:
|
||||
// ... I should get the requested number of rows back
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestData.Length), subset.RowCount);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestData.Length), subset.Rows.Length);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestResultSet.Count()), subset.RowCount);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestResultSet.Count()), subset.Rows.Length);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -85,8 +85,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
|
||||
// Then:
|
||||
// I should get the requested number of rows
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestData.Length), subset.RowCount);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestData.Length), subset.Rows.Length);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestResultSet.Count()), subset.RowCount);
|
||||
Assert.Equal(Math.Min(rowCount, Common.StandardTestResultSet.Count()), subset.Rows.Length);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -131,7 +131,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
// If:
|
||||
// ... 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 queryService = Common.GetPrimedExecutionService(Common.ExecutionPlanTestDataSet, true, false, workspaceService);
|
||||
var executeParams = new ExecuteDocumentSelectionParams {QuerySelection = null, OwnerUri = Common.OwnerUri};
|
||||
var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
|
||||
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
|
||||
@@ -175,7 +175,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
|
||||
// If:
|
||||
// ... 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 queryService = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, workspaceService);
|
||||
var executeParams = new ExecuteDocumentSelectionParams { QuerySelection = null, OwnerUri = Common.OwnerUri };
|
||||
var executeRequest = RequestContextMocks.Create<ExecuteRequestResult>(null);
|
||||
await queryService.HandleExecuteRequest(executeParams, executeRequest.Object);
|
||||
|
||||
Reference in New Issue
Block a user