public static void SaveToProperties() { var dbConfig = new Configuration(); dbConfig.SetValue("first-setting", "one"); dbConfig.SetValue("second", 345.33); var stream = new MemoryStream(); dbConfig.Save(stream, new PropertiesConfigurationFormatter()); Assert.Greater(stream.Length, 0); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); var line = reader.ReadLine(); Assert.IsNotNullOrEmpty(line); Assert.IsTrue(line.StartsWith("#")); line = reader.ReadLine(); Assert.IsNotNullOrEmpty(line); Assert.IsTrue(line.StartsWith("#")); line = reader.ReadLine(); Assert.IsNotNullOrEmpty(line); Assert.AreEqual("first-setting=one", line); line = reader.ReadLine(); Assert.IsNotNullOrEmpty(line); Assert.AreEqual("second=345.33", line); }
public void SaveToFile_Properties() { var filePath = Path.Combine(Environment.CurrentDirectory, "db.config"); var config = new Configuration(); config.SetValue("system.configKey", 7679); config.SetValue("db.name", "testdb"); config.Save(filePath, new PropertiesConfigurationFormatter()); }