public void DoNotPreserveCase() { var builder = new HTMLBuilder(); builder.AddElement("DiV", new[] { new HTMLAttribute("CLASS", "Test") }, "Content"); Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertDoNotPreserveCase), builder.ToString()); }
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()); }
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()); }
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()); }
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()); }
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); }
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); }
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); }
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); }
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); }