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


C# Select.ShouldHaveHtmlNode方法代码示例

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


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

示例1: select_with_options_for_enum_renders_enum_values_as_options

		public void select_with_options_for_enum_renders_enum_values_as_options()
		{
			var html = new Select("foo.Bar").Options<FakeEnum>().Selected(FakeEnum.Two).ToString();

			var element = html.ShouldHaveHtmlNode("foo_Bar");
			var optionNodes = element.ShouldHaveChildNodesCount(4);
			optionNodes[0].ShouldBeUnSelectedOption((int)FakeEnum.Zero, FakeEnum.Zero);
			optionNodes[1].ShouldBeUnSelectedOption((int)FakeEnum.One, FakeEnum.One);
			optionNodes[2].ShouldBeSelectedOption((int)FakeEnum.Two, FakeEnum.Two);
			optionNodes[3].ShouldBeUnSelectedOption((int)FakeEnum.Three, FakeEnum.Three);
		}
开发者ID:haithemaraissia,项目名称:MVCContribute,代码行数:11,代码来源:SelectTests.cs

示例2: basic_select_renders_with_options_from_dictionary

		public void basic_select_renders_with_options_from_dictionary()
		{
			var options = new Dictionary<int, string> { { 1, "One" }, { 2, "Two" } };

			var html = new Select("foo.Bar").Selected(1).Options(options).ToString();

			var element = html.ShouldHaveHtmlNode("foo_Bar");

			var optionNodes = element.ShouldHaveChildNodesCount(2);

			optionNodes[0].ShouldBeSelectedOption(1, "One");
			optionNodes[1].ShouldBeUnSelectedOption(2, "Two");
		}
开发者ID:haithemaraissia,项目名称:MVCContribute,代码行数:13,代码来源:SelectTests.cs

示例3: basic_select_can_select_null_valued_options

        public void basic_select_can_select_null_valued_options()
        {
            var items = new List<FakeModel>
            {
                new FakeModel {Price = null, Title = "One"},
                new FakeModel {Price = 2, Title = "Two"}
            };
            var html = new Select("foo.Bar").Options(items, "Price", "Title").Selected(items[0].Price).ToString();

            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var optionNodes = element.ShouldHaveChildNodesCount(2);
            optionNodes[0].ShouldBeSelectedOption(items[0].Price, items[0].Title);
            optionNodes[1].ShouldBeUnSelectedOption(items[1].Price, items[1].Title);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:14,代码来源:SelectTests.cs

示例4: basic_select_renders_select_with_options_from_select_list

        public void basic_select_renders_select_with_options_from_select_list()
        {
            var items = new List<FakeModel>
            {
                new FakeModel {Id = 1, Title = "One"},
                new FakeModel {Id = 2, Title = "Two"}
            };
            var selectList = new SelectList(items, "Id", "Title", items[0].Id);

            var html = new Select("foo.Bar").Options(selectList).ToString();

            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var optionNodes = element.ShouldHaveChildNodesCount(2);
            optionNodes[0].ShouldBeSelectedOption(items[0].Id, items[0].Title);
            optionNodes[1].ShouldBeUnSelectedOption(items[1].Id, items[1].Title);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:16,代码来源:SelectTests.cs

示例5: basic_select_renders_with_options_from_dictionary

        public void basic_select_renders_with_options_from_dictionary()
        {
            var options = new Dictionary<int, string> { { 1, "One" }, { 2, "Two" } };

            var html = new Select("foo.Bar").Options(options).Selected(1).ToString();

            var element = html.ShouldHaveHtmlNode("foo_Bar");

            var optionNodes = element.ShouldHaveChildNodesCount(2);

            var option1 = optionNodes[0].ShouldBeNamed(HtmlTag.Option);
            option1.ShouldHaveAttribute(HtmlAttribute.Value).WithValue("1");
            option1.ShouldHaveAttribute(HtmlAttribute.Selected).WithValue(HtmlAttribute.Selected);
            option1.ShouldHaveInnerTextEqual(options[1]);

            var option2 = optionNodes[1].ShouldBeNamed(HtmlTag.Option);
            option2.ShouldHaveAttribute(HtmlAttribute.Value).WithValue("2");
            option2.ShouldNotHaveAttribute(HtmlAttribute.Selected);
            option2.ShouldHaveInnerTextEqual(options[2]);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:20,代码来源:SelectTests.cs

示例6: basic_select_can_group_by_overload

        public void basic_select_can_group_by_overload()
        {
            var items = new List<FakeModel>
            {
                new FakeModel {Id = 1, Title = "One", Selection = FakeEnum.One},
                new FakeModel {Id = 2, Title = "Two", Selection = FakeEnum.Zero}
            };

            var select = new Select("foo").Options(items, x => x.Id, x => x.Title, x => x.Selection).ToString();
            var optgroups = select.ShouldHaveHtmlNode("foo")
                .ShouldHaveChildNodesCount(2);

            optgroups[0].ShouldHaveAttribute("label").WithValue("One");
            optgroups[1].ShouldHaveAttribute("label").WithValue("Zero");

            optgroups[0].ShouldHaveChildNodesCount(1)[0]
                .ShouldHaveAttribute("value").WithValue("1");
            optgroups[1].ShouldHaveChildNodesCount(1)[0]
                .ShouldHaveAttribute("value").WithValue("2");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:20,代码来源:SelectTests.cs

示例7: select_with_options_for_enum_renders_null_first_option

        public void select_with_options_for_enum_renders_null_first_option()
        {
            var html = new Select("foo.Bar").Options<FakeEnum>().FirstOption("-Choose-").ToString();

            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var optionNodes = element.ShouldHaveChildNodesCount(5);
            optionNodes[0].ShouldBeUnSelectedOption(string.Empty, "-Choose-");
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:8,代码来源:SelectTests.cs

示例8: select_with_lambda_selector_for_options_should_render

        public void select_with_lambda_selector_for_options_should_render()
        {
            var items = new List<FakeModel> { new FakeModel {Price = 1, Title = "One"} };
            var html = new Select("x").Options(items, x => x.Price, x => x.Title).ToString();

            var element = html.ShouldHaveHtmlNode("x");
            var options = element.ShouldHaveChildNodesCount(1);
            options[0].ShouldBeUnSelectedOption("1", "One");
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:9,代码来源:SelectTests.cs

示例9: select_option_of_enumerable_select_list_item_renders_options

 public void select_option_of_enumerable_select_list_item_renders_options()
 {
     var items = new List<SelectListItem>
     {
         new SelectListItem {Value = "1", Text = "One", Selected = false},
         new SelectListItem {Value = "2", Text = "Two", Selected = true},
         new SelectListItem {Value = "3", Text = "Three", Selected = true}
     };
     var html = new Select("foo.Bar").Options(items).ToString();
     var element = html.ShouldHaveHtmlNode("foo_Bar");
     var optionNodes = element.ShouldHaveChildNodesCount(3);
     optionNodes[0].ShouldBeUnSelectedOption(items[0].Value, items[0].Text);
     optionNodes[1].ShouldBeSelectedOption(items[1].Value, items[1].Text);
     optionNodes[2].ShouldBeSelectedOption(items[2].Value, items[2].Text);
 }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:15,代码来源:SelectTests.cs


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