public void CanFindHierarchyTest()
        {
            ConfigurationDesignHost host             = new ConfigurationDesignHost();
            UIHierarchyService      hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;

            Assert.IsNotNull(hierarchyService);
            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            UIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
            ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();

            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionNode());
            hierarchyService.AddHierarchy(hierarchy);
            IUIHierarchy foundHierarchy = hierarchyService.GetHierarchy(appNode.Id);

            Assert.AreSame(hierarchy, foundHierarchy);
        }
        public void AddHierarchyAndEventFiredTest()
        {
            ConfigurationDesignHost host             = new ConfigurationDesignHost();
            UIHierarchyService      hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;

            hierarchyService.HierarchyAdded += new HierarchyAddedEventHandler(OnHierarchyAdded);
            Assert.IsNotNull(hierarchyService);
            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            IUIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));

            hierarchyService.AddHierarchy(hierarchy);
            Assert.IsTrue(addEventCalled);
            Assert.AreEqual(1, addEventCount);
            Assert.AreSame(hierarchy, eventHierarchy);
            ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();

            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionNode());
            Assert.AreEqual(1, hierarchyService.hierarchies.Count);
        }