Example #1
0
        public void TestAppendUtf8PlainTextFile_Html()
        {
            var fileName = Path.Combine(FileHelper.GetAppPath(), "Resources\\HelpFile.txt");

            var sr = new StructuredText();

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

            sr.AppendUtf8PlainTextFile(fileName);


            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);

            var f = new HtmlTextFormatter
            {
                StructuredText    = sr,
                Template          = "<<<Start>>>{0}<<<Ende>>>",
                AddTableOfContent = true
            };
            var result = f.GetFormattedText();

            Debug.Print(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result));
        }
Example #2
0
        public void TestAppendUtf8PlainTextFile_Text()
        {
            var fileName = Path.Combine(FileHelper.GetAppPath(), "Resources\\HelpFile.txt");

            var sr = new StructuredText();

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

            sr.AppendUtf8PlainTextFile(fileName);

            sr.AddHeader1("Überschrift 1");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);

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

            Debug.Print(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result));
        }
Example #3
0
        public void TestGetFormattedText_WithTable()
        {
            var sr = new StructuredText();

            sr.AddHeader1("Überschrift 1");

            sr.AddTable("Tabellentitel", DataHelper.GetData());

            sr.AddHeader1("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);



            sr.AddParagraph(MassText);
            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.AddHeader1("Überschrift 2");
            sr.AddParagraph(MassText);
            sr.AddParagraph(MassText);

            sr.AddTable("Tabellentitel", DataHelper.GetData());

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

            var f = new PlainTextFormatter
            {
                StructuredText = sr,
                Template       = "<<<Start>>>{0}<<<Ende>>>"
            };
            var result = f.GetFormattedText();

            Debug.Print(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result));
        }
Example #4
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 #5
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 #6
0
        public void TestGetFormattedText_MoveHeaderlevel1_NoTemplate()
        {
            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.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
            };
            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"));
        }