Beispiel #1
0
        public void check_that_comment_char_is_not_stored_as_the_key()
        {
            string data = "[data]" + Environment.NewLine + "key = value;";

            IniData inidata = new StringIniParser().ParseString(data);

            Assert.That(inidata["data"]["key"], Is.EqualTo("value"));
        }
Beispiel #2
0
        public void allow_keys_with_dots()
        {
            string strTest = "[section_issue.3]\nkey.with_dots = value\n";

            IniData data = new StringIniParser().ParseString(strTest);

            Assert.That(data.Sections.Count, Is.EqualTo(1));
            Assert.That(data.Sections["section_issue.3"]["key.with_dots"], Is.Not.Null);
        }
Beispiel #3
0
        public void Issue10_Tests()
        {
            string data = @"[http://example.com/page]
            key1 = value1";

            IniData newData = new StringIniParser().ParseString(data);

            Assert.That(newData.Sections[@"http://example.com/page"]["key1"], Is.EqualTo("value1"));
        }
Beispiel #4
0
        public void test_no_exception_is_raised_when_reading_url_like_section_names()
        {
            string data =
            @"[http://example.com/page]
            key1 = value1";

            IniData newData = new StringIniParser().ParseString(data);

            Assert.That(newData.Sections[@"http://example.com/page"]["key1"], Is.EqualTo("value1"));
        }
Beispiel #5
0
        public void not_reproduced_error_tests_old()
        {
            string test = "[ExampleSection]\nkey = value;value\n";

            StringIniParser strParser = new StringIniParser();

            IniData data = strParser.ParseString(test);

            Assert.That(data.Sections.Count, Is.EqualTo(1));
            Assert.That(data.Sections["ExampleSection"], Is.Not.Null);
            Assert.That(data.Sections["ExampleSection"].Count, Is.EqualTo(1));
            Assert.That(data.Sections["ExampleSection"]["key"], Is.EqualTo("value"));
        }
        public void WritingTotring_Test()
        {
            StringIniParser parser = new StringIniParser();
            IniData data = new IniData();

            data.Sections.AddSection("newSection1");
            data.Sections["newSection1"].AddKey("newKey1", "newValue1");
            data.Sections["newSection1"].AddKey("newKey2", "newValue5");

            string result = parser.WriteString(data);

            Assert.That(result, Is.Not.Empty);
            Assert.That(result.Length, Is.Not.EqualTo(0));
        }
Beispiel #7
0
        public void Issue15_Tests()
        {
            string data = @"[123_1]
            key1=value1
            key2=value2
            [123_2]
            key3 = value3
            [123_1]
            key4=value4";
            IniData iniData = new StringIniParser().ParseString(data, true);

            Assert.That(iniData.Sections.ContainsSection("123_1"), Is.True);
            Assert.That(iniData.Sections.ContainsSection("123_2"), Is.True);
            Assert.That(iniData["123_1"]["key4"], Is.EqualTo("value4"));
        }
Beispiel #8
0
        public void check_using_another_leading_character_for_comments()
        {
            string data =
            @"[test]
            # a comment
            connectionString = Server=sqlserver.domain.com;Database=main;User ID=user;Password=password";

            StringIniParser parser = new StringIniParser();
            parser.Parser.Configuration.CommentChar = '#';
            IniData iniData = parser.ParseString(data);

            Assert.That(
                iniData["test"]["connectionString"],
                Is.EqualTo("Server=sqlserver.domain.com;Database=main;User ID=user;Password=password"));

            Assert.That(
                iniData["test"].GetKeyData("connectionString").Comments[0], Is.EqualTo(" a comment"));
        }
 public void SetUp()
 {
     sip = new StringIniParser();
 }
Beispiel #10
0
        public void Issue9_Tests()
        {
            string data = @"[test]
            connectionString = Server=sqlserver.domain.com;Database=main;User ID=user;Password=password";

            StringIniParser parser = new StringIniParser();
            parser.CommentDelimiter = '#';
            IniData iniData = parser.ParseString(data);

            Assert.That(
                iniData["test"]["connectionString"],
                Is.EqualTo("Server=sqlserver.domain.com;Database=main;User ID=user;Password=password"));
        }
Beispiel #11
0
        public void Issue6_Tests()
        {
            string data = "[data]" + Environment.NewLine +"key = value;";

            IniData inidata = new StringIniParser().ParseString(data);

            Assert.That(inidata["data"]["key"],Is.EqualTo("value") );
        }