public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement() && !tag.HasAttr("name"))
     {
         tag.Attr("name", request.ElementId);
     }
 }
        public void AssertValid(HtmlTag tag, string tagName, string name, string type = "", object value = null)
        {
            Assert.Equal(tagName, tag.TagName());
            Assert.Equal(name, tag.Attr("name"));
            Assert.Equal(name, tag.Attr("id"));

            if (type == null)
                Assert.False(tag.HasAttr("type"));
            else
                Assert.Equal(type, tag.Attr("type"));

            if (value == null)
                Assert.True(!tag.HasAttr("value") || tag.Attr("value") == "");
            else
                Assert.Equal(value.ToString(), tag.Attr("value"));
        }
        public void do_not_add_element_name_to_span()
        {
            var span = new HtmlTag("span");

            ElementRequest request = For(x => x.Address.City);
            request.ElementId = "AddressCity";

            DefaultHtmlConventions.AddElementName(request, span);

            span.HasAttr("name").ShouldBeFalse();
        }
 private static void SetColspan(HtmlTag cell, ExportCell exportCell)
 {
     if (!cell.HasAttr(HtmlAttributeConstants.Colspan))
     {
         return;
     }
     int colspan;
     if(int.TryParse(cell.Attr(HtmlAttributeConstants.Colspan), out colspan))
     {
         exportCell.ColumnSpan = colspan;
     }
 }
 public void BoolAttr_Set_True_Then_False()
 {
     var tag = new HtmlTag("input").BoolAttr("disabled", true).BoolAttr("disabled", false);
     var value = tag.BoolAttr("disabled");
     Assert.False(value);
     Assert.False(tag.HasAttr("disabled"));
 }