private void AssertDocument(bool isReadOnly, bool isDisabled, bool withStyle) { var siteStub = MockRepository.GenerateStub <ISite> (); siteStub.Stub(stub => stub.DesignMode).Return(true); _dateTimeValue.Site = siteStub; IClientScriptBehavior clientScriptBehaviorStub = MockRepository.GenerateStub <IClientScriptBehavior>(); clientScriptBehaviorStub.Stub(stub => stub.IsBrowserCapableOfScripting(HttpContext, _dateTimeValue)).Return(true); _renderer = new BocDateTimeValueQuirksModeRenderer(clientScriptBehaviorStub, _resourceUrlFactory); _renderer.Render(new BocDateTimeValueRenderingContext(HttpContext, Html.Writer, _dateTimeValue)); var document = Html.GetResultDocument(); var div = GetAssertedDiv(document, isReadOnly, isDisabled, withStyle); if (isReadOnly) { AssertSpan(div); } else { AssertTable(div, isDisabled, withStyle); } }
public void RenderIDs() { _dateTimeValue.Stub(stub => stub.ActualValueType).Return(BocDateTimeValueType.DateTime); _dateTimeValue.Stub(stub => stub.Enabled).Return(true); IClientScriptBehavior clientScriptBehaviorStub = MockRepository.GenerateStub <IClientScriptBehavior> (); clientScriptBehaviorStub.Stub(stub => stub.IsBrowserCapableOfScripting(HttpContext, _dateTimeValue)).Return(true); var renderer = new BocDateTimeValueQuirksModeRenderer(clientScriptBehaviorStub, new FakeResourceUrlFactory()); renderer.Render(new BocDateTimeValueRenderingContext(HttpContext, Html.Writer, _dateTimeValue)); var document = Html.GetResultDocument(); var tableRow = document.GetAssertedChildElement("div", 0).GetAssertedChildElement("table", 0).GetAssertedChildElement("tr", 0); var dateInput = tableRow.GetAssertedChildElement("td", 0).GetAssertedChildElement("input", 0); var timeInput = tableRow.GetAssertedChildElement("td", 2).GetAssertedChildElement("input", 0); dateInput.AssertAttributeValueEquals("id", c_dateValueName); dateInput.AssertAttributeValueEquals("name", c_dateValueName); timeInput.AssertAttributeValueEquals("id", c_timeValueName); timeInput.AssertAttributeValueEquals("name", c_timeValueName); }