예제 #1
0
        public void RenamingOneDistributionStrategyLeavesOnlyOneStrategy()
        {
            string name = "Test Custom Strategy 1";

            GeneratedHierarchy.Open();
            LoggingSettingsNode node = new LoggingSettingsNode();

            GeneratedApplicationNode.Nodes.AddWithDefaultChildren(node);
            DistributionStrategyCollectionNode distributionStrategyCollectionNode = GeneratedHierarchy.FindNodeByType(typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;

            Assert.IsNotNull(distributionStrategyCollectionNode);
            distributionStrategyCollectionNode.Nodes.Clear();
            CustomDistributionStrategyNode customNode = new CustomDistributionStrategyNode();

            distributionStrategyCollectionNode.Nodes.AddWithDefaultChildren(customNode);
            customNode.TypeName = typeof(InProcDistributionStrategyData).AssemblyQualifiedName;
            customNode.Name     = name;
            GeneratedHierarchy.Save();

            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            IUIHierarchy hierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration());

            HierarchyService.SelectedHierarchy = hierarchy;
            hierarchy.Open();
            LoggingSettingsNode settingsNode = hierarchy.FindNodeByType(typeof(LoggingSettingsNode)) as LoggingSettingsNode;

            Assert.IsNotNull(settingsNode);
            distributionStrategyCollectionNode = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;
            Assert.IsNotNull(distributionStrategyCollectionNode);
            ConfigurationNode [] nodes = hierarchy.FindNodesByType(distributionStrategyCollectionNode, typeof(CustomDistributionStrategyNode));
            Assert.AreEqual(1, nodes.Length);
            Assert.AreEqual(name, nodes[0].Name);
        }
        public void CustomStrategyNodeTest()
        {
            NameValueItem item = new NameValueItem("TeST", "VALUE");
            string        name = "testName";
            string        type = "fakeType";

            CustomDistributionStrategyNode node = new CustomDistributionStrategyNode();

            applicationNode.Nodes.Add(node);
            node.Name     = name;
            node.TypeName = type;
            node.Attributes.Add(item);

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.TypeName);
            Assert.AreEqual(item, node.Attributes[0]);
        }