Beispiel #1
0
        public void CanSetStyleOnParagraph()
        {
            var doc = new Document();
            var para = doc.AddParagraph();

            var style = new StyleEx();

            style.SetIndent("p", 5);

            style.GetIndent(para).ShouldBe(5);
        }
Beispiel #2
0
        public void CanIndentOneLine()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Lorem");
            para.AddBlock("ipsum");

            para.Style.Indent = 4;

            // Set console width to 20 to force wrapping
            var lines = Render(doc, 20);

            lines[0].ShouldBe("    Lorem ipsum");
        }
Beispiel #3
0
        public void CanIndentMultipleLines()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            para.Style.Indent = 4;

            // Set console width to 20 to force wrapping
            var lines = Render(doc, 20);

            lines[0].ShouldBe("    Lorem ipsum");
            lines[1].ShouldBe("    dolor sit amet,");
            lines[2].ShouldBe("    consectetur");
                            // 12345678901234567890
        }
Beispiel #4
0
        public void CanWrapSingleBlock()
        {
            var doc = new Document();
            doc.AddParagraph().AddBlock("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
            //                           12345678901234567890
            //                                             12345678901234567890
            //                                                       12345678901234567890
            //                                                                   12345678901234567890

            // Set console width to 20 to force wrapping
            var lines = Render(doc, 20);

            lines[0].ShouldBe("Lorem ipsum dolor");
            lines[1].ShouldBe("sit amet,");
            lines[2].ShouldBe("consectetur");
            lines[3].ShouldBe("adipiscing elit.");
        }
Beispiel #5
0
        public void CanWrapMultipleBlocks()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Lorem");
            para.AddBlock("ipsum dolor");
            para.AddBlock("sit amet, consectetur adipiscing elit.");
            para.AddBlock("adipiscing elit.");

            // Set console width to 20 to force wrapping
            var lines = Render(doc, 20);

            lines[0].ShouldBe("Lorem ipsum dolor");
            lines[1].ShouldBe("sit amet,");
            lines[2].ShouldBe("consectetur");
            lines[3].ShouldBe("adipiscing elit.");
        }
Beispiel #6
0
        public void EmptyBlocksAreIgnored()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Hello");
            para.AddBlock("");
            para.AddBlock("World!");

            var lines = Render(doc);

            lines.ShouldNotBeEmpty();
            lines[0].ShouldBe("Hello World!");
        }
Beispiel #7
0
        public void TabStopInMiddleWorks()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Lorem\tipsum");

            para.Style.Tabs = new[] { 3, 15 };
            para.Style.Indent = 5;

            var lines = Render(doc);

            // TODO - indent seems inconsistent with tab stop; should indent of 5 be five spaces or start at position 5??

            lines[0].ShouldBe("     Lorem    ipsum");
            //                 12345678901234567890
        }
Beispiel #8
0
        public void TabStopAtStartWorks()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("\tLorem ipsum");

            para.Style.Tabs = new[] { 3 };

            var lines = Render(doc);

            lines[0].ShouldBe("  Lorem ipsum");
            //                 123456789012345678
        }
Beispiel #9
0
        public void OneBlock()
        {
            var doc = new Document();
            doc.AddParagraph().AddBlock("Hello");

            var lines = Render(doc);

            lines.ShouldNotBeEmpty();
            lines[0].ShouldBe("Hello");
        }
Beispiel #10
0
        public void FirstLineCanHaveNegativeIndent()
        {
            var doc = new Document();
            var para = doc.AddParagraph();
            para.AddBlock("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            para.Style.Indent = 5;
            para.Style.FirstLineIndent = -3;

            var lines = Render(doc, 20);

            lines[0].ShouldBe("  Lorem ipsum dolor");
            lines[1].ShouldBe("     sit amet,");
            lines[2].ShouldBe("     consectetur");
            //                 12345678901234567890
        }