public void SavesChangesToConfigurationObject()
        {
            LoggingSettings sourceElement = new LoggingSettings();

            sourceElement.DefaultCategory = "foo";
            sourceElement.LogWarningWhenNoCategoriesMatch = false;
            sourceElement.TracingEnabled      = true;
            sourceElement.RevertImpersonation = false;
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

            LoggingSettingsWmiMapper.GenerateWmiObjects(sourceElement, settings);
            Assert.AreEqual(1, settings.Count);
            LoggingBlockSetting setting = settings[0] as LoggingBlockSetting;

            Assert.IsNotNull(setting);
            setting.DefaultCategory = "foobar";
            setting.LogWarningWhenNoCategoriesMatch = true;
            setting.TracingEnabled      = false;
            setting.RevertImpersonation = true;
            setting.Commit();
            Assert.AreEqual("foobar", sourceElement.DefaultCategory);
            Assert.AreEqual(true, sourceElement.LogWarningWhenNoCategoriesMatch);
            Assert.AreEqual(false, sourceElement.TracingEnabled);
            Assert.AreEqual(true, sourceElement.RevertImpersonation);
        }
Esempio n. 2
0
        public void SavesChangesToConfigurationObject()
        {
            TraceSourceData sourceElement = new TraceSourceData();

            sourceElement.Name         = "source";
            sourceElement.DefaultLevel = SourceLevels.Error;
            sourceElement.TraceListeners.Add(new TraceListenerReferenceData("listener1"));
            sourceElement.TraceListeners.Add(new TraceListenerReferenceData("listener2"));
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

            LoggingSettingsWmiMapper.GenerateTraceSourceDataWmiObjects(sourceElement, settings, "Category");
            Assert.AreEqual(1, settings.Count);
            TraceSourceSetting setting = settings[0] as TraceSourceSetting;

            Assert.IsNotNull(setting);
            setting.DefaultLevel   = SourceLevels.All.ToString();
            setting.TraceListeners = new string[] { "listener1", "listener3", "listener4" };
            setting.Commit();
            Assert.AreEqual(SourceLevels.All, sourceElement.DefaultLevel);
            Assert.AreEqual(3, sourceElement.TraceListeners.Count);
            Assert.IsTrue(sourceElement.TraceListeners.Contains("listener1"));
            Assert.IsTrue(sourceElement.TraceListeners.Contains("listener3"));
            Assert.IsTrue(sourceElement.TraceListeners.Contains("listener4"));
        }