public void Size() { var model = new ExamplePostModel(); var tag = model.Helper().Select(f => f.String, new Option[0]).Size(3).RenderTag(); tag.Attr("size").Should().Be("3"); }
public void AutoComplete_Off() { var model = new ExamplePostModel(); var tag = model.Helper().InputText(f => f.String).AutoCompleteOff().RenderTag(); tag.Attr("autocomplete").Should().Be("off"); }
public void Form_AutoCompleteDefault() { var model = new ExamplePostModel(); var tag = model.Helper().InputText(f => f.String).RenderTag(); tag.ToString().Should().NotContain("autocomplete"); }
public void NullValue() { var model = new ExamplePostModel(); var tag = model.Helper().InputText(f => f.String).RenderTag(); tag.Value().Should().Be(""); }
public void MutateControl() { var model = new ExamplePostModel(); var group = model.Helper().FormGroup("test label", fg => fg.InputText(f => f.String)).Control(tb => tb.Value("override")); var tag = Render(group); tag.Control.Value().Should().Be("override"); }
public void Form_AutoCompleteDefault() { var model = new ExamplePostModel { String = "existing value" }; var tag = model.Helper().Form().RenderTag(); tag.ToString().Should().NotContain("autocomplete"); }
public void NullableEnum() { var model = new ExamplePostModel { NullableEnum = ExamplePostModel.Values.Key2 }; var tag = model.Helper().Select(f => f.NullableEnum, _enumValues).RenderTag(); var options = tag.Children; options.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, true, false); }
public void InputNumber_String() { var model = new ExamplePostModel { String = "123" }; var tag = model.Helper().InputNumber(f => f.String).RenderTag(); tag.Attr("type").Should().Be("number"); tag.Attr("name").Should().Be("String"); tag.Attr("value").Should().Be("123"); }
public void Int() { var model = new ExamplePostModel { Int = 2 }; var tag = model.Helper().Select(f => f.Int, _intValues).RenderTag(); var options = tag.Children; options.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, true, false); }
public void Typed() { var model = new ExamplePostModel { String = "Key2" }; var tag = model.Helper().Select(f => f.String, _stringValues).RenderTag(); var optionTags = tag.Children; optionTags.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, true, false); }
public void AutoComplete_Off() { var model = new ExamplePostModel { String = "existing value" }; var tag = model.Helper().Form() .AutoCompleteOff() .RenderTag(); tag.Attr("autocomplete").Should().Be("off"); }
public void String_NullValue() { var model = new ExamplePostModel { String = null }; var tag = model.Helper().Select(f => f.String, _stringValues).Optional("<please select>").RenderTag(); var options = tag.Children; options.Select(o => o.HasAttr("selected")).Count(s => s == true).Should().Be(0, "nothin should be selected"); }
public void NullableBool() { var model = new ExamplePostModel { NullableBool = true }; var tag = model.Helper().Select(f => f.NullableBool, _boolValues).RenderTag(); var options = tag.Children; options.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, true); }
public void InputNumber_NullableInt() { var model = new ExamplePostModel { NullableInt = 123 }; var tag = model.Helper().InputNumber(f => f.NullableInt).RenderTag(); tag.Attr("type").Should().Be("number"); tag.Attr("name").Should().Be("NullableInt"); tag.Attr("value").Should().Be("123"); }
public void InputHidden_Long() { var model = new ExamplePostModel { Long = 123 }; var tag = model.Helper().InputHidden(f => f.Long).RenderTag(); tag.TagName().Should().Be("input"); tag.Attr("type").Should().Be("hidden"); tag.Attr("name").Should().Be("Long"); tag.Attr("value").Should().Be("123"); }
public void InputText() { var model = new ExamplePostModel { String = "existing value" }; var tag = model.Helper().InputText(f => f.String).RenderTag(); tag.Attr("type").Should().Be("text"); tag.Attr("name").Should().Be("String"); tag.Attr("id").Should().Be("String"); tag.Attr("value").Should().Be("existing value"); }
public void Multiple() { var model = new ExamplePostModel { Strings = new[] { "Key2", "Key3" } }; var tag = model.Helper().Select(f => f.Strings, _stringValues).RenderTag(); tag.Attr("multiple").Should().Be("true"); var options = tag.Children; options.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, true, true); }
public void Typed_Optional() { var model = new ExamplePostModel { NullableEnum = ExamplePostModel.Values.Key2 }; var options = new Dictionary <ExamplePostModel.Values, string> { { ExamplePostModel.Values.Key1, "Value 1" }, { ExamplePostModel.Values.Key2, "Value 2" }, { ExamplePostModel.Values.Key3, "Value 3" }, }; var tag = model.Helper().Select(f => f.NullableEnum, options).Optional("<please select>").RenderTag(); var optionTags = tag.Children; optionTags.Select(o => o.Text()).Should().BeEquivalentTo("<please select>", "Value 1", "Value 2", "Value 3"); optionTags.Select(o => o.HasAttr("selected")).Should().BeEquivalentTo(false, false, true, false); }
public void String() { var model = new ExamplePostModel { String = "Key2" }; var tag = model.Helper().Select(f => f.String, _stringValues).Optional("<please select>").RenderTag(); tag.TagName().Should().Be("select"); tag.Attr("name").Should().Be("String"); tag.Attr("id").Should().Be("String"); var options = tag.Children; options.Select(o => o.HasAttr("value")).Should().AllBeEquivalentTo(true, "all key values should be set"); options.Select(o => o.Attr("value")).Should().BeEquivalentTo("", "Key1", "Key2", "Key3"); options.Select(o => o.Text()).Should().BeEquivalentTo("<please select>", "Value 1", "Value 2", "Value 3"); options.Select(o => o.HasAttr("selected")).Count(s => s == true).Should().Be(1, "current value should be selected"); options.Select(o => o.Attr("selected")).Should().BeEquivalentTo("", "", "selected", ""); }
public void OptGroups() { var model = new ExamplePostModel { String = "Key3" }; var values = new List <Option> { Option.Value(null, "<please select>"), Option.Group("Primary", new [] { Option.Value("Key1", "value 1"), Option.Value("Key2", "value 2"), }), Option.Group("Secondary", new [] { Option.Value("Key3", "value 3"), Option.Value("Key4", "value 4"), }), }; var tag = model.Helper().Select(f => f.String, values).RenderTag(); var options = tag.Children; options.Select(o => o.TagName()).Should().BeEquivalentTo("option", "optgroup", "optgroup"); { var primayGroup = options[1]; primayGroup.Attr("label").Should().Be("Primary"); primayGroup.Children.Select(t => t.Attr("value")).Should().BeEquivalentTo("Key1", "Key2"); } { var secondaryGroup = options[2]; secondaryGroup.Attr("label").Should().Be("Secondary"); secondaryGroup.Children.Select(t => t.Attr("value")).Should().BeEquivalentTo("Key3", "Key4"); } }