Пример #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 OpenAndSaveTest()
        {
            GeneratedHierarchy.Load();
            Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count);
            GeneratedHierarchy.Open();
            Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count);

            CacheManagerSettingsNode rootNode = (CacheManagerSettingsNode)GeneratedHierarchy.FindNodeByType(typeof(CacheManagerSettingsNode));

            Assert.IsNotNull(rootNode);
            Assert.AreEqual("InMemoryPersistence", rootNode.DefaultCacheManager.Name);
            rootNode.DefaultCacheManager.Name = "BadData";

            GeneratedHierarchy.Save();
            Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count);

            ApplicationData data = ApplicationData.FromCurrentAppDomain();
            ApplicationConfigurationNode applicationNode = new ApplicationConfigurationNode(data);
            IUIHierarchy newHierarchy = CreateHierarchyAndAddToHierarchyService(applicationNode, CreateDefaultConfiguration());

            HierarchyService.SelectedHierarchy = newHierarchy;
            newHierarchy.Open();
            Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count);

            rootNode = (CacheManagerSettingsNode)newHierarchy.FindNodeByType(typeof(CacheManagerSettingsNode));

            Assert.AreEqual("BadData", rootNode.DefaultCacheManager.Name);

            rootNode.DefaultCacheManager.Name = "InMemoryPersistence";

            newHierarchy.Save();
        }
Пример #3
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);
        }
Пример #4
0
        public override void SetUp()
        {
            base.SetUp();
            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());

            loggingHierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration());
            HierarchyService.SelectedHierarchy = loggingHierarchy;
            loggingHierarchy.Open();
            HierarchyService.SelectedHierarchy = GeneratedHierarchy;
        }
Пример #5
0
        public void OpenAndSaveTest()
        {
            GeneratedHierarchy.Open();
            Assert.AreEqual(0, ConfigurationErrorsCount);

            ConfigurationNode rootNode = GeneratedHierarchy.FindNodeByType(typeof(DistributorSettingsNode));

            Assert.IsNotNull(rootNode);
            Assert.AreEqual(typeof(DistributorSettingsNode), rootNode.GetType());

            GeneratedHierarchy.Save();

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

            HierarchyService.SelectedHierarchy = hierarchy;
            hierarchy.Open();
            Assert.AreEqual(0, ConfigurationErrorsCount);

            Assert.IsTrue(hierarchy.ConfigurationContext.IsValidSection(DistributorSettings.SectionName));
        }
        public void SaveDefaultAuthenticationProviderAndSaveAndReloadsCorrectly()
        {
            GeneratedHierarchy.Load();

            AddConfigurationSectionCommand cmd = new AddConfigurationSectionCommand(Host, typeof(SecuritySettingsNode), SecuritySettings.SectionName);

            cmd.Execute(GeneratedApplicationNode);

            SecuritySettingsNode securitySettingsNode = GeneratedHierarchy.FindNodeByType(typeof(SecuritySettingsNode)) as SecuritySettingsNode;

            Assert.IsNotNull(securitySettingsNode);
            AuthenticationProviderCollectionNode authenticationProviderCollectionNode = GeneratedHierarchy.FindNodeByType(securitySettingsNode, typeof(AuthenticationProviderCollectionNode)) as AuthenticationProviderCollectionNode;

            Assert.IsNotNull(authenticationProviderCollectionNode);

            AddChildNodeCommand addChildNodeCommand = new AddChildNodeCommand(Host, typeof(DbAuthenticationProviderNode));

            addChildNodeCommand.Execute(authenticationProviderCollectionNode);
            Assert.AreEqual(typeof(DbAuthenticationProviderNode), addChildNodeCommand.ChildNode.GetType());
            DbAuthenticationProviderNode dbAuthenticationProviderNode = (DbAuthenticationProviderNode)addChildNodeCommand.ChildNode;

            securitySettingsNode.DefaultAuthenticationInstance = (AuthenticationProviderNode)addChildNodeCommand.ChildNode;

            addChildNodeCommand = new AddChildNodeCommand(Host, typeof(HashAlgorithmProviderNode));
            CryptographySettingsNode cryptographySettingsNode = GeneratedHierarchy.FindNodeByType(typeof(CryptographySettingsNode)) as CryptographySettingsNode;

            Assert.IsNotNull(cryptographySettingsNode);
            HashProviderCollectionNode hashProviderCollectionNode = GeneratedHierarchy.FindNodeByType(typeof(HashProviderCollectionNode)) as HashProviderCollectionNode;

            Assert.IsNotNull(hashProviderCollectionNode);
            addChildNodeCommand.Execute(hashProviderCollectionNode);
            Assert.AreEqual(typeof(HashAlgorithmProviderNode), addChildNodeCommand.ChildNode.GetType());

            dbAuthenticationProviderNode.HashProvider = (HashProviderNode)addChildNodeCommand.ChildNode;

            DatabaseSettingsNode databaseSettingsNode = GeneratedHierarchy.FindNodeByType(typeof(DatabaseSettingsNode)) as DatabaseSettingsNode;

            Assert.IsNotNull(databaseSettingsNode);
            InstanceCollectionNode instanceCollectionNode = GeneratedHierarchy.FindNodeByType(databaseSettingsNode, typeof(InstanceCollectionNode)) as InstanceCollectionNode;

            Assert.IsNotNull(instanceCollectionNode);
            Assert.IsTrue(instanceCollectionNode.Nodes.Count > 0);
            InstanceNode instanceNode = (InstanceNode)instanceCollectionNode.Nodes[0];

            dbAuthenticationProviderNode.Database = instanceNode;

            ValidateNodeCommand validateNodeCommand = new ValidateNodeCommand(Host);

            validateNodeCommand.Execute(GeneratedApplicationNode);
            Assert.AreEqual(0, ConfigurationErrorsCount);

            SaveApplicationConfigurationNodeCommand saveCmd = new SaveApplicationConfigurationNodeCommand(Host);

            saveCmd.Execute(GeneratedApplicationNode);

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

            HierarchyService.SelectedHierarchy = hierarchy;
            hierarchy.Open();
        }
Пример #7
0
 public override void SetUp()
 {
     base.SetUp ();
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     loggingHierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration());
     HierarchyService.SelectedHierarchy = loggingHierarchy;
     loggingHierarchy.Open();
     HierarchyService.SelectedHierarchy = GeneratedHierarchy;
 }