Ejemplo n.º 1
0
        public void CanSetValuesAndReloadValues()
        {
            // Arrange
            var config = new Configuration();

            config.AddIniFile(_iniConfigFilePath);
            config.AddJsonFile(_jsonConfigFilePath);
            config.AddXmlFile(_xmlConfigFilePath);

            // Act & Assert
            // Set value with Set() method
            config.Set("CommonKey1:CommonKey2:CommonKey3:CommonKey4", "NewValue");

            // All config sources must be updated
            foreach (var src in config)
            {
                Assert.Equal("NewValue",
                             (src as BaseConfigurationSource).Data["CommonKey1:CommonKey2:CommonKey3:CommonKey4"]);
            }

            // Recover values by reloading
            config.Reload();
            Assert.Equal("XmlValue6", config.Get("CommonKey1:CommonKey2:CommonKey3:CommonKey4"));

            // Set value with indexer
            config["CommonKey1:CommonKey2:CommonKey3:CommonKey4"] = "NewValue";

            // All config sources must be updated
            foreach (var src in config)
            {
                Assert.Equal("NewValue",
                             (src as BaseConfigurationSource).Data["CommonKey1:CommonKey2:CommonKey3:CommonKey4"]);
            }

            // Recover values by reloading
            config.Reload();
            Assert.Equal("XmlValue6", config["CommonKey1:CommonKey2:CommonKey3:CommonKey4"]);
        }
Ejemplo n.º 2
0
 public void Reload()
 {
     _root.Reload();
 }