예제 #1
0
        public void CodeElements_TwoNamespacesInProjectWithFirstPartsTheName_ReturnsOneParentNamespaceWithTwoChildNamespaces()
        {
            CreateCodeModel();
            string code =
                "namespace First.A { }\r\n" +
                "namespace First.B { }\r\n";

            AddClassToProject(code);

            global::EnvDTE.CodeElements codeElements = codeModel.CodeElements;
            CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault();

            global::EnvDTE.CodeElements members = codeNamespace.Members;
            CodeNamespace firstChildNamespace   = members.FirstCodeNamespaceOrDefault();
            CodeNamespace secondChildNamespace  = members.LastCodeNamespaceOrDefault();

            Assert.AreEqual("First", codeNamespace.FullName);
            Assert.AreEqual(2, codeNamespace.Members.Count);
            Assert.AreEqual("A", firstChildNamespace.Name);
            Assert.AreEqual("B", secondChildNamespace.Name);
        }
예제 #2
0
        public void CodeElements_TwoNamespacesInProjectWithFirstPartsTheName_ReturnsOneParentNamespaceWithTwoChildNamespaces()
        {
            CreateCodeModel();
            helper.AddNamespaceCompletionEntryInNamespace(String.Empty, "First");
            helper.AddNamespaceCompletionEntriesInNamespace("First", "A", "B");
            helper.NoCompletionItemsInNamespace("First.A");
            helper.NoCompletionItemsInNamespace("First.B");

            global::EnvDTE.CodeElements codeElements = codeModel.CodeElements;
            CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault();

            global::EnvDTE.CodeElements members = codeNamespace.Members;
            CodeNamespace firstChildNamespace   = members.FirstCodeNamespaceOrDefault();
            CodeNamespace secondChildNamespace  = members.LastCodeNamespaceOrDefault();

            Assert.AreEqual(1, codeElements.Count);
            Assert.AreEqual("First", codeNamespace.FullName);
            Assert.AreEqual(2, codeNamespace.Members.Count);
            Assert.AreEqual("A", firstChildNamespace.Name);
            Assert.AreEqual("B", secondChildNamespace.Name);
        }