mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-06 17:24:59 -05:00
Add end-to-end language service tests. (#123)
Test-only code coverage changes. Please review the commit and I'll follow-up on next iteration.
This commit is contained in:
@@ -38,17 +38,23 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
|
||||
public void WaitForExit()
|
||||
{
|
||||
this.isRunning = false;
|
||||
try
|
||||
{
|
||||
this.isRunning = false;
|
||||
|
||||
if (!Driver.IsCoverageRun)
|
||||
{
|
||||
Driver.Stop().Wait();
|
||||
if (!Driver.IsCoverageRun)
|
||||
{
|
||||
Driver.Stop().Wait();
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = Process.Start("taskkill", "/IM Microsoft.SqlTools.ServiceLayer.exe /F");
|
||||
p.WaitForExit();
|
||||
Driver.ServiceProcess?.WaitForExit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = Process.Start("taskkill", "/IM Microsoft.SqlTools.ServiceLayer.exe /F");
|
||||
p.WaitForExit();
|
||||
Driver.ServiceProcess?.WaitForExit();
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +100,31 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
return disconnectResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request the active SQL script is parsed for errors
|
||||
/// </summary>
|
||||
protected async Task RequestOpenDocumentNotification(DidOpenTextDocumentNotification openParams)
|
||||
{
|
||||
await Driver.SendEvent(DidOpenTextDocumentNotification.Type, openParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /// Request the active SQL script is parsed for errors
|
||||
/// </summary>
|
||||
protected async Task RequestChangeTextDocumentNotification(DidChangeTextDocumentParams changeParams)
|
||||
{
|
||||
await Driver.SendEvent(DidChangeTextDocumentNotification.Type, changeParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request completion item resolve to look-up additional info
|
||||
/// </summary>
|
||||
protected async Task<CompletionItem> RequestResolveCompletion(CompletionItem item)
|
||||
{
|
||||
var result = await Driver.SendRequest(CompletionResolveRequest.Type, item);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request a list of completion items for a position in a block of text
|
||||
/// </summary>
|
||||
@@ -116,6 +147,28 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request a a hover tooltop
|
||||
/// </summary>
|
||||
protected async Task<Hover> RequestHover(string ownerUri, string text, int line, int character)
|
||||
{
|
||||
// Write the text to a backing file
|
||||
lock (fileLock)
|
||||
{
|
||||
System.IO.File.WriteAllText(ownerUri, text);
|
||||
}
|
||||
|
||||
var completionParams = new TextDocumentPosition();
|
||||
completionParams.TextDocument = new TextDocumentIdentifier();
|
||||
completionParams.TextDocument.Uri = ownerUri;
|
||||
completionParams.Position = new Position();
|
||||
completionParams.Position.Line = line;
|
||||
completionParams.Position.Character = character;
|
||||
|
||||
var result = await Driver.SendRequest(HoverRequest.Type, completionParams);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run a query using a given connection bound to a URI
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user