示例#1
0
        public void NestedKeysAreParsedCorrectly()
        {
            const string toml = "foo.bar.baz = 10\n" +
                                "foo.qux = 20\n" +
                                "[foo.bar]\n" +
                                "qux = 30";
            var parser   = new TomlynParser();
            var expected = TomlTable.Empty
                           .Add("foo", TomlTable.Empty
                                .Add("bar", TomlTable.Empty
                                     .Add("baz", new TomlInteger(10L))
                                     .Add("qux", new TomlInteger(30L)))
                                .Add("qux", new TomlInteger(20L)));

            Assert.Equal(expected, parser.Parse(toml));
        }
示例#2
0
        public void TableArraysAreParsedCorrectly()
        {
            const string toml = "[[foo.bar]]\n" +
                                "baz = 10\n" +
                                "[[foo.bar]]\n" +
                                "baz = 20";
            var parser   = new TomlynParser();
            var expected = TomlTable.Empty
                           .Add("foo", TomlTable.Empty
                                .Add("bar", TomlArray.Empty
                                     .Add(TomlTable.Empty
                                          .Add("baz", new TomlInteger(10L)))
                                     .Add(TomlTable.Empty
                                          .Add("baz", new TomlInteger(20L)))));

            Assert.Equal(expected, parser.Parse(toml));
        }
示例#3
0
        private static TomlObject Parse(string toml)
        {
            var parser = new TomlynParser();

            return(parser.Parse(toml));
        }