예제 #1
0
        public void CanBindObject()
        {
            ProviderMappingSetting setting = new ProviderMappingSetting(null, "name", "DatabaseTypeName");

            setting.ApplicationName = "app";
            setting.SectionName     = InstrumentationConfigurationSection.SectionName;
            setting.Publish();
            using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM ProviderMappingSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("ProviderMappingSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                ManagementObject managementObject = resultEnumerator.Current as ManagementObject;
                Assert.IsNotNull(managementObject);
                managementObject.Put();
            }
        }
예제 #2
0
        public void WmiQueryReturnsSingleResultIfSinglePublishedInstance()
        {
            ProviderMappingSetting setting = new ProviderMappingSetting(null, "name", "DatabaseTypeName");

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