public void CreateVsSolution()
 {
     root = new MockVSHierarchy();
     vsSolution = new MockVsSolution(root);
     project = new MockVSHierarchy("Project.project");
     root.AddProject(project);
 }
 public void EnumerationWalking()
 {
     int children = 3;
     MockVSHierarchy hierarchy = new MockVSHierarchy(children);
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode node = new HierarchyNode(solution);
     int i = 0;
     foreach (HierarchyNode child in node.Children)
     {
         ++i;
     }
     Assert.AreEqual<int>(children, i, "Invalid number of children");
 }
 public void FindByName()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     string child1 = "Child1";
     string child2 = "Child2";
     string child3 = "Child3";
     string child4 = "Child4";
     hierarchy.AddChild(child1);
     hierarchy.AddChild(child2);
     hierarchy.AddChild(child3);
     HierarchyNode node = new HierarchyNode(solution);
     Assert.IsNotNull(node.FindByName(child1));
     Assert.IsNotNull(node.FindByName(child2));
     Assert.IsNotNull(node.FindByName(child3));
     Assert.IsNull(node.FindByName(child4));
 }
 public void FindOrCreateSolutionFolder()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode node = new HierarchyNode(solution);
     string folderName = "SlnItems";
     HierarchyNode folder = node.FindOrCreateSolutionFolder(folderName);
     Assert.IsNotNull(folder);
     Assert.AreEqual<string>(folderName, folder.Name);
 }
 public void TestRelativePath()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     MockVSHierarchy folder1 = new MockVSHierarchy("folder1");
     hierarchy.AddProject(folder1);
     string child1 = "subFolder1";
     folder1.AddChild(child1);
     HierarchyNode rootNode = new HierarchyNode(solution);
     HierarchyNode folder1Node = rootNode.FindByName("folder1");
     HierarchyNode child1Node = folder1Node.FindByName(child1);
     Assert.IsNotNull(child1Node.RelativePath);
     Assert.AreEqual<string>(Path.Combine(Directory.GetCurrentDirectory(), child1), child1Node.RelativePath);
 }
 public void TestHasProperty()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode slnNode = new HierarchyNode(solution);
     Assert.IsFalse(slnNode.HasIconIndex);
 }
        public void RecursiveFindByName()
        {
            MockVSHierarchy hierarchy = new MockVSHierarchy();
            MockVsSolution solution = new MockVsSolution(hierarchy);
            MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
            hierarchy.AddProject(project1);
            string child1 = "Child1";
            project1.AddChild(child1);
            MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
            hierarchy.AddProject(project2);
            string child2 = "Child2";
            project2.AddChild(child2);
            string child3 = "Child3";
            project2.AddChild(child3);
            string child4 = "Child4";

            HierarchyNode node = new HierarchyNode(solution);
            Assert.IsNull(node.FindByName(child1));
            Assert.IsNull(node.FindByName(child2));
            Assert.IsNull(node.FindByName(child3));
            Assert.IsNull(node.FindByName(child4));
            Assert.IsNotNull(node.RecursiveFindByName(child1));
            Assert.IsNotNull(node.RecursiveFindByName(child2));
            Assert.IsNotNull(node.RecursiveFindByName(child3));
            Assert.IsNull(node.RecursiveFindByName(child4));
        }
 public void DeleteVsSolution()
 {
     project = null;
     vsSolution = null;
     root = null;
 }
 public void TestFileHasIcon()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     string docName = "Doc1.doc";
     hierarchy.AddChild(docName);
     HierarchyNode slnNode = new HierarchyNode(solution);
     HierarchyNode node = slnNode.FindByName(docName);
     Assert.IsNotNull(node.Icon);
 }
        public void ShouldReturnTypeGuidForSolutionFolder()
        {
            MockVSHierarchy hierarchy = new MockVSHierarchy();
            MockVsSolution solution = new MockVsSolution(hierarchy);
            MockVSHierarchy project = new MockVSHierarchy("Project1.project");
            project.TypeGuid = VSConstants.GUID_ItemType_VirtualFolder;
            hierarchy.AddProject(project);

            HierarchyNode slnNode = new HierarchyNode(solution);
            HierarchyNode prjNode = slnNode.FindByName("Project1.project");

            Assert.AreEqual<Guid>(VSConstants.GUID_ItemType_VirtualFolder, prjNode.TypeGuid);
        }
        public void ShouldReturnTypeGuidForSolutionFile()
        {
            MockVSHierarchy root = new MockVSHierarchy();
            MockVsSolution solution = new MockVsSolution(root);
            string childName = "Child1.txt";
            root.AddChild(childName);

            HierarchyNode slnNode = new HierarchyNode(solution);
            HierarchyNode childNode = slnNode.FindByName(childName);

            Assert.AreEqual<Guid>(VSConstants.GUID_ItemType_PhysicalFile, childNode.TypeGuid);
        }
 public void RemoveItem()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     MockVSHierarchy project = new MockVSHierarchy("Project1.project");
     hierarchy.AddProject(project);
     ProjectNode projectNode = new ProjectNode(solution, project.GUID);
     string itemName = "item1";
     HierarchyNode node = projectNode.AddItem(itemName);
     Assert.IsNotNull(projectNode.FindByName(itemName));
     node.Remove();
     Assert.IsNull(projectNode.FindByName(itemName));
 }
        public void RecursiveForEachWalksAllChildrenAndParent()
        {
            int children = 3;
            MockVSHierarchy hierarchy = new MockVSHierarchy(children);
            MockVsSolution solution = new MockVsSolution(hierarchy);
            HierarchyNode node = new HierarchyNode(solution);

            int i = 0;

            node.RecursiveForEach(delegate(HierarchyNode child)
            {
                Trace.WriteLine(child.Name);
                i++;
            });

            Assert.AreEqual((children + 1), i, "Incorrect number of nodes walked");
        }
        public void RecursiveFindByNameIgnoreCase()
        {
            MockVSHierarchy hierarchy = new MockVSHierarchy();
            MockVsSolution solution = new MockVsSolution(hierarchy);
            MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
            hierarchy.AddProject(project1);
            string child1 = "Child1";
            project1.AddChild(child1);
            MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
            hierarchy.AddProject(project2);
            string child2 = "ChIlD2.cd";
            project2.AddChild(child2);
            string child3 = "ChildThree3";
            project2.AddChild(child3);
            string child4 = "Child4NotAdded";

            HierarchyNode node = new HierarchyNode(solution);
            Assert.IsNull(node.FindByName(child1));
            Assert.IsNull(node.FindByName(child2));
            Assert.IsNull(node.FindByName(child3));
            Assert.IsNull(node.FindByName(child4));
            Assert.IsNotNull(node.RecursiveFindByName(child1.ToLowerInvariant()));
            Assert.IsNotNull(node.RecursiveFindByName(child2.ToUpperInvariant()));
            Assert.IsNotNull(node.RecursiveFindByName(CodeIdentifier.MakeCamel(child3)));
            Assert.IsNull(node.RecursiveFindByName(child4));
        }
        public void ForEachWalksAllChildren()
        {
            int children = 3;
            MockVSHierarchy hierarchy = new MockVSHierarchy(children);
            MockVsSolution solution = new MockVsSolution(hierarchy);
            HierarchyNode node = new HierarchyNode(solution);
            int i = 0;

            node.ForEach(delegate(HierarchyNode child) { i++; });

            Assert.AreEqual(children, i, "Incorrect number of nodes walked");
        }
 public void TestGetObject()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode slnNode = new HierarchyNode(solution);
     Assert.AreSame(hierarchy, slnNode.GetObject<MockVSHierarchy>());
 }
 public void TestHasChildrenChanges()
 {
     MockVSHierarchy hierarchy = new MockVSHierarchy();
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode slnNode = new HierarchyNode(solution);
     Assert.IsFalse(slnNode.HasChildren);
     string docName = "Doc1.doc";
     hierarchy.AddChild(docName);
     Assert.IsTrue(slnNode.HasChildren);
 }
 public MockVsSolution(MockVSHierarchy root)
 {
     solution = this;
     this.root = root;
     this.projects = new Dictionary<Guid, MockVSHierarchy>();
 }
 public void NamePropertySetCorrectly()
 {
     string name = "MyName";
     MockVSHierarchy hierarchy = new MockVSHierarchy(name, Guid.NewGuid());
     MockVsSolution solution = new MockVsSolution(hierarchy);
     HierarchyNode node = new HierarchyNode(solution);
     Assert.AreEqual<string>(name, node.Name);
 }