public void Use_the_given_generator_when_returning_html_string()
        {
            var h = new LazyHtmlAttributes(_ => new HtmlString("asdf"));
            h.AddClass("lol");

            Assert.That(h.ToHtmlString(), Is.EqualTo("asdf"));
        }
Пример #2
0
        public void Use_the_given_generator_when_returning_html_string()
        {
            var h = new LazyHtmlAttributes(_ => new HtmlString("asdf"));

            h.AddClass("lol");

            Assert.That(h.ToHtmlString(), Is.EqualTo("asdf"));
        }
        public void Lazily_evaluate_the_html_generator()
        {
            var t = new TagBuilder("p");
            var h = new LazyHtmlAttributes(hh => { t.MergeAttributes(hh.Attributes); return new HtmlString(t.ToString(TagRenderMode.Normal));});
            h.AddClass("lol");
            t.InnerHtml = "hi";

            Assert.That(h.ToHtmlString(), Is.EqualTo("<p class=\"lol\">hi</p>"));
        }
Пример #4
0
        public void Lazily_evaluate_the_html_generator()
        {
            var t = new TagBuilder("p");
            var h = new LazyHtmlAttributes(hh => { t.MergeAttributes(hh.Attributes); return(new HtmlString(t.ToString(TagRenderMode.Normal))); });

            h.AddClass("lol");
            t.InnerHtml = "hi";

            Assert.That(h.ToHtmlString(), Is.EqualTo("<p class=\"lol\">hi</p>"));
        }