Exemple #1
0
        public void TestGetLinesWithNoValues()
        {
            var results = Config.FromText("[heading]\r\ntest\r\nvalue\r\nlines").GetSection("heading");

            Assert.AreEqual("test", results[0].Key);
            Assert.AreEqual("value", results[1].Key);
            Assert.AreEqual("lines", results[2].Key);
        }
Exemple #2
0
        public void TestGetConfigLineMissing()
        {
            config = Config.FromText("[Section]\r\nNo Key=bob");

            var result = config.GetValue("section", "key", "default");

            Assert.AreEqual("default", result);
        }
Exemple #3
0
        public void TestToString()
        {
            config = Config.FromText("");

            config.SetValue("section", "key", "default");

            var result = config.ToString();

            Assert.AreEqual("[section]\r\nkey=default\r\n", result);
        }
Exemple #4
0
        public void TestSetConfigLine()
        {
            config = Config.FromText("");

            config.SetValue("section", "key", "value");

            Assert.AreEqual("section", config.Lines[0].Section);
            Assert.AreEqual("key", config.Lines[0].Key);
            Assert.AreEqual("value", config.Lines[0].Value);
        }
Exemple #5
0
        public void TestToStringMultipleSections()
        {
            config = Config.FromText("");

            config.SetValue("section1", "key1", "default");
            config.SetValue("section2", "key2", "default");

            var result = config.ToString();

            Assert.AreEqual("[section1]\r\nkey1=default\r\n\r\n[section2]\r\nkey2=default\r\n", result);
        }
Exemple #6
0
        public void TestDeleteValue()
        {
            config = Config.FromText("");

            config.SetValue("section2", "key1", "default");
            config.SetValue("section2", "key2", "default");
            config.Delete("section2", "key1");

            var result = config.ToString();

            Assert.AreEqual("[section2]\r\nkey2=default\r\n", result);
        }