Beispiel #1
0
        public void DoNotPreserveCase()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("DiV", new[] { new HTMLAttribute("CLASS", "Test") }, "Content");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertDoNotPreserveCase), builder.ToString());
        }
Beispiel #2
0
        public void AddChildrenInLambda()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("div", new HTMLAttribute[] { new HTMLAttribute("class", "parent") });
            builder.Child(() =>
            {
                builder.AddElement("div", "Child Level 1");
                builder.AddAttribute("class", "child");
                builder.Child(() =>
                {
                    builder.H(2, "Child Level 2");
                });
            });
            Debug.WriteLine(builder.ToString());
        }
Beispiel #3
0
        public void PreserveCase()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("DiV", new[] { new HTMLAttribute("CLASS", "Test") }, "Content");
            builder.Settings.EnforceProperCase = false;
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualPreserveCase), builder.ToString());
        }
Beispiel #4
0
        public void CustomRootElement()
        {
            var builder = new HTMLBuilder(HTMLDocumentType.HTML5, new HTMLEmpty());

            builder.Settings.EnforceProperNesting = true;
            builder.AddElement("br", "");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertSelfClosing), builder.ToString());
        }
Beispiel #5
0
        public void NoSelfClosing()
        {
            var builder = new HTMLBuilder();

            builder.Settings.EnforceProperNesting = false;
            builder.Empty();
            builder.AddElement("script", new[] { new HTMLAttribute("src", "test.js") }, "");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertNoSelfClosing), builder.ToString());
        }
Beispiel #6
0
        public void LargeHTMLDocument()
        {
            var builder = new HTMLBuilder();

            builder.Settings.EnforceProperNesting = false;
            builder.Document().Body().P().Child().AddElement("div");
            for (int i = 1; i <= 1000; i++)
            {
                builder.AddElement("p", "List element " + i.ToString()).Child();
            }
            Assert.AreEqual(builder.ToString().Split('\n').Length, 3007);
        }
Beispiel #7
0
        public void InvalidTagForHTML401Strict()
        {
            var  builder         = new HTMLBuilder(HTMLDocumentType.HTML4_01_Strict);
            bool exceptionThrown = false;

            try
            {
                builder.AddElement("article", "Test");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Trace.WriteLine(ex.Message);
            }
            Assert.IsTrue(exceptionThrown);
        }
Beispiel #8
0
        public void ValidTagForHTML5()
        {
            var  builder         = new HTMLBuilder();
            bool exceptionThrown = false;

            try
            {
                builder.AddElement("article", "Test");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Trace.WriteLine(ex.Message);
            }
            Assert.IsFalse(exceptionThrown);
        }
Beispiel #9
0
        public void EnforceProperNesting()
        {
            var  builder         = new HTMLBuilder();
            bool exceptionThrown = false;

            try
            {
                builder.AddElement("p", "").Child().AddElement("li");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Trace.WriteLine(ex.Message);
            }

            Assert.IsTrue(exceptionThrown);
        }
Beispiel #10
0
        public void InvalidCharactersInTagName()
        {
            var  builder         = new HTMLBuilder();
            bool exceptionThrown = false;

            try
            {
                builder.Settings.EnforceDocType = false;
                builder.AddElement("m3t@", "Test");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Trace.WriteLine(ex.Message);
            }
            Assert.IsTrue(exceptionThrown);
        }