예제 #1
0
        public void MDMerger_MergeParagraph_tryMergeParagraphsWithDiffHeader()
        {
            MDParagraph p1 = new MDParagraph(1, "Header 1");
            MDParagraph p2 = new MDParagraph(1, "Header 2");

            Assert.Catch <ArgumentException>(() => MDMerger.Merge(null, p1, p2), "Все переданные параграфы должны иметь одинаковый заголовок.");
        }
예제 #2
0
        public void MDMerger_MergeParagraph_unionParagraphText()
        {
            MDParagraph p1 = new MDParagraph(1, "Header 1");

            p1.Text.Add("Main text (first)");

            MDParagraph p2 = new MDParagraph(1, "Header 1");

            p2.Text.Add("Main text (second)");

            MDParagraph mdMerged = MDMerger.Merge(null, p1, p2);

            Assert.AreEqual(1, mdMerged.Level);
            Assert.AreEqual("Header 1", mdMerged.Header);
            CollectionAssert.AreEqual(new string[] { "Main text (first)", "", "Main text (second)" }, mdMerged.Text.ToArray());
        }
예제 #3
0
        public void MDParagraph_GetLines_retLines()
        {
            MDParagraph p = new MDParagraph(2, "Header");

            p.Text.Add("Line 1");
            p.Text.Add("Line 2");

            string[] lines = p.GetLines();

            CollectionAssert.AreEqual(new string[] {
                "## Header",
                "",
                "Line 1",
                "Line 2",
                ""
            }, lines);
        }
예제 #4
0
        public void MDMerger_MergeParagraph_unionSimilarSubParagraphs()
        {
            MDParagraph p1 = new MDParagraph(1, "Header 1");

            p1.SubParagraphs.Add(new MDParagraph(2, "Header 1.1"));

            MDParagraph p2 = new MDParagraph(1, "Header 1");

            p2.SubParagraphs.Add(new MDParagraph(2, "Header 1.1"));

            MDParagraph mdMerged = MDMerger.Merge(null, p1, p2);

            Assert.AreEqual(1, mdMerged.Level);
            Assert.AreEqual("Header 1", mdMerged.Header);
            Assert.AreEqual(1, mdMerged.SubParagraphs.Count);
            Assert.AreEqual("Header 1.1", mdMerged.SubParagraphs[0].Header);
        }
예제 #5
0
        public void MDParser_ParseParagraph_ComplexTest()
        {
            string[] text = new string[]
            {
                "# Header 1",
                "",
                "## Header 1.1",
                "",
                "Text 1.1",
                "",
                "## Header 1.2"
            };

            int iLine = 0;

            MDParagraph paragraph = MDParser.ParseParagraph(text, ref iLine, 1);

            Assert.AreEqual("Header 1", paragraph.Header);
            Assert.AreEqual(0, paragraph.Text.Count);
            Assert.AreEqual(1, paragraph.Level);
            Assert.AreEqual(2, paragraph.SubParagraphs.Count);

            MDParagraph p11 = paragraph.SubParagraphs[0];

            Assert.AreEqual("Header 1.1", p11.Header);
            Assert.AreEqual(1, p11.Text.Count);
            Assert.AreEqual("Text 1.1", p11.Text[0]);
            Assert.AreEqual(2, p11.Level);
            Assert.AreEqual(0, p11.SubParagraphs.Count);

            MDParagraph p12 = paragraph.SubParagraphs[1];

            Assert.AreEqual("Header 1.2", p12.Header);
            Assert.AreEqual(0, p12.Text.Count);
            Assert.AreEqual(2, p12.Level);
            Assert.AreEqual(0, p12.SubParagraphs.Count);
        }