当前位置: 首页>>代码示例>>C#>>正文


C# TextBox.ShouldHaveHtmlNode方法代码示例

本文整理汇总了C#中TextBox.ShouldHaveHtmlNode方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.ShouldHaveHtmlNode方法的具体用法?C# TextBox.ShouldHaveHtmlNode怎么用?C# TextBox.ShouldHaveHtmlNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextBox的用法示例。


在下文中一共展示了TextBox.ShouldHaveHtmlNode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: model_textbox_renders_with_id_and_name

 public void model_textbox_renders_with_id_and_name()
 {
     Expression<Func<FakeModel, object>> expression = x => x.Person.FirstName;
     var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), null).ToString();
     html.ShouldHaveHtmlNode("Person_FirstName")
         .ShouldBeNamed(HtmlTag.Input)
         .ShouldHaveAttribute(HtmlAttribute.Name).WithValue("Person.FirstName");
 }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:8,代码来源:TextboxTests.cs

示例2: basic_textbox_renders_with_id_and_name_and_value

        public void basic_textbox_renders_with_id_and_name_and_value()
        {
            var html = new TextBox("foo.Bar").ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar")
                .ShouldHaveAttributesCount(4)
                .ShouldBeNamed(HtmlTag.Input);

            element.ShouldHaveAttribute(HtmlAttribute.Type).WithValue(HtmlInputType.Text);
            element.ShouldHaveAttribute(HtmlAttribute.Name).WithValue("foo.Bar");
            element.ShouldHaveAttribute(HtmlAttribute.Value).WithValue("");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:11,代码来源:TextboxTests.cs

示例3: CustomRequiredInMetadataBehavior

        public void text_box_for_member_with_required_attribute_and_additional_css_classes_adds_metadata_to_class_using_custom_behavior()
        {
            Expression<Func<FakeModel, object>> expression = x => x.Id;
            var behaviors = new List<IBehaviorMarker> { new CustomRequiredInMetadataBehavior(0), new AppyJsonMetadataToCssBehavior(1) };

            var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).Class("MyOtherClass").ToString();

            var element = html.ShouldHaveHtmlNode("Id");
            var expectedMetadata = HttpUtility.HtmlEncode("{'required':true}");
            element.ShouldHaveAttribute(HtmlAttribute.Class).ValueShouldContain(expectedMetadata);
            element.ShouldHaveAttribute(HtmlAttribute.Class).ValueShouldContain("MyOtherClass");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:12,代码来源:TextboxTests.cs

示例4: text_box_for_member_with_required_attibute_adds_set_class_using_default_behavior

        public void text_box_for_member_with_required_attibute_adds_set_class_using_default_behavior()
        {
            Expression<Func<FakeModel, object>> expression = x => x.Id;
            var behaviors = new List<IBehaviorMarker> { new CustomRequiredHtmlBehavior() };

            var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).ToString();

            var element = html.ShouldHaveHtmlNode("Id");
            element.ShouldHaveAttribute(HtmlAttribute.Class).ValueShouldContain("req");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:10,代码来源:TextboxTests.cs

示例5: text_box_for_member_with_range_attribute_adds_min_and_max_attributes_using_custom_behavior

        public void text_box_for_member_with_range_attribute_adds_min_and_max_attributes_using_custom_behavior()
        {
            Expression<Func<FakeModel, object>> expression = x => x.Quantity;
            var behaviors = new List<IBehaviorMarker> { new CustomRangeHtmlBehavior() };

            var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).ToString();

            var element = html.ShouldHaveHtmlNode("quantity");
            element.ShouldHaveAttribute(HtmlAttribute.Min).ValueShouldContain("1");
            element.ShouldHaveAttribute(HtmlAttribute.Max).ValueShouldContain("10");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:11,代码来源:TextboxTests.cs

示例6: text_box_for_member_with_multiple_attributes_populates_metadata_in_css_class_from_custom_behaviors

 public void text_box_for_member_with_multiple_attributes_populates_metadata_in_css_class_from_custom_behaviors()
 {
     Expression<Func<FakeModel, object>> expression = x => x.MultiAttributedProperty;
     var behaviors = new List<IBehaviorMarker> { new AppyJsonMetadataToCssBehavior(1), new CustomRequiredInMetadataBehavior(0), new CustomMaxLengthInMetadataBehavior(0) };
     var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).ToString();
     var element = html.ShouldHaveHtmlNode("MultiAttributedProperty");
     var expectedMetadata = HttpUtility.HtmlEncode("{'required':true,'maximum':50,'minimum':0}");
     element.ShouldHaveAttribute(HtmlAttribute.Class).ValueShouldContain(expectedMetadata);
 }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:9,代码来源:TextboxTests.cs

示例7: text_box_for_member_with_maxlength_attibute_sets_maxlength

        public void text_box_for_member_with_maxlength_attibute_sets_maxlength()
        {
            Expression<Func<FakeModel, object>> expression = x => x.Title;
            var behaviors = new List<IBehaviorMarker> { new CustomMaxLengthBehavior() };
            var expectedLength = expression.GetMemberExpression().GetAttribute<RangeAttribute>().Maximum;

            var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).ToString();

            var element = html.ShouldHaveHtmlNode("Title");
            element.ShouldHaveAttribute(HtmlAttribute.MaxLength).WithValue(expectedLength.ToString());
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:11,代码来源:TextboxTests.cs

示例8: text_box_for_member_with_expression_attribute_adds_pattern_attribute_using_custom_behavior

        public void text_box_for_member_with_expression_attribute_adds_pattern_attribute_using_custom_behavior()
        {
            Expression<Func<FakeModel, object>> expression = x => x.Telephone;
            var behaviors = new List<IBehaviorMarker> {new CustomExpressionHtmlBehavior()};

            var html = new TextBox(expression.GetNameFor(), expression.GetMemberExpression(), behaviors).ToString();

            var element = html.ShouldHaveHtmlNode("telephone");
            element.ShouldHaveAttribute(HtmlAttribute.Pattern).ValueShouldContain(@"\(\d\d\d\) \d\d\d\-\d\d\d\d");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:10,代码来源:TextboxTests.cs

示例9: textbox_styles_renders_style

        public void textbox_styles_renders_style()
        {
            var html = new TextBox("x").Styles(color => "#000", text_align => "right").ToString();

            html.ShouldHaveHtmlNode("x")
                .ShouldHaveAttribute(HtmlAttribute.Style)
                .WithValue("color:#000;text-align:right;");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:8,代码来源:TextboxTests.cs

示例10: textbox_list_renders_list

 public void textbox_list_renders_list()
 {
     var html = new TextBox("foo").List("list1").ToString();
     html.ShouldHaveHtmlNode("foo")
         .ShouldHaveAttribute(HtmlAttribute.List).WithValue("list1");
 }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:6,代码来源:TextboxTests.cs


注:本文中的TextBox.ShouldHaveHtmlNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。