示例#1
0
        public void CanBindObject()
        {
            InstrumentationSetting setting = new InstrumentationSetting(null, true, false, true);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM InstrumentationSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("InstrumentationSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = (ManagementObject)resultEnumerator.Current;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }
示例#2
0
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            InstrumentationSetting setting = new InstrumentationSetting(null, true, false, true);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM InstrumentationSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual(true, resultEnumerator.Current.Properties["EventLoggingEnabled"].Value);
                Assert.AreEqual(false, resultEnumerator.Current.Properties["PerformanceCountersEnabled"].Value);
                Assert.AreEqual(true, resultEnumerator.Current.Properties["WmiEnabled"].Value);
                Assert.AreEqual("InstrumentationSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }