Ejemplo n.º 1
0
 protected override void InitializeCore()
 {
     requiredNode = new MyRequiredTestNode();
     ApplicationNode.AddNode(requiredNode);
     valueInfo1      = requiredNode.GetType().GetProperty("Value1");
     valueInfo2      = requiredNode.GetType().GetProperty("Value2");
     serviceProvider = ServiceBuilder.Build();
     hierarchy       = new ConfigurationUIHierarchy(ApplicationNode, serviceProvider);
 }
        public void AllTraceSourcesDefaultDataTest()
        {
            AllTraceSourceNode allTraceSourcesNode = new AllTraceSourceNode(new TraceSourceData());

            ApplicationNode.AddNode(allTraceSourcesNode);

            Assert.AreEqual("All Events", allTraceSourcesNode.Name);
            Assert.AreEqual(0, allTraceSourcesNode.Nodes.Count);
        }
        public void CategoryTraceSourceDefaultDataTest()
        {
            string name = "some name";
            NotProcessedTraceSourceNode categoryTraceSourcesNode = new NotProcessedTraceSourceNode(new TraceSourceData());

            categoryTraceSourcesNode.Name = name;
            ApplicationNode.AddNode(categoryTraceSourcesNode);
            Assert.AreEqual(name, categoryTraceSourcesNode.Name);
            Assert.AreEqual(0, categoryTraceSourcesNode.Nodes.Count);
        }
        public void LoggingSettingsNodeDefaultDataTest()
        {
            LoggingSettingsNode loggingSettings = new LoggingSettingsNode();

            ApplicationNode.AddNode(loggingSettings);
            Assert.AreEqual(false, loggingSettings.LogWarningWhenNoCategoriesMatch);
            Assert.AreEqual(false, loggingSettings.TracingEnabled);
            Assert.AreEqual("Logging Application Block", loggingSettings.Name);
            Assert.IsNull(loggingSettings.DefaultCategory);
        }
        protected void SetDictionaryConfigurationSource(DictionaryConfigurationSource configurationSource)
        {
            ConfigurationSourceSectionNode configurationSourceSection = new ConfigurationSourceSectionNode();
            DictionarySourceElementNode    configurationSourceNode    = new DictionarySourceElementNode(configurationSource);

            ApplicationNode.AddNode(configurationSourceSection);

            configurationSourceSection.AddNode(configurationSourceNode);
            configurationSourceSection.SelectedSource = configurationSourceNode;
        }
Ejemplo n.º 6
0
        public void CanInitializeTheHierarchyWhenRootIsAttachedWithChildren()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child2"));
            node.AddNode(new TestNode("Child3"));

            Assert.AreEqual(4, ((IContainer)Hierarchy).Components.Count);
        }
Ejemplo n.º 7
0
        public void CanFindNodeByPath()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TestNode("Child2"));
            ConfigurationNode foundNode = Hierarchy.FindNodeByPath(node.Path);

            Assert.AreSame(node, foundNode);
        }
Ejemplo n.º 8
0
        public void FindGrandChildNodeByType()
        {
            TempNode node = new TempNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child"));
            IList <ConfigurationNode> foundNodes = Hierarchy.FindNodesByType(typeof(TempNode));

            Assert.AreEqual(2, foundNodes.Count);
        }
Ejemplo n.º 9
0
        public void EnsureNodesAreNamesAreUniqueWhenAddedToTheContainer()
        {
            TestNode child1 = new TestNode("Child");
            TestNode child2 = new TestNode("Child");

            ApplicationNode.AddNode(child1);
            ApplicationNode.AddNode(child2);

            Assert.AreEqual("Child1", child2.Name);
        }
Ejemplo n.º 10
0
        public void SecuritySettingsNodeDefaultDataTest()
        {
            SecuritySettingsNode securitySettings = new SecuritySettingsNode();

            ApplicationNode.AddNode(securitySettings);

            Assert.IsNull(securitySettings.DefaultAuthorizationInstance);
            Assert.IsNull(securitySettings.DefaultSecurityCacheInstance);
            Assert.AreEqual("Security Application Block", securitySettings.Name);
        }
Ejemplo n.º 11
0
        public void CanDetermineIfAParentInTheHierarchyContainsANodeType()
        {
            TempNode node = new TempNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TestNode("Child2"));
            node.Nodes[0].AddNode(new TempNode("Child"));

            Assert.IsTrue(Hierarchy.ContainsNodeType(node, typeof(TempNode)));
        }
Ejemplo n.º 12
0
        public void FindNodeByTypeForParentReturnsNullIfTypeNotFound()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child2"));
            node.AddNode(new TestNode("Child3"));
            ConfigurationNode foundNode = Hierarchy.FindNodeByType(ApplicationNode, typeof(Object));

            Assert.IsNull(foundNode);
        }
