public void ShouldReturnIdOfFolderIfIsFirstChild() { var hierarchyHelper = new HierarchyHelper(); var mockHierarchy = new MockVsHierarchy2(); Node folderNode = new Node() { Name = "folder" }; Node rootNode = new Node(true) { FirstChild = folderNode }; mockHierarchy.AddNode(rootNode); var itemId = hierarchyHelper.GetItemId(mockHierarchy, "folder"); Assert.AreEqual(folderNode.ItemId, itemId); }
public void ShouldReturnIdOfFolderIfInSubFolder() { var hierarchyHelper = new HierarchyHelper(); var mockHierarchy = new MockVsHierarchy2(); Node subFolderNode = new Node() { Name = "subfolder" }; Node folderNode = new Node() { Name = "folder", FirstChild = subFolderNode }; Node firstChildNode = new Node() { Name = "otherItem", NextSibling = folderNode }; Node rootNode = new Node(true) { FirstChild = firstChildNode }; mockHierarchy.AddNode(rootNode); var itemId = hierarchyHelper.GetItemId(mockHierarchy, "folder\\subfolder"); Assert.AreEqual(subFolderNode.ItemId, itemId); }
public void AddNode(Node node) { nodes.Add(node.ItemId, node); if (node.FirstChild != null) { AddNode(node.FirstChild); } if (node.NextSibling != null) { AddNode(node.NextSibling); } }
public void ShouldReturnNilIfElementDoesntExists() { var hierarchyHelper = new HierarchyHelper(); var mockHierarchy = new MockVsHierarchy2(); Node firstChildNode = new Node() { Name = "anotherItem" }; Node rootNode = new Node(true) { FirstChild = firstChildNode }; mockHierarchy.AddNode(rootNode); var itemId = hierarchyHelper.GetItemId(mockHierarchy, "folder\\subfolder"); Assert.AreEqual(VSConstants.VSITEMID_NIL, itemId); }