Exemplo n.º 1
0
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            string[]             attributes = new string[] { "att1", "att2" };
            CustomHandlerSetting setting    = new CustomHandlerSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomHandlerSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("name", resultEnumerator.Current.Properties["Name"].Value);
                Assert.AreEqual("FilterType", resultEnumerator.Current.Properties["HandlerType"].Value);
                Assert.AreEqual("CustomHandlerSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }
Exemplo n.º 2
0
        public void CanBindObject()
        {
            string[]             attributes = new string[] { "att1", "att2" };
            CustomHandlerSetting setting    = new CustomHandlerSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Policy          = "Policy";
            setting.ExceptionType   = typeof(Exception).AssemblyQualifiedName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomHandlerSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("CustomHandlerSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = (ManagementObject)resultEnumerator.Current;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }