예제 #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 StrategiesPropertiesTest()
        {
            DistributionStrategyCollectionNode node = new DistributionStrategyCollectionNode();

            applicationNode.Nodes.Add(node);
            Assert.AreEqual(SR.DistributionStrategies, node.Name);
        }
예제 #3
0
        /// <summary>
        /// Adds a <see cref="DistributionStrategyCollectionNode"/>.
        /// </summary>
        protected override void AddDefaultChildNodes()
        {
            base.AddDefaultChildNodes();
            DistributionStrategyCollectionNode node = new DistributionStrategyCollectionNode(loggingSettings.DistributionStrategies);

            Nodes.AddWithDefaultChildren(node);
            this.ResolveNodeReferences();
        }
        public void StrategiesDefaultChildNodesTest()
        {
            DistributionStrategyCollectionNode node = new DistributionStrategyCollectionNode();

            applicationNode.Nodes.AddWithDefaultChildren(node);
            Assert.AreEqual(1, node.Nodes.Count);
            Assert.AreEqual(typeof(InProcDistributionStrategyNode), node.Nodes[0].GetType());
        }
예제 #5
0
        /// <summary>
        /// See <see cref="ConfigurationNode.ResolveNodeReferences"/>.
        /// </summary>
        public override void ResolveNodeReferences()
        {
            base.ResolveNodeReferences();
            DistributionStrategyCollectionNode nodes = Hierarchy.FindNodeByType(typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;

            if (nodes == null)
            {
                return;
            }
            DistributionStrategy = Hierarchy.FindNodeByName(nodes, loggingSettings.DistributionStrategy) as DistributionStrategyNode;
        }
        public void StrategiesDataTest()
        {
            string dataName = "TestName";

            DistributionStrategyDataCollection dataCollection = new DistributionStrategyDataCollection();
            DistributionStrategyData           data           = new CustomDistributionStrategyData();

            data.Name = dataName;
            dataCollection.Add(data);

            DistributionStrategyCollectionNode node = new DistributionStrategyCollectionNode(dataCollection);

            applicationNode.Nodes.Add(node);
            Assert.AreEqual(1, node.Nodes.Count);
            Assert.AreEqual(dataName, node.Nodes[0].Name);
        }
예제 #7
0
        public void RemovingDistributionStrategySavesAndReopensCorrectly()
        {
            GeneratedHierarchy.Open();
            LoggingSettingsNode node = new LoggingSettingsNode();

            GeneratedApplicationNode.Nodes.AddWithDefaultChildren(node);
            ClientSettingsNode clientSettingsNode            = GeneratedHierarchy.FindNodeByType(node, typeof(ClientSettingsNode)) as ClientSettingsNode;
            DistributionStrategyCollectionNode distributions = GeneratedHierarchy.FindNodeByType(clientSettingsNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;

            distributions.Nodes.AddWithDefaultChildren(new MsmqDistributionStrategyNode());
            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);
            distributions = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;
            Assert.IsNotNull(distributions);
            MsmqDistributionStrategyNode msmqDistributionStrategyNode = hierarchy.FindNodeByType(distributions, typeof(MsmqDistributionStrategyNode)) as MsmqDistributionStrategyNode;

            Assert.IsNotNull(msmqDistributionStrategyNode);
            // expect 3, inproc, MSMQ, and custom
            Assert.AreEqual(3, distributions.Nodes.Count);
            InProcDistributionStrategyNode inProcNode = hierarchy.FindNodeByType(distributions, typeof(InProcDistributionStrategyNode)) as InProcDistributionStrategyNode;

            Assert.IsNotNull(inProcNode);
            inProcNode.Remove();
            hierarchy.Save();


            appNode   = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            hierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration());
            HierarchyService.SelectedHierarchy = hierarchy;
            hierarchy.Open();
            settingsNode = hierarchy.FindNodeByType(typeof(LoggingSettingsNode)) as LoggingSettingsNode;
            Assert.IsNotNull(settingsNode);
            distributions = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;
            Assert.IsNotNull(distributions);
            // expect 2, inproc & custom
            Assert.AreEqual(2, distributions.Nodes.Count);
        }
예제 #8
0
        private void GetDistributionStrategies()
        {
            DistributionStrategyCollectionNode distributionStrategyCollectionNode = Hierarchy.FindNodeByType(this, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode;

            if (distributionStrategyCollectionNode == null)
            {
                return;
            }
            if (Object.ReferenceEquals(loggingSettings.DistributionStrategies, distributionStrategyCollectionNode.DistributionStrategyDataCollection))
            {
                return;
            }

            loggingSettings.DistributionStrategies.Clear();
            foreach (DistributionStrategyData strategyNode in distributionStrategyCollectionNode.DistributionStrategyDataCollection)
            {
                loggingSettings.DistributionStrategies[strategyNode.Name] = strategyNode;
            }
        }