Exemplo n.º 1
0
        public void CanBindObject()
        {
            string[]           traceListeners = new string[] { "tl1", "tl2" };
            TraceSourceSetting setting        = new TraceSourceSetting(null, "name", "DefaultLevel", traceListeners, "Kind");

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM TraceSourceSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("TraceSourceSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = resultEnumerator.Current as ManagementObject;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }
Exemplo n.º 2
0
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            string[]           traceListeners = new string[] { "tl1", "tl2" };
            TraceSourceSetting setting        = new TraceSourceSetting(null, "name", "DefaultLevel", traceListeners, "Kind");

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM TraceSourceSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("name", resultEnumerator.Current.Properties["Name"].Value);
                Assert.AreEqual("DefaultLevel", resultEnumerator.Current.Properties["DefaultLevel"].Value);
                Assert.ReferenceEquals(traceListeners, resultEnumerator.Current.Properties["TraceListeners"].Value);
                Assert.AreEqual("Kind", resultEnumerator.Current.Properties["Kind"].Value);
                Assert.AreEqual("TraceSourceSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }