示例#1
0
        public void CanAddAndRemoveHandlers()
        {
            SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data, false);
            object section = implementation.GetSection(externalSection);

            Assert.IsNotNull(section);

            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(2, updatedSectionsTally[externalSection]);

            implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(3, updatedSectionsTally[externalSection]);

            implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(3, updatedSectionsTally[externalSection]);
        }
示例#2
0
        public void RegisteredObjectIsNotifiedOfSectionChanges()
        {
            SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data, false);

            implementation.GetSection(externalSection);
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));

            implementation.ExternalConfigSourceChanged(externalSectionSource);

            Assert.AreEqual(1, updatedSectionsTally[externalSection]);
        }
        public void CanAddAndRemoveHandlers()
        {
            SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data,  false);
            object section = implementation.GetSection(externalSection);
            Assert.IsNotNull(section);

            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(2, updatedSectionsTally[externalSection]);

            implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(3, updatedSectionsTally[externalSection]);

            implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.ExternalConfigSourceChanged(externalSectionSource);
            Assert.AreEqual(3, updatedSectionsTally[externalSection]);
        }
        public void AllRegisteredObjectsAreNotifiedOfSectionChanges()
        {
            SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data,  false);
            implementation.GetSection(externalSection);
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));
            implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged));

            implementation.ExternalConfigSourceChanged(externalSectionSource);

            Assert.AreEqual(3, updatedSectionsTally[externalSection]);
        }