Example #1
0
        public void MultilineListQuotedProperty()
        {
            var md = string.Join(Environment.NewLine,
                "* Key:",
                "  + `SK1`",
                "    + <sk2>",
                "  + SK3 : v3",
                "  + SK4: `v4`",
                "  + `SK5`:`v5`",
                "  + <SK6>: `v6`",
                "  + `SK7`:<v7>",
                "  + `$abc:123$`");
            var cfg = new GroupedPropertyCollection();
            var parser = new MarkdownPropertyParser(cfg);
            using (var r = new StringReader(md)) { parser.Parse(r); }

            Assert.AreEqual(new[]
            {
                "SK1",
                "sk2",
                "SK3 : v3",
                "SK4: v4",
                "SK5:v5",
                "SK6: v6",
                "SK7:v7",
                "$abc:123$"
            }, cfg.GetValue("Key"));
        }
Example #2
0
        public void InvalidGroupedVariableReference()
        {
            var groupedProperties = new GroupedPropertyCollection(new Dictionary<string, IDictionary<string, object>>
            {
                { "A", new Dictionary<string, object> {
                    { "x", "123" },
                } },
            });
            var cfg = new ResolvingPropertyCollection();
            cfg.AddResolver(new GroupedVariableResolver(groupedProperties));

            cfg.SetValue("v1", " $A:x ");
            cfg.SetValue("v2", " A:x$ ");
            cfg.SetValue("v3", " $A :x$ ");
            cfg.SetValue("v4", " $A: x$ ");
            cfg.SetValue("v5", " $ A:x$ ");
            cfg.SetValue("v6", " $A:x $ ");
            cfg.SetValue("v7", " $A:y$ ");
            cfg.SetValue("v8", " $B:x$ ");

            Assert.AreEqual(" $A:x ", cfg.GetValue("v1"));
            Assert.AreEqual(" A:x$ ", cfg.GetValue("v2"));
            Assert.AreEqual(" #A :x# ", cfg.GetValue("v3"));
            Assert.AreEqual(" #A: x# ", cfg.GetValue("v4"));
            Assert.AreEqual(" # A:x# ", cfg.GetValue("v5"));
            Assert.AreEqual(" #A:x # ", cfg.GetValue("v6"));
            Assert.AreEqual(" #A:y# ", cfg.GetValue("v7"));
            Assert.AreEqual(" #B:x# ", cfg.GetValue("v8"));
        }
Example #3
0
        public void GroupedVariableExpansion()
        {
            var groupedProperties = new GroupedPropertyCollection(new Dictionary<string, IDictionary<string, object>>
            {
                { "A", new Dictionary<string, object> {
                    { "x", "123" },
                    { "y", "456" }
                } },
                { "B", new Dictionary<string, object>
                {
                    { "x", "UVW" }
                } },
            });
            var cfg = new ResolvingPropertyCollection();
            cfg.AddResolver(new GroupedVariableResolver(groupedProperties));

            cfg.SetValue("v1", "$A:x$");
            cfg.SetValue("v2", "pre$A:x$");
            cfg.SetValue("v3", "$A:x$post");
            cfg.SetValue("v4", "pre$A:x$post");
            cfg.SetValue("v5", "$A:x$$A:x$$A:x$");
            cfg.SetValue("v6", "$A:x$$A:y$$B:x$");

            Assert.AreEqual("123", cfg.GetValue("v1"));
            Assert.AreEqual("pre123", cfg.GetValue("v2"));
            Assert.AreEqual("123post", cfg.GetValue("v3"));
            Assert.AreEqual("pre123post", cfg.GetValue("v4"));
            Assert.AreEqual("123123123", cfg.GetValue("v5"));
            Assert.AreEqual("123456UVW", cfg.GetValue("v6"));
        }
Example #4
0
        public void SimpleProperty()
        {
            var md = "* Key: Value";
            var cfg = new GroupedPropertyCollection();
            var parser = new MarkdownPropertyParser(cfg);
            using (var r = new StringReader(md)) { parser.Parse(r); }

            Assert.AreEqual("Value", cfg.GetValue("Key"));
        }
Example #5
0
        public void OneLineListProperty()
        {
            var md = "* Key: `ABC`, `XYZ`, `123`";
            var cfg = new GroupedPropertyCollection();
            var parser = new MarkdownPropertyParser(cfg);
            using (var r = new StringReader(md)) { parser.Parse(r); }

            Assert.AreEqual(new[] { "ABC", "XYZ", "123" }, cfg.GetValue("Key"));
        }
Example #6
0
        public void QuotedProperties()
        {
            var md = "* K1: `Value`\n* K2: <Value2>";
            var cfg = new GroupedPropertyCollection();
            var parser = new MarkdownPropertyParser(cfg);
            using (var r = new StringReader(md)) { parser.Parse(r); }

            Assert.AreEqual("Value", cfg.GetValue("K1"));
            Assert.AreEqual("Value2", cfg.GetValue("K2"));
        }
Example #7
0
        public void InvalidGroupedVariableValue()
        {
            var groupedProperties = new GroupedPropertyCollection(new Dictionary<string, IDictionary<string, object>>
            {
                { "A", new Dictionary<string, object> {
                    { "x", 123 },
                    { "y", true },
                } },
            });
            var cfg = new ResolvingPropertyCollection();
            cfg.AddResolver(new GroupedVariableResolver(groupedProperties));
            cfg.SetValue("int", "$A:x$");
            cfg.SetValue("bool", "$A:y$");

            Assert.AreEqual("#A:x#", cfg.GetValue("int"));
            Assert.AreEqual("#A:y#", cfg.GetValue("bool"));
        }
Example #8
0
        public void TransitiveGroupedVariableExpansion()
        {
            var groupedProperties = new GroupedPropertyCollection(new Dictionary<string, IDictionary<string, object>>
            {
                { "A", new Dictionary<string, object> {
                    { "x1", "$A:x2$" },
                    { "x2", "123" },
                    { "y1", "$B:y2$" }
                } },
                { "B", new Dictionary<string, object>
                {
                    { "y2", "$B:y3$" },
                    { "y3", "456" },
                } },
            });
            var cfg = new ResolvingPropertyCollection();
            cfg.AddResolver(new GroupedVariableResolver(cfg));

            cfg.SetGroupValue("A", "x1", "$A:x2$");
            cfg.SetGroupValue("A", "x2", "$B:x3$");
            cfg.SetGroupValue("B", "x3", "$B:x4$");
            cfg.SetGroupValue("B", "x4", "123");

            Assert.AreEqual("123", cfg.GetGroupValue("A", "x1"));
        }