Ejemplo n.º 1
0
        public void EnsureDatabaseSettingsAreAddedOnNewNode()
        {
            AddLoggingDatabaseCommand cmd = new AddLoggingDatabaseCommand(ServiceProvider);

            cmd.Execute(Hierarchy.RootNode);
            Assert.IsNotNull(Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode)));
        }
        public void EnsureDatabaseSettingsAreAddedOnNewNode()
        {
            AddLoggingDatabaseCommand cmd = new AddLoggingDatabaseCommand(ServiceProvider);
            cmd.Execute(Hierarchy.RootNode);

            Assert.IsNotNull(Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode)));
        }
Ejemplo n.º 3
0
        public void OpenAndSaveConfiguration()
        {
            ApplicationNode.Hierarchy.Load();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            ApplicationNode.Hierarchy.Open();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            TraceListenerCollectionNode traceListenersNode = (TraceListenerCollectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(TraceListenerCollectionNode));
            AddLoggingDatabaseCommand   cmd = new AddLoggingDatabaseCommand(ServiceProvider);

            cmd.Execute(traceListenersNode);
            LoggingDatabaseNode          dataNode    = (LoggingDatabaseNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(LoggingDatabaseNode));
            ConnectionStringSettingsNode connectNode = (ConnectionStringSettingsNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(ConnectionStringSettingsNode));

            dataNode.DatabaseInstance = connectNode;
            Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(DatabaseSectionNode)).Count);
            Hierarchy.Save();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            Hierarchy.Load();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            Hierarchy.Open();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(LoggingDatabaseNode)).Count);
            dataNode = (LoggingDatabaseNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(LoggingDatabaseNode));
            Assert.AreEqual(dataNode.DatabaseInstance.Name, connectNode.Name);
            DatabaseSectionNode databaseSectionNode = (DatabaseSectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode));

            databaseSectionNode.Remove();
            dataNode.Remove();
            Hierarchy.Save();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
        }
        public void OpenAndSaveConfiguration()
        {
            ApplicationNode.Hierarchy.Load();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            ApplicationNode.Hierarchy.Open();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);

            TraceListenerCollectionNode traceListenersNode = (TraceListenerCollectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(TraceListenerCollectionNode));
            AddLoggingDatabaseCommand cmd = new AddLoggingDatabaseCommand(ServiceProvider);
            cmd.Execute(traceListenersNode);
            LoggingDatabaseNode dataNode = (LoggingDatabaseNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(LoggingDatabaseNode));
            ConnectionStringSettingsNode connectNode = (ConnectionStringSettingsNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(ConnectionStringSettingsNode));
            dataNode.DatabaseInstance= connectNode;

            Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(DatabaseSectionNode)).Count);

            Hierarchy.Save();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);

            Hierarchy.Load();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
            Hierarchy.Open();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);

            Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(LoggingDatabaseNode)).Count);

            dataNode = (LoggingDatabaseNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(LoggingDatabaseNode));
            Assert.AreEqual(dataNode.DatabaseInstance.Name, connectNode.Name);

            DatabaseSectionNode databaseSectionNode = (DatabaseSectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode));
            databaseSectionNode.Remove();

            dataNode.Remove();
            Hierarchy.Save();
            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);
        }