public void CommitOnEmptyConfigurationThrows()
        {
            var config = new Configuration();

            var exception = Assert.Throws <InvalidOperationException>(() => config.Commit());

            Assert.Equal(0, CountAllEntries(config));
            Assert.Equal(Resources.Error_NoCommitableSource, exception.Message);
        }
        public void CommitOnConfigurationWithZeroCommitableSourceThrows()
        {
            var dict = new Dictionary <string, string>()
            {
                { "Mem:KeyInMem", "MemVal" }
            };
            var memConfigSrc = new MemoryConfigurationSource(dict);
            var config       = new Configuration();

            config.Add(memConfigSrc);

            var exception = Assert.Throws <InvalidOperationException>(() => config.Commit());

            Assert.Equal(1, CountAllEntries(config));
            Assert.Equal(Resources.Error_NoCommitableSource, exception.Message);
        }
Ejemplo n.º 3
0
        public void CanCommitChangeBackToLastConfigFile()
        {
            // Arrange
            var config = new Configuration();

            config.AddIniFile(_iniConfigFilePath);
            config.AddJsonFile(_jsonConfigFilePath);
            config.AddXmlFile(_xmlConfigFilePath);
            config.Set("CommonKey1:CommonKey2:CommonKey3:CommonKey4", "NewValue");

            // Act
            config.Commit();

            // Assert
            Assert.Equal(_iniConfigFileContent, File.ReadAllText(_iniConfigFilePath));

            Assert.Equal(_jsonConfigFileContent, File.ReadAllText(_jsonConfigFilePath));

            var updatedXmlContent = _xmlConfigFileContent.Replace("XmlValue6", "NewValue");

            Assert.Equal(updatedXmlContent, File.ReadAllText(_xmlConfigFilePath));
        }
Ejemplo n.º 4
0
 public void Commit()
 {
     _root.Commit();
 }