public void TestDiagnosticMetadataRendering()
        {
            PopulateTabStrip();
            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new[]
            {
                new WebTabRendererAdapter(CreateWebTabRenderer(RenderingFeatures.WithDiagnosticMetadata), _tab0, true, true, _style),
            });

            _renderer = new WebTabStripRenderer(new FakeResourceUrlFactory(), GlobalizationService, RenderingFeatures.WithDiagnosticMetadata);
            _renderer.Render(renderingContext);

            var document = _htmlHelper.GetResultDocument();
            var outerDiv = document.GetAssertedChildElement("div", 0);
            var innerDiv = outerDiv.GetAssertedChildElement("div", 0);

            outerDiv.AssertAttributeValueEquals(DiagnosticMetadataAttributes.ControlType, _webTabStrip.ControlType);
            var list    = innerDiv.GetAssertedChildElement("ul", 0);
            var item    = list.GetAssertedChildElement("li", 0);
            var wrapper = item.GetAssertedChildElement("span", 0);
            var tab     = wrapper.GetAssertedChildElement("span", 1);

            tab.AssertAttributeValueEquals(DiagnosticMetadataAttributes.ItemID, _tab0.ItemID);
            tab.AssertAttributeValueEquals(DiagnosticMetadataAttributes.Content, _tab0.Text);
        }
        public void RenderEmptyStrip()
        {
            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new WebTabRendererAdapter[0]);

            AssertControl(false, true, false, 0, renderingContext);
        }
Exemple #3
0
        protected void AddAttributesToRender(WebTabStripRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            AddStandardAttributesToRender(renderingContext);

            if (string.IsNullOrEmpty(renderingContext.Control.CssClass) && string.IsNullOrEmpty(renderingContext.Control.Attributes["class"]))
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassBase);
            }
        }
        public void RenderEmptyListInDesignMode()
        {
            _webTabStrip.Stub(stub => stub.IsDesignMode).Return(true);

            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new WebTabRendererAdapter[0]);

            AssertControl(false, true, true, 0, renderingContext);
        }
        protected override Command RenderBeginTagForCommand(WebTabStripRenderingContext renderingContext, IWebTab tab, bool isEnabled, WebTabStyle style)
        {
            ArgumentUtility.CheckNotNull("style", style);

            var menuTab = ((IMenuTab)tab).GetActiveTab();
            var command = GetRenderingCommand(isEnabled, menuTab);

            var additionalUrlParameters = menuTab.GetUrlParameters();
            var backupID        = command.ItemID;
            var backupAccessKey = command.AccessKey;

            try
            {
                if (string.IsNullOrEmpty(command.ItemID) && !string.IsNullOrEmpty(tab.ItemID))
                {
                    command.ItemID = tab.ItemID + "_Command";
                }

                if (string.IsNullOrEmpty(command.AccessKey))
                {
                    var textWithHotkey = HotkeyParser.Parse(tab.Text);
                    if (textWithHotkey.Hotkey.HasValue)
                    {
                        command.AccessKey = HotkeyFormatter.FormatHotkey(textWithHotkey);
                    }
                }

                command.RenderBegin(
                    renderingContext.Writer,
                    RenderingFeatures,
                    tab.GetPostBackClientEvent(),
                    new string[0],
                    string.Empty,
                    null,
                    additionalUrlParameters,
                    false,
                    style);

                return(command);
            }
            finally
            {
                command.ItemID    = backupID;
                command.AccessKey = backupAccessKey;
            }
        }
        public void RenderPopulatedStrip()
        {
            PopulateTabStrip();
            _tab0.Stub(stub => stub.EvaluateEnabled()).Return(true);

            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new[]
            {
                new WebTabRendererAdapter(_tab0.GetRenderer(), _tab0, false, true, _style), new WebTabRendererAdapter(_tab1.GetRenderer(), _tab1, false, true, _style),
                new WebTabRendererAdapter(_tab2.GetRenderer(), _tab2, false, true, _style), new WebTabRendererAdapter(_tab3.GetRenderer(), _tab3, true, true, _style)
            });

            AssertControl(false, false, false, 4, renderingContext);
        }
        public void RenderPopulatedListInDesignMode()
        {
            _webTabStrip.Stub(stub => stub.IsDesignMode).Return(true);
            PopulateTabStrip();

            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new[]
            {
                new WebTabRendererAdapter(_tab0.GetRenderer(), _tab0, false, true, _style), new WebTabRendererAdapter(_tab1.GetRenderer(), _tab1, false, true, _style),
                new WebTabRendererAdapter(_tab2.GetRenderer(), _tab2, false, true, _style), new WebTabRendererAdapter(_tab3.GetRenderer(), _tab3, true, true, _style)
            });

            AssertControl(false, true, true, 4, renderingContext);
        }
        public void RenderPopulatedStripWithInvisibleTab()
        {
            PopulateTabStrip();
            _webTabStrip.GetVisibleTabs().RemoveAt(2);

            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new[]
            {
                new WebTabRendererAdapter(_tab0.GetRenderer(), _tab0, false, true, _style), new WebTabRendererAdapter(_tab1.GetRenderer(), _tab1, false, true, _style),
                new WebTabRendererAdapter(_tab3.GetRenderer(), _tab3, true, true, _style)
            });

            AssertControl(false, false, false, 3, renderingContext);
        }
