Exemplo n.º 1
0
        public void SetUp()
        {
            _htmlHelper      = new HtmlHelper();
            _httpContextStub = MockRepository.GenerateStub <HttpContextBase>();

            _control    = MockRepository.GenerateStub <IDropDownMenu>();
            _control.ID = "DropDownMenu1";
            _control.Stub(stub => stub.Enabled).Return(true);
            _control.Stub(stub => stub.UniqueID).Return("DropDownMenu1");
            _control.Stub(stub => stub.ClientID).Return("DropDownMenu1");
            _control.Stub(stub => stub.ControlType).Return("DropDownMenu");
            _control.Stub(stub => stub.MenuItems).Return(new WebMenuItemCollection(_control));
            _control.Stub(stub => stub.GetBindOpenEventScript(null, null, true)).IgnoreArguments().Return("OpenDropDownMenuEventReference");
            _control.Stub(stub => stub.ResolveClientUrl(null)).IgnoreArguments().Do((Func <string, string>)(url => url.TrimStart('~')));

            IPage pageStub = MockRepository.GenerateStub <IPage>();

            _control.Stub(stub => stub.Page).Return(pageStub);

            StateBag stateBag = new StateBag();

            _control.Stub(stub => stub.Attributes).Return(new AttributeCollection(stateBag));
            _control.Stub(stub => stub.ControlStyle).Return(new Style(stateBag));

            IClientScriptManager scriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>();

            _control.Page.Stub(stub => stub.ClientScript).Return(scriptManagerMock);

            _resourceUrlFactory = new FakeResourceUrlFactory();
        }
        private void CheckRendering(string value, string iconUrl, string description)
        {
            var resourceUrlFactory = new FakeResourceUrlFactory();

            _renderer = new BocBooleanValueRenderer(resourceUrlFactory, GlobalizationService, RenderingFeatures.Default, new BocBooleanValueResourceSetFactory(resourceUrlFactory));
            _renderer.Render(new BocBooleanValueRenderingContext(HttpContext, Html.Writer, _booleanValue));
            var document  = Html.GetResultDocument();
            var outerSpan = Html.GetAssertedChildElement(document, "span", 0);

            CheckOuterSpanAttributes(outerSpan);

            if (!_booleanValue.IsReadOnly)
            {
                CheckHiddenField(outerSpan, value);
            }
            else
            {
                CheckDataValueField(outerSpan, value);
            }
            Html.AssertChildElementCount(outerSpan, 3);

            var link = Html.GetAssertedChildElement(outerSpan, "a", 1);

            Html.AssertAttribute(link, "id", c_displayValueName);
            if (!_booleanValue.IsReadOnly)
            {
                CheckLinkAttributes(link);
            }

            var image = Html.GetAssertedChildElement(link, "img", 0);

            checkImageAttributes(image, iconUrl, description);

            var label = Html.GetAssertedChildElement(outerSpan, "span", 2);

            Html.AssertChildElementCount(label, 0);
            Html.AssertTextNode(label, description, 0);

            if (!_booleanValue.IsReadOnly)
            {
                Html.AssertAttribute(label, "onclick", _booleanValue.Enabled ? _clickScript : _dummyScript);
            }
        }
Exemplo n.º 3
0
        public void RenderDiagnosticMetadataAttributes()
        {
            _checkbox.Stub(mock => mock.IsAutoPostBackEnabled).Return(true);
            _checkbox.Value = true;

            var resourceUrlFactory = new FakeResourceUrlFactory();

            _renderer = new BocCheckBoxRenderer(
                resourceUrlFactory,
                GlobalizationService,
                RenderingFeatures.WithDiagnosticMetadata);
            _renderer.Render(new BocCheckBoxRenderingContext(HttpContext, Html.Writer, _checkbox));

            var document  = Html.GetResultDocument();
            var outerSpan = Html.GetAssertedChildElement(document, "span", 0);

            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.ControlType, "BocCheckBox");
            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.TriggersPostBack, "true");
        }
Exemplo n.º 4
0
        public void RenderDiagnosticMetadataAttributes()
        {
            _enumValue.ListControlStyle.ControlType  = ListControlType.ListBox;
            _enumValue.ListControlStyle.AutoPostBack = true;

            var resourceUrlFactory = new FakeResourceUrlFactory();
            var renderer           = new BocEnumValueRenderer(
                resourceUrlFactory,
                GlobalizationService,
                RenderingFeatures.WithDiagnosticMetadata);

            renderer.Render(new BocEnumValueRenderingContext(HttpContext, Html.Writer, _enumValue));

            var document  = Html.GetResultDocument();
            var outerSpan = Html.GetAssertedChildElement(document, "span", 0);

            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.ControlType, "BocEnumValue");
            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.TriggersPostBack, "true");
            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributesForObjectBinding.BocEnumValueStyle, "ListBox");
        }
        public void RenderDiagnosticMetadataAttributes()
        {
            _booleanValue.Stub(mock => mock.IsRequired).Return(false);
            _booleanValue.Stub(mock => mock.IsAutoPostBackEnabled).Return(true);
            _booleanValue.Value = true;

            var resourceUrlFactory = new FakeResourceUrlFactory();

            _renderer = new BocBooleanValueRenderer(
                resourceUrlFactory,
                GlobalizationService,
                RenderingFeatures.WithDiagnosticMetadata,
                new BocBooleanValueResourceSetFactory(resourceUrlFactory));
            _renderer.Render(new BocBooleanValueRenderingContext(HttpContext, Html.Writer, _booleanValue));

            var document  = Html.GetResultDocument();
            var outerSpan = Html.GetAssertedChildElement(document, "span", 0);

            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.ControlType, "BocBooleanValue");
            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributes.TriggersPostBack, "true");
            Html.AssertAttribute(outerSpan, DiagnosticMetadataAttributesForObjectBinding.BocBooleanValueIsTriState, "true");
        }