mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-21 09:35:39 -05:00
Next batch of code coverage tests. (#128)
Auto-merging test-only changes. Please review the commit and I'll make changes in next iteration. * Add more tests to boast code coverage * Add more reliable connection tests.
This commit is contained in:
@@ -30,15 +30,12 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
public async Task HoverTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
string ownerUri = System.IO.Path.GetTempFileName();
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||
Assert.True(connected, "Connection is successful");
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
string query = "SELECT * FROM sys.objects";
|
||||
|
||||
WriteToFile(ownerUri, query);
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification()
|
||||
{
|
||||
TextDocument = new TextDocumentItem()
|
||||
@@ -51,7 +48,14 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
};
|
||||
|
||||
await RequestOpenDocumentNotification(openParams);
|
||||
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||
Assert.True(connected, "Connection is successful");
|
||||
|
||||
Thread.Sleep(10000);
|
||||
|
||||
Hover hover = await RequestHover(ownerUri, query, 0, 15);
|
||||
|
||||
Assert.True(hover != null, "Hover tooltop is not null");
|
||||
@@ -71,15 +75,12 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
public async Task CompletionTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
string ownerUri = System.IO.Path.GetTempFileName();
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||
Assert.True(connected, "Connection is successful");
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
string query = "SELECT * FROM sys.objects";
|
||||
|
||||
WriteToFile(ownerUri, query);
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification()
|
||||
{
|
||||
TextDocument = new TextDocumentItem()
|
||||
@@ -92,43 +93,20 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
};
|
||||
|
||||
await RequestOpenDocumentNotification(openParams);
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
var contentChanges = new TextDocumentChangeEvent[1];
|
||||
contentChanges[0] = new TextDocumentChangeEvent()
|
||||
{
|
||||
Range = new Range()
|
||||
{
|
||||
Start = new Position()
|
||||
{
|
||||
Line = 0,
|
||||
Character = 5
|
||||
},
|
||||
End = new Position()
|
||||
{
|
||||
Line = 0,
|
||||
Character = 6
|
||||
}
|
||||
},
|
||||
RangeLength = 1,
|
||||
Text = "z"
|
||||
};
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||
Assert.True(connected, "Connection is successful");
|
||||
|
||||
DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams()
|
||||
{
|
||||
ContentChanges = contentChanges,
|
||||
TextDocument = new VersionedTextDocumentIdentifier()
|
||||
{
|
||||
Version = 2,
|
||||
Uri = ownerUri
|
||||
}
|
||||
};
|
||||
Thread.Sleep(10000);
|
||||
|
||||
await RequestChangeTextDocumentNotification(changeParams);
|
||||
|
||||
CompletionItem[] completions = await RequestCompletion(ownerUri, query, 0, 15);
|
||||
|
||||
Assert.True(completions != null && completions.Length > 0, "Completion items list is not null and not empty");
|
||||
|
||||
Thread.Sleep(50);
|
||||
|
||||
CompletionItem item = await RequestResolveCompletion(completions[0]);
|
||||
|
||||
Assert.True(completions != null && completions.Length > 0, "Completion items list is not null and not empty");
|
||||
|
||||
Reference in New Issue
Block a user