Example #1
0
        public void RemovedHandlerReceivesNoFurtherNotifications()
        {
            MockManageabilityHelper manageabilityHelper = new MockManageabilityHelper();

            instance = new ManageableConfigurationSourceImplementation(testConfigurationFile,
                                                                       manageabilityHelper,
                                                                       groupPolicyWatcher,
                                                                       watcherCoordinator,
                                                                       notificationCoordinator);

            instance.AddSectionChangeHandler(localSection1, OnConfigurationSectionChange);
            instance.AddSectionChangeHandler(externalSection1, OnConfigurationSectionChange);

            instance.GetSection(localSection1);
            instance.GetSection(externalSection1);
            watcherCoordinator.OnConfigurationChanged(null,
                                                      new ConfigurationChangedEventArgs(ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource));

            Assert.AreEqual(2, valuesForNotifiedSections.Count);
            Assert.AreEqual("value1", valuesForNotifiedSections[localSection1]);
            Assert.AreEqual("value1", valuesForNotifiedSections[externalSection1]);

            instance.RemoveSectionChangeHandler(localSection1, OnConfigurationSectionChange);
            valuesForNotifiedSections.Clear();

            watcherCoordinator.OnConfigurationChanged(null,
                                                      new ConfigurationChangedEventArgs(ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource));

            Assert.AreEqual(1, valuesForNotifiedSections.Count);
            Assert.AreEqual("value1", valuesForNotifiedSections[externalSection1]);
        }
        public void RemovedHandlerReceivesNoFurtherNotifications()
        {
            MockManageabilityHelper manageabilityHelper = new MockManageabilityHelper();

            instance = new ManageableConfigurationSourceImplementation(testConfigurationFile,
                                                                       manageabilityHelper,
                                                                       groupPolicyWatcher,
                                                                       watcherCoordinator,
                                                                       notificationCoordinator);

            instance.AddSectionChangeHandler(localSection1, OnConfigurationSectionChange);
            instance.AddSectionChangeHandler(externalSection1, OnConfigurationSectionChange);

            instance.GetSection(localSection1);
            instance.GetSection(externalSection1);
            watcherCoordinator.OnConfigurationChanged(null,
                                                      new ConfigurationChangedEventArgs(ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource));

            Assert.AreEqual(2, valuesForNotifiedSections.Count);
            Assert.AreEqual("value1", valuesForNotifiedSections[localSection1]);
            Assert.AreEqual("value1", valuesForNotifiedSections[externalSection1]);

            instance.RemoveSectionChangeHandler(localSection1, OnConfigurationSectionChange);
            valuesForNotifiedSections.Clear();

            watcherCoordinator.OnConfigurationChanged(null,
                                                      new ConfigurationChangedEventArgs(ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource));

            Assert.AreEqual(1, valuesForNotifiedSections.Count);
            Assert.AreEqual("value1", valuesForNotifiedSections[externalSection1]);
        }