Beispiel #1
0
        public void SetUp()
        {
            WebFormMetricContext metricContext = new WebFormMetricContext();

            _classConverterFactory = new ClassConverterFactory(string.Empty, new LifecycleManagerService(), new TaskManagerService(), metricContext);
            _workspaceManager      = new WorkspaceManagerService();
            _workspaceManager.CreateSolutionFile();
            _workspaceManager.NotifyNewExpectedProject();
            _primaryProjectId = _workspaceManager.CreateProjectFile("TestProjectName", metadataReferences: _metadataReferences);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        public async Task GetNamespacesReferencedByType_Does_Not_Contain_Own_Namespace()
        {
            _workspaceManager.NotifyNewExpectedProject();
            _workspaceManager.NotifyNewExpectedDocument();

            var pid1 = _workspaceManager.CreateProjectFile("TestProjectName1");
            var did1 = _workspaceManager.AddDocument(pid1, "TestDocumentName1", TestDocument1NamespaceText);

            var model = await _workspaceManager.GetCurrentDocumentSemanticModel(did1);

            var treeNodes = model.SyntaxTree.GetRoot().DescendantNodes();

            var testClass1Declaration = treeNodes.OfType <ClassDeclarationSyntax>().Single(node => node.Identifier.ToString().Equals("TestClass1"));
            var classSymbol           = model.GetDeclaredSymbol(testClass1Declaration);
            var requiredNamespaces    = model.GetNamespacesReferencedByType(testClass1Declaration);

            Assert.False(requiredNamespaces.Contains(classSymbol?.ContainingNamespace?.ToDisplayString()));
        }
        public void CreateProjectFile_Creates_Single_Project_On_Solution()
        {
            _workspaceManager.CreateSolutionFile();
            _workspaceManager.NotifyNewExpectedProject();
            _workspaceManager.CreateProjectFile("TestProjectName");

            Assert.AreEqual(_workspaceManager.CurrentSolution.Projects.Count(), 1);
        }