public void Select_NotNull_DefaultValue() { var model = new Model1() { PropInt = 1 }; var helper = new HtmlTagHelper(model); var name = "PropInt"; var tag = helper.Select( name, OptionsList.CreateForEnum <Enum1>(), defaultValue: 2); AssertValid(tag, "select", name); var firstChild = tag.Children.First(); var secondChild = tag.Children.Skip(1).First(); var thirdChild = tag.Children.Skip(2).First(); Assert.Equal("Option1", firstChild.Text()); Assert.True(firstChild.ValueIsEqual(1)); Assert.True(firstChild.HasAttr("selected")); Assert.Equal("Option2", secondChild.Text()); Assert.True(secondChild.ValueIsEqual(2)); Assert.False(secondChild.HasAttr("selected")); Assert.Equal("Option3", thirdChild.Text()); Assert.True(thirdChild.ValueIsEqual(3)); Assert.False(thirdChild.HasAttr("selected")); }
public void Select_NotNull_DefaultValue() { var model = new Model1() { PropInt = 1 }; var helper = new HtmlTagHelper(model); var name = "PropInt"; var tag = helper.Select( name, OptionsList.CreateForEnum<Enum1>(), defaultValue: 2); AssertValid(tag, "select", name); var firstChild = tag.Children.First(); var secondChild = tag.Children.Skip(1).First(); var thirdChild = tag.Children.Skip(2).First(); Assert.Equal("Option1", firstChild.Text()); Assert.True(firstChild.ValueIsEqual(1)); Assert.True(firstChild.HasAttr("selected")); Assert.Equal("Option2", secondChild.Text()); Assert.True(secondChild.ValueIsEqual(2)); Assert.False(secondChild.HasAttr("selected")); Assert.Equal("Option3", thirdChild.Text()); Assert.True(thirdChild.ValueIsEqual(3)); Assert.False(thirdChild.HasAttr("selected")); }