Example #1
0
        public void TestCreatePdf()
        {
            var fileName = Path.Combine(TestHelper.TempPath, "TextPdf.pdf");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            FileAssert.DoesNotExist(fileName);

            var st = new StructuredText();

            st.AddHeader1("Überschrift 1");

            st.AddParagraph(TestHelper.Masstext1);

            var code = FileHelper.GetTextResource("code1.txt");

            st.AddCode(code);

            st.AddParagraph(TestHelper.Masstext1);

            st.AddDefinitionListLine("Left1", "Right1");
            st.AddDefinitionListLine("Left2", "Right2");
            st.AddDefinitionListLine("Left3", "Right3");
            st.AddDefinitionListLine("Left4", "Right4");

            st.AddParagraph(TestHelper.Masstext1);

            st.AddTable("Tabelle", TestHelper.GetDataTable());

            st.AddHeader1("Überschrift 2");

            st.AddDefinitionListLine("Left1", "Right1");
            st.AddDefinitionListLine("Left2", "Right2");
            st.AddDefinitionListLine("Left3", "Right3");
            st.AddDefinitionListLine("Left4", "Right4");

            var f = new PdfTextFormatter
            {
                Title          = "Testreport",
                StructuredText = st,
                DateString     = $"Date created: {DateTime.Now:G}",
                Author         = "Testautor"
            };

            f.GetFormattedText();
            f.SaveAsFile(fileName);

            FileAssert.Exists(fileName);

            TestHelper.OpenFile(fileName);
        }
Example #2
0
        public void TestGetFormattedText_NoTemplate()
        {
            var sr = new StructuredText();

            sr.AddHeader1("Überschrift 1 '& &&&' ");
            sr.AddParagraph(MassText, "CssTestFixture");
            sr.AddDefinitionListLine("Def1", "Value1");
            sr.AddDefinitionListLine("Definition 2", "Value1234");
            sr.AddDefinitionListLine("Defini 3", "Value234556666");
            sr.AddParagraph("");

            sr.AddParagraph(FormattedMasstext,
                            "CssTestFixture");

            sr.AddCode(MassText, "CssTestFixture");

            sr.AddParagraph(MassText);

            sr.AddListItem("Bahnhof");
            sr.AddListItem("HauptBahnhof");
            sr.AddListItem("SüdBahnhof");
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);

            var f = new HtmlTextFormatter {
                StructuredText = sr
            };
            var result = f.GetFormattedText();


            Debug.Print(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result));
            Assert.IsTrue(result.Contains("<h1"));
            Assert.IsTrue(result.Contains("<h2"));
        }
Example #3
0
        public void TestAppendText()
        {
            const string h1 = "T1 Überschrift 1";
            const string h2 = "Ende T2";

            var masterText = new StructuredText();

            masterText.AddHeader1(h1);
            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 2");
            masterText.AddParagraph(MassText);

            masterText.AddCode(MassText);

            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 2");
            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 1");
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 2");
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 2");
            masterText.AddParagraph(MassText);
            masterText.AddHeader1("Überschrift 1");
            masterText.AddParagraph(MassText);
            masterText.AddParagraph(MassText);


            var toAppendText = new StructuredText();

            toAppendText.AddHeader1("T2 Überschrift 1");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 2");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 2");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 1");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 2");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 2");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddHeader1("Überschrift 1");
            toAppendText.AddParagraph(MassText);
            toAppendText.AddParagraph(h2);


            var masterCount   = masterText.TextItems.Count;
            var toAppendCount = toAppendText.TextItems.Count;

            masterText.AppendText(toAppendText);

            Assert.IsTrue(masterText.TextItems.Count == masterCount + toAppendCount);
            Assert.IsTrue(masterText.TextItems[0].Content == h1);
            Assert.IsTrue(masterText.TextItems[masterText.TextItems.Count - 1].Content == h2);
        }
Example #4
0
        public void TestGetFormattedText_MoveHeaderlevel1_NoTemplateSynthaxHighLighting()
        {
            var sr = new StructuredText();

            sr.AddHeader1("Überschrift 1 '& &&&' ");

            sr.AddParagraph("??pa??Task to take a documentation for all SQL databases on a Microsoft(R) SqlServer with exception of databases Master, Msdb, Model and TempDb.??pe??");

            sr.AddCode("public void test()\r\n{{\r\nMessageBox.Show(\"Test\");\r\n}};");

            sr.AddParagraph(MassText);
            sr.AddParagraph("??pa??Test paragraph PaPe 1??pe????pa??Test paragraph PaPe 2??pe??");

            sr.AddParagraph("<para>Task to take a documentation for all SQL databases on a MSSqlServer with exception of databases Master, Msdb, Model and TempDb.</para><para>A database may contain stored procs under the schema dbo and names beginning with spDbDocu_ for adding database specific " +
                            "content to the docmentation.</para><para>For parts of the documentation the user running the job needs certain permissions." +
                            "To give least possible permissions, this user should be part of a user defined server role on the SqlServer with the permissions VIEW ANY DEFINITION and GRANT VIEW SERVER STATE." +
                            "You should avoid making the user a sysadmin for security reasons. User must have access to each database with least possible permissions!</para>");

            sr.AddDefinitionListLine("Test para", "<para>Task to take a documentation for all SQL databases on a MSSqlServer with exception of databases Master, Msdb, Model and TempDb.</para><para>A database may contain stored procs under the schema dbo and names beginning with spDbDocu_ for adding database specific " +
                                     "content to the docmentation.</para><para>For parts of the documentation the user running the job needs certain permissions." +
                                     "To give least possible permissions, this user should be part of a user defined server role on the SqlServer with the permissions VIEW ANY DEFINITION and GRANT VIEW SERVER STATE." +
                                     "You should avoid making the user a sysadmin for security reasons. User must have access to each database with least possible permissions!</para>");
            sr.AddDefinitionListLine("Def1", "Value1");
            sr.AddDefinitionListLine("Definition 2", "Value1234");
            sr.AddDefinitionListLine("Defini 3", "Value234556666");
            sr.AddParagraph("");
            sr.AddParagraph(MassText);

            sr.AddListItem("Bahnhof");
            sr.AddListItem("HauptBahnhof");
            sr.AddListItem("SüdBahnhof");
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);
            sr.AddHeader2("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);

            var f = new HtmlTextFormatter {
                StructuredText = sr, MoveHeaderLevel = 1, CssCode = "prettyprint"
            };
            var result = f.GetFormattedText();


            Debug.Print(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result));
            Assert.IsFalse(result.Contains("<h1"));
            Assert.IsTrue(result.Contains("<h2"));
            Assert.IsTrue(result.Contains("<h3"));
        }