Пример #1
0
        public void TestParse()
        {
            const string markdown = "This is a text with some *emphasis*";

            var pipeline = new MarkdownPipelineBuilder()
                           .UsePreciseSourceLocation()
                           .Build();

            MarkdownDocument document = Markdown.Parse(markdown, pipeline);

            Assert.AreEqual(1, document.LineCount);
            Assert.AreEqual(markdown.Length, document.Span.Length);
            Assert.AreEqual(1, document.LineStartIndexes.Count);
            Assert.AreEqual(0, document.LineStartIndexes[0]);

            Assert.AreEqual(1, document.Count);
            ParagraphBlock paragraph = document[0] as ParagraphBlock;

            Assert.NotNull(paragraph);
            Assert.AreEqual(markdown.Length, paragraph.Span.Length);
            LiteralInline literal = paragraph.Inline.FirstChild as LiteralInline;

            Assert.NotNull(literal);
            Assert.AreEqual("This is a text with some ", literal.ToString());
            EmphasisInline emphasis = literal.NextSibling as EmphasisInline;

            Assert.NotNull(emphasis);
            Assert.AreEqual("*emphasis*".Length, emphasis.Span.Length);
            LiteralInline emphasisLiteral = emphasis.FirstChild as LiteralInline;

            Assert.NotNull(emphasisLiteral);
            Assert.AreEqual("emphasis", emphasisLiteral.ToString());
            Assert.Null(emphasisLiteral.NextSibling);
            Assert.Null(emphasis.NextSibling);
        }
Пример #2
0
        public void CreateLinkInline_CreatesLinkInline(string dummyLabel, string dummyName, string expectedContent)
        {
            // Arrange
            const string            dummyUrl                = "dummyUrl";
            var                     dummyLiteralInline      = new LiteralInline(dummyLabel);
            var                     linkReferenceDefinition = new LinkReferenceDefinition(dummyLabel, dummyUrl, dummyName); // We use the title property to hold the block's name
            FlexiFigureBlockFactory testSubject             = CreateFlexiFigureBlockFactory();

            // Act
            Inline result = testSubject.CreateLinkInline(null, linkReferenceDefinition, dummyLiteralInline);

            // Assert
            Assert.IsType <LinkInline>(result);
            Assert.Equal(dummyUrl, ((LinkInline)result).Url);
            Assert.Equal(expectedContent, dummyLiteralInline.ToString());
        }