Ejemplo n.º 13
0
        public void FindNodeByTypeForParentReturnsFirstNode()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child2"));
            node.AddNode(new TestNode("Child3"));
            ConfigurationNode foundNode = Hierarchy.FindNodeByType(ApplicationNode, typeof(TestNode));

            Assert.AreEqual("Child", foundNode.Name);
        }
Ejemplo n.º 14
0
        public void CanFindNodeById()
        {
            TestNode node = new TestNode("Child1");

            ApplicationNode.AddNode(node);
            node.AddNode(new TestNode("Child11"));

            ConfigurationNode foundNode = Hierarchy.FindNodeById(node.Id);

            Assert.AreSame(node, foundNode);
        }
Ejemplo n.º 15
0
        public void FindNodeByNameForAParentWithNoNameReturnsNull()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child2"));
            node.AddNode(new TestNode("Child3"));
            ConfigurationNode foundNode = Hierarchy.FindNodeByName(node, "Child4");

            Assert.IsNull(foundNode);
        }
Ejemplo n.º 16
0
        public void SerializationUtilityCanSerializeConfigurationNode()
        {
            InstrumentationNode instrumentationNode = new InstrumentationNode();

            ApplicationNode.AddNode(instrumentationNode);

            string serializedNode   = SerializationUtility.SerializeToString(instrumentationNode, instrumentationNode.Hierarchy);
            string relativeNodePath = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, instrumentationNode.Hierarchy);

            Assert.AreEqual(relativeNodePath, serializedNode);
        }
Ejemplo n.º 17
0
        public void FindNodeByNameForAParent()
        {
            TestNode node = new TestNode("Child");

            ApplicationNode.AddNode(node);
            node.AddNode(new TempNode("Child2"));
            node.AddNode(new TestNode("Child3"));
            ConfigurationNode foundNode = Hierarchy.FindNodeByName(node, "Child3");

            Assert.AreEqual("Child3", foundNode.Name);
        }
Ejemplo n.º 18
0
        private void AddConfigurationSourcesToHierarchy()
        {
            ConfigurationSourceSection section = new ConfigurationSourceSection();

            section.Sources.Add(new SystemConfigurationSourceElement("System"));
            section.Sources.Add(new FileConfigurationSourceElement("File", "app.config"));
            section.SelectedSource = "File";
            ConfigurationSourceSectionNodeBuilder builder = new ConfigurationSourceSectionNodeBuilder(ServiceProvider, section);

            ApplicationNode.AddNode(builder.Build());
        }
        public void StrangeBehaviour()
        {
            ConfigurationNode parentNode = new NodeImpl("parent");
            ConfigurationNode childNode  = new NodeImpl("child");

            parentNode.AddNode(childNode);

            ApplicationNode.AddNode(parentNode);

            Assert.AreEqual("child", childNode.Name);
            Assert.AreEqual("parent", parentNode.Name);
        }
        public void RenameNodeChangesIndex()
        {
            ConfigurationNode childNode = new NodeImpl("Test");

            ApplicationNode.AddNode(childNode);
            childNode.Name = "test3";

            ConfigurationNode childNode2 = new NodeImpl("Test2");

            ApplicationNode.AddNode(childNode2);

            childNode2.Name = ServiceHelper.GetNameCreationService(ServiceProvider).GetUniqueName("Test", childNode, childNode.Parent);
        }
Ejemplo n.º 21
0
        public void TraceListenerNameEqualsReferencedTraceListenerName()
        {
            string traceListenerName = "a traceListener";
            TraceListenerReferenceNode  traceListenerReference  = new TraceListenerReferenceNode();
            TraceListenerCollectionNode traceListenerCollection = new TraceListenerCollectionNode();
            TraceListenerNode           aTraceListener          = new WmiTraceListenerNode(new WmiTraceListenerData(traceListenerName));

            ApplicationNode.AddNode(traceListenerReference);
            ApplicationNode.AddNode(traceListenerCollection);
            traceListenerCollection.AddNode(aTraceListener);
            traceListenerReference.ReferencedTraceListener = aTraceListener;
            Assert.AreEqual(traceListenerName, traceListenerReference.Name);
        }
Ejemplo n.º 22
0
        public void FindByTypeGrandGrandChildTest()
        {
            TempNode node = new TempNode("Child");

            ApplicationNode.AddNode(node);
            TempNode deepNode = new TempNode("Child");

            node.AddNode(deepNode);
            deepNode.AddNode(new AnotherNode("Another"));
            IList <ConfigurationNode> foundNodes = Hierarchy.FindNodesByType(typeof(AnotherNode));

            Assert.AreEqual(1, foundNodes.Count);
        }
Ejemplo n.º 23
0
        public void SerializationUtilityCanDeserializeConfigurationNode()
        {
            InstrumentationNode instrumentationNode = new InstrumentationNode();

            ApplicationNode.AddNode(instrumentationNode);

            string relativePathToInstrumentationNode = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, ApplicationNode.Hierarchy);

            Assert.IsNotNull(relativePathToInstrumentationNode);

            InstrumentationNode deserializedInstance = SerializationUtility.DeserializeFromString(relativePathToInstrumentationNode, typeof(InstrumentationNode), ApplicationNode.Hierarchy) as InstrumentationNode;

            Assert.AreEqual(instrumentationNode, deserializedInstance);
        }
