public void NotifiesIfSavedChanges()
        {
            MockConfigurationSectionSettingB setting = CreateMockConfigurationSectionSettingB("Foo", "Bar");

            setting.Changed      += this.Changed;
            setting.SourceElement = new TestConfigurationSection();             // just so Commit works

            setting.Publish();

            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM MockConfigurationSectionSettingB")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());

                ManagementObject managementObject = (ManagementObject)resultEnumerator.Current;

                setting.performSave = false;
                Assert.IsNull(this.changedObject);
                managementObject.Put();
                Assert.IsNull(this.changedObject);                 // no change notified

                setting.performSave = true;
                Assert.IsNull(this.changedObject);
                managementObject.Put();
                Assert.IsNotNull(this.changedObject);                 // change notified
            }
        }
        public void CanPublishInstancesOfSiblingClassesWithTheSameKey()
        {
            MockConfigurationSectionSetting  setting  = CreateMockConfigurationSectionSetting("Foo", "Bar");
            MockConfigurationSectionSettingB setting2 = CreateMockConfigurationSectionSettingB("Foo", "Bar");

            setting.Publish();
            setting2.Publish();

            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM MockConfigurationSectionSetting")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("Bar", resultEnumerator.Current.Properties["SectionName"].Value);
                Assert.AreEqual("MockConfigurationSectionSetting", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }

            using (ManagementObjectCollection.ManagementObjectEnumerator resultEnumerator
                       = new ManagementObjectSearcher("root\\enterpriselibrary", "SELECT * FROM MockConfigurationSectionSettingB")
                         .Get().GetEnumerator())
            {
                Assert.IsTrue(resultEnumerator.MoveNext());
                Assert.AreEqual("Bar", resultEnumerator.Current.Properties["SectionName"].Value);
                Assert.AreEqual("MockConfigurationSectionSettingB", resultEnumerator.Current.SystemProperties["__CLASS"].Value);
                Assert.IsFalse(resultEnumerator.MoveNext());
            }
        }