private void AssertOptionList(bool withNullValue, TestEnum?selectedValue, bool isDisabled, bool withStyle, bool autoPostBack) { var renderer = new BocEnumValueQuirksModeRenderer(_resourceUrlFactory); renderer.Render(new BocEnumValueRenderingContext(HttpContext, Html.Writer, _enumValue)); var document = Html.GetResultDocument(); var div = GetAssertedSpan(document, false, false, false, renderer); var select = Html.GetAssertedChildElement(div, "select", 0); Html.AssertAttribute(select, "id", c_valueName); Html.AssertAttribute(select, "name", c_valueName); if (withStyle) { Html.AssertStyleAttribute(select, "width", "100%"); Html.AssertStyleAttribute(select, "height", "100%"); } else { Html.AssertStyleAttribute(select, "width", "150pt"); } if (isDisabled) { Html.AssertAttribute(select, "disabled", "disabled"); } if (withNullValue) { AssertNullOption(select, !selectedValue.HasValue); } if (autoPostBack) { Html.AssertAttribute(select, "onchange", string.Format("javascript:__doPostBack('{0}','')", c_valueName)); } int index = withNullValue ? 1 : 0; foreach (TestEnum value in Enum.GetValues(typeof(TestEnum))) { AssertOption(select, value.ToString(), value.ToString(), index, selectedValue == value); ++index; } }
private void AssertLabel(TestEnum?value, bool withStyle) { var renderer = new BocEnumValueQuirksModeRenderer(_resourceUrlFactory); renderer.Render(new BocEnumValueRenderingContext(HttpContext, Html.Writer, _enumValue)); var document = Html.GetResultDocument(); XmlNode div = GetAssertedSpan(document, true, false, false, renderer); var span = Html.GetAssertedChildElement(div, "span", 0); Html.AssertAttribute(span, "id", c_valueName); if (withStyle) { Html.AssertStyleAttribute(span, "width", _width.ToString()); Html.AssertStyleAttribute(span, "height", "100%"); } Html.AssertTextNode(span, value.HasValue ? value.Value.ToString() : HtmlHelper.WhiteSpace, 0); }