Example #1
0
        public void HTMLbuilder_indent()
        {
            HTML_builder builder = new HTML_builder();

            builder.indentLevelUp();
            builder.addContentWithEmptyLine("<head>");

            string HTMLcontent = builder.currentHTML();
            int    len         = HTMLcontent.Length;

            Assert.AreEqual("\n    <head>\n", HTMLcontent, "XYZ");
            Assert.AreEqual(12, len, "XYZ"); // Weaker, but the report will be
            // more clear (as it may be difficult to see with spaces).
        } //HTMLbuilder_indent()
Example #2
0
        public void HTML_builder_startHTML()
        {
            HTML_builder builder = new HTML_builder();

            builder.startHTML("Some title");

            string HTMLcontent1 = builder.currentHTML(); // Side effect!
            int    len1         = HTMLcontent1.Length;

            // Poor man's hash: check length (later, use a real
            // hashing function). At least it should catch that
            // indentation in the HTML source is not broken
            // by changes (e.g. refactoring) and unintended omissions
            // deletions.
            //
            // But it will not detect single spaces replaced by single TAB...
            //
            Assert.AreEqual(157, len1, "XYZ");
            Assert.AreEqual(HTMLcontent1.IndexOf("\t"), -1, "XYZ"); // Detect
            // any TABs...
        } //HTML_builder_appendOperations()
Example #3
0
        public void HTML_builder_appendOperations()
        {
            HTML_builder builder = new HTML_builder();

            {
                builder.addContent("<head>");

                string HTMLcontent1 = builder.currentHTML(); // Side effect!
                int    len1         = HTMLcontent1.Length;

                Assert.AreEqual("<head>", HTMLcontent1, "XYZ");
                Assert.AreEqual(6, len1, "XYZ"); // Weaker, but the report
                // will be more clear (as it may be difficult spaces).
            }

            {
                builder.addContentOnSeparateLine("<head>");

                string HTMLcontent2 = builder.currentHTML(); // Side effect!
                int    len2         = HTMLcontent2.Length;

                Assert.AreEqual("<head>\n", HTMLcontent2, "XYZ");
                Assert.AreEqual(7, len2, "XYZ"); // Weaker, but the report
                // will be more clear (as it may be difficult spaces).
            }

            {
                builder.addContentWithEmptyLine("<head>");

                string HTMLcontent3 = builder.currentHTML(); // Side effect!
                int    len3         = HTMLcontent3.Length;

                Assert.AreEqual("\n<head>\n", HTMLcontent3, "XYZ");
                Assert.AreEqual(8, len3, "XYZ"); // Weaker, but the report
                // will be more clear (as it may be difficult spaces).
            }
        } //HTML_builder_appendOperations()