public void CodeElements_ProjectHasEmptyNamespaceName_EmptyNamespaceNameNotIncludedInMembers() { CreateCodeModel(); helper.AddNamespaceCompletionEntriesInNamespace(String.Empty, String.Empty, "Tests"); global::EnvDTE.CodeElements members = codeModel.CodeElements; CodeNamespace codeNamespace = members.FirstCodeNamespaceOrDefault(); Assert.AreEqual(1, members.Count); Assert.AreEqual("Tests", codeNamespace.Name); }
public void CodeElements_OneNamespaceInProject_ReturnsOneCodeNamespaceItem() { CreateCodeModel(); helper.AddNamespaceCompletionEntryInNamespace(String.Empty, "Test"); global::EnvDTE.CodeElements codeElements = codeModel.CodeElements; global::EnvDTE.CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault(); Assert.AreEqual(1, codeElements.Count); Assert.AreEqual("Test", codeNamespace.FullName); Assert.AreEqual("Test", codeNamespace.Name); }
public void CodeElements_OneNamespaceInProjectWithTwoPartsToName_ReturnsOneCodeNamespaceItemWithFirstPartOfNamespaceAsName() { CreateCodeModel(); helper.AddNamespaceCompletionEntryInNamespace(String.Empty, "First"); helper.AddNamespaceCompletionEntryInNamespace("First", "Second"); global::EnvDTE.CodeElements codeElements = codeModel.CodeElements; global::EnvDTE.CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault(); Assert.AreEqual(1, codeElements.Count); Assert.AreEqual("First", codeNamespace.FullName); Assert.AreEqual("First", codeNamespace.Name); }
public void Members_NamespaceHasOneChildNamespace_ReturnsOneChildNamespace() { string code = "namespace First.Second {}"; CreateCodeNamespace(code, "First"); global::EnvDTE.CodeElements members = codeNamespace.Members; CodeNamespace childNamespace = members.FirstCodeNamespaceOrDefault(); Assert.AreEqual("First", codeNamespace.Name); Assert.AreEqual(1, members.Count); Assert.AreEqual("Second", childNamespace.Name); Assert.AreEqual("First.Second", childNamespace.FullName); }
public void Members_NamespaceHasOneChildNamespace_ReturnsOneChildNamespace() { CreateProjectContent(); helper.AddNamespaceCompletionEntryInNamespace("First", "Second"); CreateCodeNamespace("First"); global::EnvDTE.CodeElements members = codeNamespace.Members; CodeNamespace childNamespace = members.FirstCodeNamespaceOrDefault(); Assert.AreEqual("First", codeNamespace.Name); Assert.AreEqual(1, members.Count); Assert.AreEqual("Second", childNamespace.Name); Assert.AreEqual("First.Second", childNamespace.FullName); }
public void FileCodeModel_GetCodeElementsFromFileCodeModelForProjectFile_FileServicePassedToFileCodeModel() { CreateProjectItems(@"d:\projects\MyProject\MyProject.csproj"); AddCompilationUnit(); msbuildProject.AddFile(@"src\program.cs"); global::EnvDTE.ProjectItem directoryItem = projectItems.Item("src"); global::EnvDTE.ProjectItem fileItem = directoryItem.ProjectItems.Item("program.cs"); global::EnvDTE.CodeElements codeElements = fileItem.FileCodeModel.CodeElements; CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault(); Assert.AreEqual(testableDteProject.TestableProject, fakeFileService.ProjectPassedToGetCompilationUnit); Assert.AreEqual(0, codeElements.Count); }
public void Members_NamespaceHasOneChildNamespaceWithThreeNamespaceParts_ReturnsOneChildNamespaceWhichHasOneChildNamespace() { string code = "namespace First.Second.Third {}"; CreateCodeNamespace(code, "First"); global::EnvDTE.CodeElements members = codeNamespace.Members; CodeNamespace secondNamespace = members.FirstCodeNamespaceOrDefault(); CodeNamespace thirdNamespace = secondNamespace.Members.FirstCodeNamespaceOrDefault(); Assert.AreEqual("First", codeNamespace.Name); Assert.AreEqual(1, members.Count); Assert.AreEqual("Second", secondNamespace.Name); Assert.AreEqual("First.Second", secondNamespace.FullName); Assert.AreEqual(1, secondNamespace.Members.Count); Assert.AreEqual("First.Second.Third", thirdNamespace.FullName); Assert.AreEqual(0, thirdNamespace.Members.Count); }
public void Members_NamespaceHasOneChildNamespaceWithThreeNamespaceParts_ReturnsOneChildNamespaceWhichHasOneChildNamespace() { CreateProjectContent(); helper.AddNamespaceCompletionEntryInNamespace("First", "Second"); helper.AddNamespaceCompletionEntryInNamespace("First.Second", "Third"); helper.NoCompletionItemsInNamespace("First.Second.Third"); CreateCodeNamespace("First"); global::EnvDTE.CodeElements members = codeNamespace.Members; CodeNamespace secondNamespace = members.FirstCodeNamespaceOrDefault(); CodeNamespace thirdNamespace = secondNamespace.Members.FirstCodeNamespaceOrDefault(); Assert.AreEqual("First", codeNamespace.Name); Assert.AreEqual(1, members.Count); Assert.AreEqual("Second", secondNamespace.Name); Assert.AreEqual("First.Second", secondNamespace.FullName); Assert.AreEqual(1, secondNamespace.Members.Count); Assert.AreEqual("First.Second.Third", thirdNamespace.FullName); Assert.AreEqual(0, thirdNamespace.Members.Count); }
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); }
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); }