public void SavesChangesToConfigurationObject() { DbProviderMapping sourceElement = new DbProviderMapping("name", typeof(bool)); List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1); DatabaseSettingsWmiMapper.GenerateDbProviderMappingWmiObjects(sourceElement, settings); Assert.AreEqual(1, settings.Count); ProviderMappingSetting setting = settings[0] as ProviderMappingSetting; Assert.IsNotNull(setting); setting.DatabaseType = typeof(int).AssemblyQualifiedName; setting.Commit(); Assert.AreEqual(typeof(int).AssemblyQualifiedName, sourceElement.DatabaseTypeName); }
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(); } }
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()); } }