Exemple #9
0
        public void Render()
        {
            var webTabRendererMock = MockRepository.GenerateStrictMock <IWebTabRenderer>();
            var webTabStub         = MockRepository.GenerateStub <IWebTab>();
            var renderingContext   = new WebTabStripRenderingContext(
                _httpContextStub, _htmlTextWriterStub, new WebTabStripMock(), new WebTabRendererAdapter[0]);
            var webTabStyle = new WebTabStyle();

            webTabRendererMock.Expect(mock => mock.Render(renderingContext, webTabStub, true, true, webTabStyle));
            webTabRendererMock.Replay();

            var rendererAdapter = new WebTabRendererAdapter(webTabRendererMock, webTabStub, true, true, webTabStyle);

            rendererAdapter.Render(renderingContext);

            webTabRendererMock.VerifyAllExpectations();
        }
Exemple #10
0
        public void Render(WebTabStripRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            AddAttributesToRender(renderingContext);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            RenderBeginTabsPane(renderingContext);

            foreach (var webTabRenderer in renderingContext.WebTabRenderers)
            {
                webTabRenderer.Render(renderingContext);
                renderingContext.Writer.WriteLine();
            }

            RenderEndTabsPane(renderingContext);
            renderingContext.Writer.RenderEndTag();
        }
        public void RenderPopulatedStripWithCssClass()
        {
            _webTabStrip.CssClass = "SomeCssClass";
            PopulateTabStrip();
            _tab0.Stub(stub => stub.EvaluateEnabled()).Return(true);

            var renderingContext = new WebTabStripRenderingContext(
                _httpContextStub,
                _htmlHelper.Writer,
                _webTabStrip,
                new[]
            {
                new WebTabRendererAdapter(CreateWebTabRenderer(), _tab0, false, true, _style),
                new WebTabRendererAdapter(CreateWebTabRenderer(), _tab1, false, true, _style),
                new WebTabRendererAdapter(CreateWebTabRenderer(), _tab2, false, true, _style),
                new WebTabRendererAdapter(CreateWebTabRenderer(), _tab3, true, true, _style)
            });

            AssertControl(true, false, false, 4, renderingContext);
        }
Exemple #12
0
        private void RenderBeginTabsPane(WebTabStripRenderingContext renderingContext)
        {
            bool isEmpty = renderingContext.Control.Tabs.Count == 0;

            string cssClass = CssClassTabsPane;

            if (isEmpty)
            {
                cssClass += " " + CssClassTabsPaneEmpty;
            }
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); // Begin Div

            if (renderingContext.Control.IsDesignMode)
            {
                renderingContext.Writer.AddStyleAttribute("list-style", "none");
                renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
                renderingContext.Writer.AddStyleAttribute("display", "inline");
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Ul); // Begin List
        }
Exemple #13
0
 private void RenderEndTabsPane(WebTabStripRenderingContext renderingContext)
 {
     renderingContext.Writer.RenderEndTag(); // End List
     renderingContext.Writer.RenderEndTag(); // End Div
 }
        private void AssertControl(bool withCssClass, bool isEmpty, bool isDesignMode, int tabCount, WebTabStripRenderingContext renderingContext)
        {
            _renderer = new WebTabStripQuirksModeRenderer(new FakeResourceUrlFactory());
            _renderer.Render(renderingContext);

            var     document = _htmlHelper.GetResultDocument();
            XmlNode list     = GetAssertedTabList(document, withCssClass, isEmpty, tabCount, isDesignMode);

            AssertTabs(list, isDesignMode);
        }