Adding sr.strings file and removing hard-coded strings (#52)

* Strings sweep for connection service

* String sweep for credentials service

* String sweep for hosting

* String sweep for query execution service

* String sweep for Workspace service

* Renaming utility namespace to match standards

Renaming Microsoft.SqlTools.EditorServices.Utility to
Microsoft.SqlTools.ServiceLayer.Utility to match the naming changes done a
while back. Also renaming them on the files that use them

* Namespace change on reliable connection

* Adding the new resx and designer files

* Final bug fixes for srgen

Fixing flakey moq package name

* Removing todo as per @kevcunnane

* Adding using statements as per @llali's comment

* Fixing issues from broken unit tests

Note: This feature contains changes that will break the contract for
saving as CSV and JSON. On success, null is returned as a message instead
of "Success". Changes will be made to the vscode component to handle this
change.
This commit is contained in:
Benjamin Russell
2016-09-16 16:18:25 -07:00
committed by GitHub
parent 55047a0196
commit 41198e9357
63 changed files with 1713 additions and 264 deletions

View File

@@ -26,7 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.DataStorage
// ... It should throw an argument null exception
using (FileStreamWrapper fsw = new FileStreamWrapper())
{
Assert.Throws<ArgumentNullException>(() => fsw.Init(fileName, 8192, FileAccess.Read));
Assert.Throws<ArgumentException>(() => fsw.Init(fileName, 8192, FileAccess.Read));
}
}

View File

@@ -229,7 +229,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
// ... I create a query that has a null query text
// Then:
// ... It should throw an exception
Assert.Throws<ArgumentNullException>(() =>
Assert.Throws<ArgumentException>(() =>
new Query(null, Common.CreateTestConnectionInfo(null, false), new QueryExecutionSettings(), Common.GetFileStreamFactory()));
}

View File

@@ -32,16 +32,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as csv with correct parameters
var saveParams = new SaveResultsAsCsvRequestParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
saveParams.FilePath = "testwrite.csv";
saveParams.IncludeHeaders = true;
var saveParams = new SaveResultsAsCsvRequestParams
{
OwnerUri = Common.OwnerUri,
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = "testwrite_1.csv",
IncludeHeaders = true
};
SaveResultRequestResult result = null;
var saveRequest = GetSaveResultsContextMock(qcr => result = qcr, null);
queryService.ActiveQueries[Common.OwnerUri].Batches[0] = Common.GetBasicExecutedBatch();
queryService.HandleSaveResultsAsCsvRequest(saveParams, saveRequest.Object).Wait();
// Expect to see a file successfully created in filepath and a success message
Assert.Equal("Success", result.Messages);
Assert.Null(result.Messages);
Assert.True(File.Exists(saveParams.FilePath));
VerifySaveResultsCallCount(saveRequest, Times.Once(), Times.Never());
@@ -65,15 +70,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as csv with incorrect filepath
var saveParams = new SaveResultsAsCsvRequestParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
if (RuntimeInformation.IsOSPlatform( OSPlatform.Windows))
var saveParams = new SaveResultsAsCsvRequestParams
{
saveParams.FilePath = "G:\\test.csv";
}
else
{
saveParams.FilePath = "/test.csv";
}
OwnerUri = Common.OwnerUri,
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "G:\\test.csv" : "/test.csv"
};
// SaveResultRequestResult result = null;
string errMessage = null;
var saveRequest = GetSaveResultsContextMock( null, err => errMessage = (string) err);
@@ -99,14 +102,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as csv with query that is no longer active
var saveParams = new SaveResultsAsCsvRequestParams { OwnerUri = "falseuri", ResultSetIndex = 0, BatchIndex = 0 };
saveParams.FilePath = "testwrite.csv";
var saveParams = new SaveResultsAsCsvRequestParams
{
OwnerUri = "falseuri",
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = "testwrite_3.csv"
};
SaveResultRequestResult result = null;
var saveRequest = GetSaveResultsContextMock(qcr => result = qcr, null);
queryService.HandleSaveResultsAsCsvRequest(saveParams, saveRequest.Object).Wait();
// Expect message that save failed
Assert.Equal("Failed to save results, ID not found.", result.Messages);
Assert.NotNull(result.Messages);
Assert.False(File.Exists(saveParams.FilePath));
VerifySaveResultsCallCount(saveRequest, Times.Once(), Times.Never());
}
@@ -124,15 +132,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as json with correct parameters
var saveParams = new SaveResultsAsJsonRequestParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
saveParams.FilePath = "testwrite.json";
var saveParams = new SaveResultsAsJsonRequestParams
{
OwnerUri = Common.OwnerUri,
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = "testwrite_4.json"
};
SaveResultRequestResult result = null;
var saveRequest = GetSaveResultsContextMock(qcr => result = qcr, null);
queryService.ActiveQueries[Common.OwnerUri].Batches[0] = Common.GetBasicExecutedBatch();
queryService.HandleSaveResultsAsJsonRequest(saveParams, saveRequest.Object).Wait();
// Expect to see a file successfully created in filepath and a success message
Assert.Equal("Success", result.Messages);
Assert.Null(result.Messages);
Assert.True(File.Exists(saveParams.FilePath));
VerifySaveResultsCallCount(saveRequest, Times.Once(), Times.Never());
@@ -156,15 +169,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as json with incorrect filepath
var saveParams = new SaveResultsAsJsonRequestParams { OwnerUri = Common.OwnerUri, ResultSetIndex = 0, BatchIndex = 0 };
if (RuntimeInformation.IsOSPlatform( OSPlatform.Windows))
var saveParams = new SaveResultsAsJsonRequestParams
{
saveParams.FilePath = "G:\\test.json";
}
else
{
saveParams.FilePath = "/test.json";
}
OwnerUri = Common.OwnerUri,
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "G:\\test.json" : "/test.json"
};
// SaveResultRequestResult result = null;
string errMessage = null;
var saveRequest = GetSaveResultsContextMock( null, err => errMessage = (string) err);
@@ -190,8 +201,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
queryService.HandleExecuteRequest(executeParams, executeRequest.Object).Wait();
// Request to save the results as json with query that is no longer active
var saveParams = new SaveResultsAsJsonRequestParams { OwnerUri = "falseuri", ResultSetIndex = 0, BatchIndex = 0 };
saveParams.FilePath = "testwrite.json";
var saveParams = new SaveResultsAsJsonRequestParams
{
OwnerUri = "falseuri",
ResultSetIndex = 0,
BatchIndex = 0,
FilePath = "testwrite_6.json"
};
SaveResultRequestResult result = null;
var saveRequest = GetSaveResultsContextMock(qcr => result = qcr, null);
queryService.HandleSaveResultsAsJsonRequest(saveParams, saveRequest.Object).Wait();