public void CanBindObject()
        {
            string[]            attributes = new string[] { "att1", "att2" };
            CustomFilterSetting setting    = new CustomFilterSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomFilterSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("CustomFilterSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = resultEnumerator.Current as ManagementObject;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            string[]            attributes = new string[] { "att1", "att2" };
            CustomFilterSetting setting    = new CustomFilterSetting(null, "name", "FilterType", attributes);

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM CustomFilterSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("name", resultEnumerator.Current.Properties["Name"].Value);
                Assert.AreEqual("FilterType", resultEnumerator.Current.Properties["FilterType"].Value);
                ReferenceEquals(attributes, resultEnumerator.Current.Properties["Attributes"].Value);
                Assert.AreEqual("CustomFilterSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }
        public void SavesChangesToConfigurationObject()
        {
            CustomLogFilterData sourceElement = new CustomLogFilterData("name", typeof(bool));

            sourceElement.Attributes.Add("att3", "val3");
            sourceElement.Attributes.Add("att4", "val4");
            sourceElement.Attributes.Add("att5", "val5");
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

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

            Assert.IsNotNull(setting);
            setting.Attributes = new string[] { "att1=val1", "att2=val2" };
            setting.FilterType = typeof(int).AssemblyQualifiedName;
            setting.Commit();
            Assert.AreEqual(2, sourceElement.Attributes.Count);
            Assert.AreEqual("val1", sourceElement.Attributes["att1"]);
            Assert.AreEqual("val2", sourceElement.Attributes["att2"]);
            Assert.AreEqual(typeof(int), sourceElement.Type);
        }