Example #1
0
        public void testReadBoolean_OnOff2()
        {
            global::GitSharp.Core.Config c = parse("[s]\na = ON\nb = OFF\n");
            Assert.AreEqual("ON", c.getString("s", null, "a"));
            Assert.AreEqual("OFF", c.getString("s", null, "b"));

            Assert.IsTrue(c.getBoolean("s", "a", false));
            Assert.IsFalse(c.getBoolean("s", "b", true));
        }
Example #2
0
        public void testReadBoolean_YesNo2()
        {
            global::GitSharp.Core.Config c = parse("[s]\na = yEs\nb = NO\n");
            Assert.AreEqual("yEs", c.getString("s", null, "a"));
            Assert.AreEqual("NO", c.getString("s", null, "b"));

            Assert.IsTrue(c.getBoolean("s", "a", false));
            Assert.IsFalse(c.getBoolean("s", "b", true));
        }
Example #3
0
        public void testReadBoolean_TrueFalse2()
        {
            global::GitSharp.Core.Config c = parse("[s]\na = TrUe\nb = fAlSe\n");
            Assert.AreEqual("TrUe", c.getString("s", null, "a"));
            Assert.AreEqual("fAlSe", c.getString("s", null, "b"));

            Assert.IsTrue(c.getBoolean("s", "a", false));
            Assert.IsFalse(c.getBoolean("s", "b", true));
        }
Example #4
0
 public void test002_ReadWithSubsection()
 {
     global::GitSharp.Core.Config c = parse("[foo \"zip\"]\nbar\n[foo \"zap\"]\nbar=false\nn=3\n");
     Assert.AreEqual(true, c.getBoolean("foo", "zip", "bar", false));
     Assert.AreEqual(string.Empty, c.getString("foo", "zip", "bar"));
     Assert.AreEqual(false, c.getBoolean("foo", "zap", "bar", true));
     Assert.AreEqual("false", c.getString("foo", "zap", "bar"));
     Assert.AreEqual(3, c.getInt("foo", "zap", "n", 4));
     Assert.AreEqual(4, c.getInt("foo", "zap", "m", 4));
 }
Example #5
0
 public void testBooleanWithNoValue()
 {
     global::GitSharp.Core.Config c = parse("[my]\n\tempty\n");
     Assert.AreEqual("", c.getString("my", null, "empty"));
     Assert.AreEqual(1, c.getStringList("my", null, "empty").Length);
     Assert.AreEqual("", c.getStringList("my", null, "empty")[0]);
     Assert.IsTrue(c.getBoolean("my", "empty", false));
     Assert.AreEqual("[my]\n\tempty\n", c.toText());
 }
Example #6
0
        public void testEmptyString()
        {
            global::GitSharp.Core.Config c = parse("[my]\n\tempty =\n");
            Assert.IsNull(c.getString("my", null, "empty"));

            String[] values = c.getStringList("my", null, "empty");
            Assert.IsNotNull(values);
            Assert.AreEqual(1, values.Length);
            Assert.IsNull(values[0]);

            // always matches the default, because its non-boolean
            Assert.IsTrue(c.getBoolean("my", "empty", true));
            Assert.IsFalse(c.getBoolean("my", "empty", false));

            Assert.AreEqual("[my]\n\tempty =\n", c.toText());

            c = new global::GitSharp.Core.Config();
            c.setStringList("my", null, "empty", values.ToList());
            Assert.AreEqual("[my]\n\tempty =\n", c.toText());
        }
Example #7
0
 public void test001_ReadBareKey()
 {
     global::GitSharp.Core.Config c = parse("[foo]\nbar\n");
     Assert.AreEqual(true, c.getBoolean("foo", null, "bar", false));
     Assert.AreEqual(string.Empty, c.getString("foo", null, "bar"));
 }
Example #8
0
 public void test006_readCaseInsensitive()
 {
     global::GitSharp.Core.Config c = parse("[Foo]\nBar\n");
     Assert.AreEqual(true, c.getBoolean("foo", null, "bar", false));
     Assert.AreEqual(string.Empty, c.getString("foo", null, "bar"));
 }