Ejemplo n.º 24
0
        public void WmiTraceListenerNodeDataTest()
        {
            string name = "some name";

            WmiTraceListenerData wmiTraceListenerData = new WmiTraceListenerData();

            wmiTraceListenerData.Name = name;

            WmiTraceListenerNode wmiTraceListenerNode = new WmiTraceListenerNode(wmiTraceListenerData);

            ApplicationNode.AddNode(wmiTraceListenerNode);

            Assert.AreEqual(name, wmiTraceListenerNode.Name);
        }
        public void WmiTraceListenerNodeDataTest()
        {
            string               name   = "some name";
            SourceLevels         filter = SourceLevels.Critical;
            WmiTraceListenerData wmiTraceListenerData = new WmiTraceListenerData();

            wmiTraceListenerData.Name   = name;
            wmiTraceListenerData.Filter = filter;
            WmiTraceListenerNode wmiTraceListenerNode = new WmiTraceListenerNode(wmiTraceListenerData);

            ApplicationNode.AddNode(wmiTraceListenerNode);
            Assert.AreEqual(name, wmiTraceListenerNode.Name);
            Assert.AreEqual(filter, wmiTraceListenerNode.Filter);
        }
Ejemplo n.º 26
0
        public void CacheManagerSettingsNodeTest()
        {
            CacheManagerNode defaultCacheManager = new CacheManagerNode();

            ApplicationNode.AddNode(defaultCacheManager);
            defaultCacheManager.Name = "testName";

            CacheManagerSettingsNode node = new CacheManagerSettingsNode();

            ApplicationNode.AddNode(node);
            Assert.AreEqual("Caching Application Block", node.Name);

            node.DefaultCacheManager = defaultCacheManager;
            Assert.AreEqual(defaultCacheManager, node.DefaultCacheManager);
        }
Ejemplo n.º 27
0
        public void MakeSureThatYouCanOnlyAddOneCacheManagerCollectionNode()
        {
            CacheManagerNode defaultCacheManager = new CacheManagerNode();

            ApplicationNode.AddNode(defaultCacheManager);
            defaultCacheManager.Name = "testName";

            CacheManagerSettingsNode node = new CacheManagerSettingsNode();

            ApplicationNode.AddNode(node);
            CacheManagerCollectionNode collectionNode = new CacheManagerCollectionNode();

            node.AddNode(collectionNode);
            node.AddNode(new CacheManagerCollectionNode());
        }
Ejemplo n.º 28
0
        public void FindByTypeTwoTopSearchFromOneLowerChildTest()
        {
            TempNode node = new TempNode("Child");

            ApplicationNode.AddNode(node);
            TempNode node2 = new TempNode("Child");
            TempNode node3 = new TempNode("Child");

            ApplicationNode.AddNode(node2);
            node2.AddNode(node3);
            node3.AddNode(new AnotherNode("Child"));
            node3.AddNode(new AnotherNode("Another"));
            IList <ConfigurationNode> foundNodes = Hierarchy.FindNodesByType(typeof(AnotherNode));

            Assert.AreEqual(2, foundNodes.Count);
        }
        public void SystemDiagnosticsTraceListenerNodeDataTest()
        {
            string name     = "some name";
            string initData = "some initData";
            Type   type     = typeof(ConsoleTraceListener);
            SystemDiagnosticsTraceListenerData systemDiagnosticsTraceListenerData = new SystemDiagnosticsTraceListenerData();

            systemDiagnosticsTraceListenerData.Name     = name;
            systemDiagnosticsTraceListenerData.Type     = type;
            systemDiagnosticsTraceListenerData.InitData = initData;
            SystemDiagnosticsTraceListenerNode systemDiagnosticsTraceListenerNode = new SystemDiagnosticsTraceListenerNode(systemDiagnosticsTraceListenerData);

            ApplicationNode.AddNode(systemDiagnosticsTraceListenerNode);
            Assert.AreEqual(name, systemDiagnosticsTraceListenerNode.Name);
            Assert.AreEqual(type.AssemblyQualifiedName, systemDiagnosticsTraceListenerNode.Type);
            Assert.AreEqual(initData, systemDiagnosticsTraceListenerNode.InitData);
        }
Ejemplo n.º 30
0
        public void CanFindNodeByPath2()
        {
            TestNode node = new TestNode("Child1");

            ApplicationNode.AddNode(node);
            node.AddNode(new TestNode("Child11"));

            TestNode node2 = new TestNode("Child2");

            ApplicationNode.AddNode(node2);
            TestNode node21 = new TestNode("Child21");

            node2.AddNode(node21);

            ConfigurationNode foundNode = Hierarchy.FindNodeByPath(node21.Path);

            Assert.AreSame(node21, foundNode);
        }