1 write to TestWorkspace
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
LanguageServer\AbstractLanguageServerProtocolTests.cs (1)
507TestWorkspace = testWorkspace;
145 references to TestWorkspace
IdeBenchmarks (1)
Lsp\LspCompletionBenchmarks.cs (1)
96_globalOptionService = _testServer.TestWorkspace.GetService<IGlobalOptionService>();
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (11)
LanguageServer\AbstractLanguageServerProtocolTests.cs (11)
519TestWorkspace.GetService<LspWorkspaceRegistrationService>().Register(GetManagerAccessor().GetLspMiscellaneousFilesWorkspace()); 528var workspaceWaiter = GetWorkspaceWaiter(TestWorkspace); 611var sourceText = await TestWorkspace.CurrentSolution.GetDocuments(documentUri).First().GetTextAsync(CancellationToken.None).ConfigureAwait(false); 667public Solution GetCurrentSolution() => TestWorkspace.CurrentSolution; 671var listenerProvider = TestWorkspace.GetService<IAsynchronousOperationListenerProvider>(); 692TestWorkspace.GetService<LspWorkspaceRegistrationService>().Deregister(TestWorkspace); 693TestWorkspace.GetService<LspWorkspaceRegistrationService>().Deregister(GetManagerAccessor().GetLspMiscellaneousFilesWorkspace()); 695var solutionCrawlerRegistrationService = (SolutionCrawlerRegistrationService)TestWorkspace.Services.GetRequiredService<ISolutionCrawlerRegistrationService>(); 696solutionCrawlerRegistrationService.Unregister(TestWorkspace); 709TestWorkspace.Dispose();
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (133)
CodeActions\RunCodeActionsTests.cs (1)
56var documentForB = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.Single(doc => doc.Name.Equals("B.cs", StringComparison.OrdinalIgnoreCase));
Completion\CompletionResolveTests.cs (1)
186document, new TestCaretOutOfScopeCompletionService(testLspServer.TestWorkspace.Services.SolutionServices), selectedItem, snippetsSupported: true, CancellationToken.None).ConfigureAwait(false);
Completion\CompletionTests.cs (4)
210var solution = testLspServer.TestWorkspace.CurrentSolution; 213testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, true); 236testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(CompletionOptionsStorage.SnippetsBehavior, LanguageNames.CSharp, SnippetsRule.NeverInclude); 1289var globalOptions = testLspServer.TestWorkspace.GetService<IGlobalOptionService>();
Definitions\GoToDefinitionTests.cs (1)
84AddMappedDocument(testLspServer.TestWorkspace, markup);
Diagnostics\AbstractPullDiagnosticTestsBase.cs (1)
63var optionService = testLspServer.TestWorkspace.GetService<IGlobalOptionService>();
Diagnostics\AdditionalFileDiagnosticsTests.cs (1)
79await testLspServer.TestWorkspace.ChangeSolutionAsync(newSolution);
Diagnostics\PullDiagnosticTests.cs (51)
59testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 81testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 118testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 143testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 166testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 194testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 212testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 217testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag, false); 231testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 235testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag, true); 247var workspace = testLspServer.TestWorkspace; 281testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 308testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 321var encDiagnosticsSource = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<EditAndContinueDiagnosticUpdateSource>(); 323encDiagnosticsSource.ReportDiagnostics(testLspServer.TestWorkspace, testLspServer.TestWorkspace.CurrentSolution, ImmutableArray<DiagnosticData>.Empty, rudeEdits); 341var buffer = testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 364var buffer = testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 393testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 414testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 452testLspServer.TestWorkspace.GetTestDocument(csproj1Document.Id).GetTextBuffer(); 455testLspServer.TestWorkspace.SetDocumentContext(csproj2Document.Id); 466testLspServer.TestWorkspace.SetDocumentContext(csproj1Document.Id); 626testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 651testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 672testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 678testLspServer.TestWorkspace.OnAnalyzerReferenceAdded( 703testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp, true); 742testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp, false); 883testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption( 1005testLspServer.TestWorkspace.OnAnalyzerReferenceAdded( 1026testLspServer.TestWorkspace.OnAnalyzerReferenceAdded( 1110testLspServer.TestWorkspace.OnDocumentRemoved(testLspServer.TestWorkspace.Documents.First().Id); 1170var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); 1205var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); 1213testLspServer.TestWorkspace.OnDocumentClosed( 1306await testLspServer.TestWorkspace.ChangeDocumentAsync(csproj2Document.Id, newCsProj2Document.Project.Solution); 1381await testLspServer.TestWorkspace.ChangeDocumentAsync(csproj3Document.Id, newCsProj3Document.Project.Solution).ConfigureAwait(false); 1448await testLspServer.TestWorkspace.ChangeDocumentAsync(csproj2Document.Id, newCsProj2Document.Project.Solution); 1506var projectInfo = testLspServer.TestWorkspace.Projects.Where(p => p.AssemblyName == "CSProj2").Single().ToProjectInfo(); 1508testLspServer.TestWorkspace.OnProjectReloaded(projectInfo); 1509var operations = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<AsynchronousOperationListenerProvider>(); 1561var projectInfo = testLspServer.TestWorkspace.Projects.Where(p => p.AssemblyName == "CSProj2").Single().ToProjectInfo(); 1562testLspServer.TestWorkspace.OnProjectReloaded(projectInfo); 1563var operations = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<AsynchronousOperationListenerProvider>(); 1616var projectInfo = testLspServer.TestWorkspace.Projects.Where(p => p.AssemblyName == "CSProj2").Single().ToProjectInfo(); 1617testLspServer.TestWorkspace.OnProjectReloaded(projectInfo); 1618var operations = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<AsynchronousOperationListenerProvider>(); 1701var projectInfo = testLspServer.TestWorkspace.Projects.Single().ToProjectInfo(); 1702testLspServer.TestWorkspace.OnProjectReloaded(projectInfo);
Diagnostics\WorkspaceProjectDiagnosticsTests.cs (1)
59await testLspServer.TestWorkspace.ChangeSolutionAsync(newSolution);
InlineCompletions\InlineCompletionsTests.cs (1)
254var snippetParser = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<XmlSnippetParser>();
Miscellaneous\LspMiscellaneousFilesWorkspaceTests.cs (4)
64testLspServer.TestWorkspace.GetService<LspWorkspaceRegistrationService>().Register(miscWorkspace); 163testLspServer.TestWorkspace.OnDocumentAdded(documentInfo); 164await WaitForWorkspaceOperationsAsync(testLspServer.TestWorkspace); 214Assert.Equal(testLspServer.TestWorkspace, lspWorkspace);
Options\LspOptionsTests.cs (2)
37var globalOptions = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<IGlobalOptionService>(); 51var globalOptions = testLspServer.TestWorkspace.ExportProvider.GetExportedValue<IGlobalOptionService>();
Ordering\RequestOrderingTests.cs (1)
212testLspServer.TestWorkspace.SetCurrentSolution(s => s.WithProjectName(s.Projects.First().Id, "NewName"), WorkspaceChangeKind.ProjectChanged);
ProjectContext\GetTextDocumentWithContextHandlerTests.cs (2)
85foreach (var document in testLspServer.TestWorkspace.Documents) 94testLspServer.TestWorkspace.SetDocumentContext(project.DocumentIds.Single());
References\FindImplementationsTests.cs (1)
90AddMappedDocument(testLspServer.TestWorkspace, markup);
Rename\RenameTests.cs (1)
167AddMappedDocument(testLspServer.TestWorkspace, markup);
SpellCheck\SpellCheckTests.cs (26)
53var testDocument = testLspServer.TestWorkspace.Documents.Single(); 79var workspace = testLspServer.TestWorkspace; 121testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 134Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 157var buffer = testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 170Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 205var buffer = testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 217Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 231Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 246testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 259Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 273testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 286Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.Single().AnnotatedSpans), 308var document = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.First(); 314Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), 381var document = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.First(); 387Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), 391testLspServer.TestWorkspace.OnDocumentRemoved(testLspServer.TestWorkspace.Documents.First().Id); 419var document = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.First(); 425Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), 455var document = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.First(); 461Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), 465var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); 508var document = testLspServer.TestWorkspace.CurrentSolution.Projects.Single().Documents.First(); 514Ranges = GetRanges(sourceText, testLspServer.TestWorkspace.Documents.First().AnnotatedSpans),
Workspaces\LspWorkspaceManagerTests.cs (33)
69Assert.Same(testLspServer.TestWorkspace.CurrentSolution.GetDocument(firstDocument.Id), firstDocument); 70Assert.Same(testLspServer.TestWorkspace.CurrentSolution.GetDocument(secondDocument.Id), secondDocument); 74await testLspServer.TestWorkspace.ChangeDocumentAsync(firstDocument.Id, SourceText.From($"Some more text{markupOne}", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 89Assert.Equal(testLspServer.TestWorkspace.CurrentSolution.GetDocument(firstDocumentWithChange.Id), firstDocumentWithChange); 90Assert.Equal(testLspServer.TestWorkspace.CurrentSolution.GetDocument(secondDocumentUnchanged.Id), secondDocumentUnchanged); 108await testLspServer.TestWorkspace.ChangeDocumentAsync(secondDocument.Id, SourceText.From("Two is now three!", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 119Assert.NotEqual(testLspServer.TestWorkspace.CurrentSolution.GetDocument(secondDocument.Id), secondDocument); 132Assert.Equal(testLspServer.TestWorkspace.CurrentSolution, openedDocument!.Project.Solution); 135var newProject = testLspServer.TestWorkspace.CurrentSolution.Projects.First().WithAssemblyName("NewCSProj1"); 136await testLspServer.TestWorkspace.ChangeProjectAsync(newProject.Id, newProject.Solution); 143Assert.Equal(testLspServer.TestWorkspace.CurrentSolution, openedDocument.Project.Solution); 156Assert.NotEqual(testLspServer.TestWorkspace.CurrentSolution, openedDocument!.Project.Solution); 159var newProject = testLspServer.TestWorkspace.CurrentSolution.Projects.First().WithAssemblyName("NewCSProj1"); 160await testLspServer.TestWorkspace.ChangeProjectAsync(newProject.Id, newProject.Solution); 167Assert.NotEqual(testLspServer.TestWorkspace.CurrentSolution, openedDocument.Project.Solution); 181var newDocumentId = DocumentId.CreateNewId(testLspServer.TestWorkspace.CurrentSolution.ProjectIds[0]); 182var newSolution = testLspServer.TestWorkspace.CurrentSolution.AddDocument(newDocumentId, "NewDoc.cs", SourceText.From("New Doc", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default), filePath: @"C:\NewDoc.cs"); 184await testLspServer.TestWorkspace.ChangeSolutionAsync(newSolution); 190Assert.Equal(testLspServer.TestWorkspace.CurrentSolution, lspDocument.Project.Solution); 202var newDocumentId = DocumentId.CreateNewId(testLspServer.TestWorkspace.CurrentSolution.ProjectIds[0]); 224await testLspServer.TestWorkspace.AddDocumentAsync(newDocumentInfo); 229Assert.Equal(testLspServer.TestWorkspace, documentWorkspace); 255Assert.True(IsWorkspaceRegistered(testLspServer.TestWorkspace, testLspServer)); 260composition: testLspServer.TestWorkspace.Composition); 266var workspaceRegistrationService = testLspServer.TestWorkspace.GetService<LspWorkspaceRegistrationService>(); 270Assert.True(IsWorkspaceRegistered(testLspServer.TestWorkspace, testLspServer)); 290var exportProvider = testLspServer.TestWorkspace.ExportProvider; 296Assert.True(IsWorkspaceRegistered(testLspServer.TestWorkspace, testLspServer)); 329Assert.True(IsWorkspaceRegistered(testLspServer.TestWorkspace, testLspServer)); 340Assert.Equal(testLspServer.TestWorkspace, firstWorkspace); 395Assert.Equal(testLspServer.TestWorkspace, firstWorkspace); 473testLspServer.TestWorkspace.Documents.Single().GetTextBuffer(); 481Assert.Same(testLspServer.TestWorkspace.CurrentSolution, lspDocument.Project.Solution);
Workspaces\LspWorkspaceRegistrationServiceTests.cs (1)
29registrationService = (TestWorkspaceRegistrationService)testLspServer.TestWorkspace.ExportProvider.GetExportedValue<LspWorkspaceRegistrationService>();