Пример #1
0
        public void TestMarkdownContentAttributeWithContentPlaceholderShouldSucceed()
        {
            var model = new MarkdownModel1
            {
                Content  = "Hello *world*, @xref, [link](link.md)",
                Content2 = "*content",
                Inner    = new MarkdownModel1
                {
                    Content  = "*content",
                    Content2 = "*content",
                    Content3 = new string[]
                    {
                        "*content"
                    },
                    Content4 = new Dictionary <string, object>
                    {
                        ["key1"] = "*content"
                    },
                    Content5 = new SortedList <string, object>
                    {
                        ["key1"] = "*content"
                    }
                }
            };

            var context = GetDefaultContext();

            context.EnableContentPlaceholder = true;
            context.PlaceholderContent       = "placeholder";
            context = Handle(model, context);

            Assert.Single(context.LinkToUids);
            Assert.Single(context.LinkToFiles);
            Assert.Single(context.FileLinkSources);
            Assert.Single(context.UidLinkSources);
            var expected = @"<p sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1"">Hello <em>world</em>, <xref href=""xref"" data-throw-if-not-resolved=""False"" data-raw-source=""@xref"" sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1""></xref>, <a href=""link.md"" data-raw-source=""[link](link.md)"" sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1"">link</a></p>
".Replace("\r\n", "\n");

            Assert.Equal(expected, model.Content);
            Assert.Equal(context.PlaceholderContent, model.Content2);
            Assert.Equal(context.PlaceholderContent, model.Inner.Content);
            Assert.Equal(context.PlaceholderContent, model.Inner.Content2);
            Assert.Equal(context.PlaceholderContent, model.Inner.Content3[0]);
            Assert.Equal(context.PlaceholderContent, model.Inner.Content4["key1"]);
            Assert.Equal(context.PlaceholderContent, model.Inner.Content5["key1"]);
        }
Пример #2
0
        public void TestSimpleModelWithMarkdownContentAttributeShouldSucceed()
        {
            var model = new MarkdownModel1
            {
                Content  = "Hello *world*, @xref, [link](link.md)",
                Content2 = "Content2",
                Content3 = new string[]
                {
                    "Content3",
                    "Content3.1"
                }
            };

            var context = Handle(model);

            Assert.Single(context.LinkToUids);
            Assert.Single(context.LinkToFiles);
            Assert.Single(context.FileLinkSources);
            Assert.Single(context.UidLinkSources);
            Assert.Equal(
                @"<p sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1"">Hello <em>world</em>, <xref href=""xref"" data-throw-if-not-resolved=""False"" data-raw-source=""@xref"" sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1""></xref>, <a href=""link.md"" data-raw-source=""[link](link.md)"" sourcefile=""test"" sourcestartlinenumber=""1"" sourceendlinenumber=""1"">link</a></p>
".Replace("\r\n", "\n"),
                model.Content);
        }