Esempio n. 1
0
        public void CanParseSimpleSubstitutionFile()
        {
            JsonPlusRoot ctx = ResUtility.GetEmbed("SimpleSub.jsonp");
            var          val = ctx.GetString("root.simple-string");

            Assert.Equal("Hello world", val);
        }
Esempio n. 2
0
        public void CanParseHelloFile()
        {
            var ctx = ResUtility.GetEmbed("Hello.jsonp");
            var val = ctx.GetString("root.simple-string");

            Assert.Equal("Hello world", val);
        }
Esempio n. 3
0
        public void CanParseObjectMergeFile()
        {
            var ctx = ResUtility.GetEmbed("ObjectMerge.jsonp");

            var val1 = ctx.GetString("root.some-object.property1");
            var val2 = ctx.GetString("root.some-object.property2");
            var val3 = ctx.GetString("root.some-object.property3");

            Assert.Equal("123", val1);
            Assert.Equal("456", val2);
            Assert.Equal("789", val3);
        }
Esempio n. 4
0
        public void CanIncludeFromAssembly()
        {
            var source = @"a { include ""dll://Hello.jsonp"" }";

            Task <string> includeAssemblyCallback(string path)
            {
                if (string.IsNullOrEmpty(path))
                {
                    return(Task.FromResult("{}"));
                }

                if (path.StartsWith("dll://"))
                {
                    return(Task.FromResult(ResUtility.GetEmbedString(path.Substring("dll://".Length))));
                }

                return(Task.FromResult("{}"));
            }

            var config = JsonPlusParser.Parse(source, includeAssemblyCallback);

            Assert.Equal("Hello world", config.GetString("a.root.simple-string"));
        }