public async Task ConnectOnPremTest() { TestServerType serverType = TestServerType.OnPrem; using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { const string query = Scripts.TestDbSimpleSelectQuery; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); var connected = await testService.CalculateRunTime(async() => { var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName); return(await testService.Connect(queryTempFile.FilePath, connectParams)); }, true); Assert.True(connected, "Connection was not successful"); } }
public async Task CompletionTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); Assert.True(connected, "Connection is successful"); Thread.Sleep(10000); CompletionItem[] completions = await testService.RequestCompletion(queryTempFile.FilePath, query, 0, 15); Assert.True(completions != null && completions.Length > 0, "Completion items list is null or empty"); Thread.Sleep(50); await testService.RequestResolveCompletion(completions[0]); Assert.True(completions != null && completions.Length > 0, "Completion items list is null or empty"); await testService.Disconnect(queryTempFile.FilePath); } }
public async Task DefinitionTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; int lineNumber = 0; int position = 23; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); // Wait for intellisense to be ready var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000); Assert.NotNull(readyParams); Assert.True(connected, "Connection is successful"); // Request definition for "objects" Location[] locations = await testService.RequestDefinition(queryTempFile.FilePath, query, lineNumber, position); Assert.True(locations != null, "Location is not null and not empty"); await testService.Disconnect(queryTempFile.FilePath); } }
public async Task HoverTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); Assert.True(connected, "Connection was not successful"); Thread.Sleep(10000); Hover hover = await testService.RequestHover(queryTempFile.FilePath, query, 0, 15); Assert.True(hover != null, "Hover tooltop is null"); await testService.Disconnect(queryTempFile.FilePath); } }
public async Task DiagnosticsTests() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); Assert.True(connected, "Connection was not successful"); Thread.Sleep(500); string query = "SELECT *** FROM sys.objects"; DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(100); 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" }; DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams() { ContentChanges = contentChanges, TextDocument = new VersionedTextDocumentIdentifier() { Version = 2, Uri = queryTempFile.FilePath } }; await testService.RequestChangeTextDocumentNotification(changeParams); Thread.Sleep(100); contentChanges[0] = new TextDocumentChangeEvent { Range = new Range { Start = new Position { Line = 0, Character = 5 }, End = new Position { Line = 0, Character = 6 } }, RangeLength = 1, Text = "t" }; changeParams = new DidChangeTextDocumentParams { ContentChanges = contentChanges, TextDocument = new VersionedTextDocumentIdentifier { Version = 3, Uri = queryTempFile.FilePath } }; await testService.RequestChangeTextDocumentNotification(changeParams); Thread.Sleep(2500); await testService.Disconnect(queryTempFile.FilePath); } }