コード例 #1
0
        public void ElementWithNameAndNullValue()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", (string)null);
            AssertEx.EqualLines("<a/>", builder);
        }
コード例 #2
0
        public void ElementWithNameAndNonEmptyValue()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", "bcd");
            AssertEx.EqualLines("<a>bcd</a>", builder);
        }
コード例 #3
0
        public void ElementWithNameAndCanBeEmptyElementSetToFalse()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", false);
            AssertEx.EqualLines("<a></a>", builder);
        }
コード例 #4
0
        public void ElementWithNameAndCanBeEmptyElementSetToTrue()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", true);
            AssertEx.EqualLines("<a/>", builder);
        }
コード例 #5
0
        public void DOCTYPE()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.DOCTYPE();
            AssertEx.EqualLines("<!DOCTYPE html>", builder);
        }
コード例 #6
0
 public HTMLElement(HTMLBuilder builder, string elementName, bool canBeEmptyElement)
 {
     this.builder           = builder;
     this.elementName       = elementName;
     this.canBeEmptyElement = canBeEmptyElement;
     this.CurrentState      = State.Start;
     builder.Text($"<{elementName}");
 }
コード例 #7
0
        public void ElementWithNoAttributesAndOneChildText()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", a =>
            {
                a.Text("b");
            });
            AssertEx.EqualLines("<a>b</a>", builder);
        }
コード例 #8
0
        public void ElementWithOneAttributeAndNoChildren()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", a =>
            {
                a.Attribute("b", "c");
            });
            AssertEx.EqualLines("<a b=\"c\"/>", builder);
        }
コード例 #9
0
        public void ScriptWithTSBuilderAction()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Script(tsBuilder =>
            {
                tsBuilder.ConstQuotedStringVariable("x", "my special text");
            });
            AssertEx.EqualLines(new[]
            {
                "<script type=\"text/javascript\">",
                "  const x = \"my special text\";",
                "</script>"
            },
                                builder);
        }
コード例 #10
0
        public void ElementWithNoAttributesAndOneChildElement()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.Element("a", a =>
            {
                a.ChildElement("b");
            });
            AssertEx.EqualLines(new[]
            {
                "<a>",
                "  <b/>",
                "</a>"
            },
                                builder);
        }
コード例 #11
0
        public void DoctypeHtmlAndHeadElements()
        {
            HTMLBuilder builder = new HTMLBuilder();

            builder.DOCTYPE();
            builder.Html(html =>
            {
                html.Head();
            });
            AssertEx.EqualLines(new[]
            {
                "<!DOCTYPE html>",
                "<html lang=\"en\">",
                "  <head/>",
                "</html>"
            },
                                builder);
        }
コード例 #12
0
        public void Constructor()
        {
            HTMLBuilder builder = new HTMLBuilder();

            AssertEx.EqualLines("", builder);
        }