public async Task GetCurrentDocumentSyntaxTree_Correctly_Builds_Syntax_Tree() { _workspaceManager.CreateSolutionFile(); _workspaceManager.NotifyNewExpectedProject(); _workspaceManager.NotifyNewExpectedDocument(); var pid1 = _workspaceManager.CreateProjectFile("TestProjectName1"); var did1 = _workspaceManager.AddDocument(pid1, "TestDocumentName1", TestDocument1Text); var syntaxTree = await _workspaceManager.GetCurrentDocumentSyntaxTree(did1); Assert.AreEqual(TestDocument1Text, syntaxTree.ToString()); }
public async Task GetNamespaceLevelTypes_Retrieves_All_Types(string testDocumentText) { _workspaceManager.NotifyNewExpectedProject(); _workspaceManager.NotifyNewExpectedDocument(); var pid1 = _workspaceManager.CreateProjectFile("TestProjectName1"); var did1 = _workspaceManager.AddDocument(pid1, "TestDocumentName1", testDocumentText); var syntaxTree = await _workspaceManager.GetCurrentDocumentSyntaxTree(did1); var testTypeNodes = syntaxTree.GetRoot().DescendantNodes().OfType <TypeDeclarationSyntax>(); var testType1 = testTypeNodes.Single(node => node.Identifier.ToString().Equals("TestType1")); var testType2 = testTypeNodes.Single(node => node.Identifier.ToString().Equals("TestType2")); var types = syntaxTree.GetNamespaceLevelTypes(); Assert.True(types.Contains(testType1)); Assert.True(types.Contains(testType2)); }