public void SavesChangesToConfigurationObject() { DatabaseSettings sourceElement = new DatabaseSettings(); sourceElement.DefaultDatabase = "foo database"; List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1); DatabaseSettingsWmiMapper.GenerateWmiObjects(sourceElement, settings); Assert.AreEqual(1, settings.Count); DatabaseBlockSetting setting = settings[0] as DatabaseBlockSetting; Assert.IsNotNull(setting); setting.DefaultDatabase = "bar database"; setting.Commit(); Assert.AreEqual("bar database", sourceElement.DefaultDatabase); }
public void WmiQueryReturnsSingleResultIfSinglePublishedInstance() { DatabaseBlockSetting setting = new DatabaseBlockSetting(null, "defaultDataBase"); setting.ApplicationName = "app"; setting.SectionName = InstrumentationConfigurationSection.SectionName; setting.Publish(); using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM DatabaseBlockSetting") .Get().GetEnumerator()) { Assert.IsTrue(resultEnumerator.MoveNext()); Assert.AreEqual("defaultDataBase", resultEnumerator.Current.Properties["DefaultDatabase"].Value); Assert.AreEqual("DatabaseBlockSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value); Assert.IsFalse(resultEnumerator.MoveNext()); } }
public void CanBindObject() { DatabaseBlockSetting setting = new DatabaseBlockSetting(null, "defaultDataBase"); setting.ApplicationName = "app"; setting.SectionName = InstrumentationConfigurationSection.SectionName; setting.Publish(); using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM DatabaseBlockSetting") .Get().GetEnumerator()) { Assert.IsTrue(resultEnumerator.MoveNext()); Assert.AreEqual("DatabaseBlockSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value); ManagementObject managementObject = resultEnumerator.Current as ManagementObject; Assert.IsNotNull(managementObject); managementObject.Put(); } }