Esempio n. 1
0
        public void StyleSheetElementCollectionRendererRendersPlainCssLinkElementsWithNoneMergeMode(string subFolder,
                                                                                                    string
                                                                                                    applicationPath,
                                                                                                    string
                                                                                                    expectedPrintCssPath,
                                                                                                    string
                                                                                                    expectedDefaultCssPath)
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", subFolder, applicationPath);
            var pathProvider = new Mock <VirtualPathProvider>();

            pathProvider.SetupSkins();
            var    skinEngine    = new SkinEngine(pathProvider.Object);
            var    renderer      = new StyleSheetElementCollectionRenderer(skinEngine);
            string styleElements = renderer.RenderStyleElementCollection("RedBook-Red.css");

            string printCss =
                string.Format(@"<link media=""print"" type=""text/css"" rel=""stylesheet"" href=""{0}"" />",
                              expectedPrintCssPath);

            Assert.IsTrue(styleElements.Contains(printCss, StringComparison.OrdinalIgnoreCase),
                          "Expected the printcss to be there.");

            string defaultCss = string.Format(@"<link type=""text/css"" rel=""stylesheet"" href=""{0}"" />",
                                              expectedDefaultCssPath);

            Assert.IsTrue(styleElements.Contains(defaultCss, StringComparison.OrdinalIgnoreCase),
                          "Expected the default css to be there.");
        }
Esempio n. 2
0
        public void StyleSheetElementCollectionRendererRendersLinkElementsInRightOrder(string skinKey,
                                                                                       bool expectedFirst)
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);
            var pathProvider = new Mock <VirtualPathProvider>();

            pathProvider.SetupSkins();
            var skinEngine = new SkinEngine(pathProvider.Object);

            var renderer = new StyleSheetElementCollectionRenderer(skinEngine);

            string       styleElements = renderer.RenderStyleElementCollection(skinKey);
            SkinTemplate template      = skinEngine.GetSkinTemplates(false)[skinKey];

            styleElements = styleElements.Trim('\r', '\n');
            string mergedCss = @"<link type=""text/css"" rel=""stylesheet"" href=""/Skins/" + template.TemplateFolder +
                               "/css.axd?name=" + skinKey + @""" />";

            if (expectedFirst)
            {
                Assert.IsTrue(styleElements.StartsWith(mergedCss, StringComparison.OrdinalIgnoreCase),
                              "Merged CSS is not in first position");
            }
            else
            {
                Assert.IsTrue(styleElements.EndsWith(mergedCss, StringComparison.OrdinalIgnoreCase),
                              "Merged CSS is not in last position");
            }
        }
Esempio n. 3
0
        public void CallsToCssHandlerAreNotRepeated(string skinKey, string exptectedElements)
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);
            var pathProvider = new Mock <VirtualPathProvider>();

            pathProvider.SetupSkins();
            var skinEngine = new SkinEngine(pathProvider.Object);

            var    renderer      = new StyleSheetElementCollectionRenderer(skinEngine);
            string styleElements = renderer.RenderStyleElementCollection(skinKey);
            IDictionary <string, SkinTemplate> templates = skinEngine.GetSkinTemplates(false);
            SkinTemplate template = templates[skinKey];

            string mergedCss = @"<link type=""text/css"" rel=""stylesheet"" href=""/Skins/" + template.TemplateFolder +
                               "/css.axd?name=" + skinKey + @""" />";

            styleElements = styleElements.Replace(mergedCss, string.Empty);
            Assert.IsTrue(styleElements.Trim('\r', '\n').Equals(exptectedElements), "Not the expected stylesheet links");
        }
Esempio n. 4
0
        public void RenderStyleElementCollection_WithNoStyles_RendersDefaultStyle()
        {
            // arrange
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", string.Empty, "/");
            var pathProvider = new Mock <VirtualPathProvider>();
            var skinEngine   = new SkinEngine(pathProvider.Object);
            var renderer     = new StyleSheetElementCollectionRenderer(skinEngine);
            var skinTemplate = new SkinTemplate {
                ExcludeDefaultStyle = false, Styles = null, TemplateFolder = "TestSkin"
            };

            // act
            string styleElements = renderer.RenderStyleElementCollection("TestSkin", skinTemplate);

            // assert
            const string defaultStyle = @"<link type=""text/css"" rel=""stylesheet"" href=""/Skins/TestSkin/style.css"" />";

            Assert.AreEqual(defaultStyle, styleElements.Trim());
        }
Esempio n. 5
0
        public void InitializeBlogPage()
        {
            var skin = SkinConfig.GetCurrentSkin(Blog, SubtextContext.HttpContext);
            var skinControlLoader = new SkinControlLoader(this, skin);

            InitializeControls(skinControlLoader);

            if (skin.HasCustomCssText)
            {
                CustomCss.Attributes.Add("href", Url.CustomCssUrl());
            }
            else
            {
                //MAC IE does not like the empy CSS file, plus its a waste :)
                CustomCss.Visible = false;
            }

            if (Rsd != null)
            {
                Rsd.Attributes.Add("href", Url.RsdUrl(Blog).ToString());
            }

            if (wlwmanifest != null)
            {
                wlwmanifest.Attributes.Add("href", Url.WlwManifestUrl());
            }

            if (opensearch != null)
            {
                opensearch.Attributes.Add("href", Url.OpenSearchDescriptorUrl());
                opensearch.Attributes.Add("Title", Blog.Title);
            }

            if (RSSLink != null)
            {
                RSSLink.Attributes.Add("href", Url.RssUrl(Blog).ToString());
            }

            // if specified, add script elements
            if (scripts != null)
            {
                scripts.Text = ScriptRenderer.RenderScriptElementCollection(skin.SkinKey);
            }

            if (styles != null)
            {
                styles.Text = StyleRenderer.RenderStyleElementCollection(skin.SkinKey);
            }

            if (openIDServer != null && !string.IsNullOrEmpty(Blog.OpenIdServer))
            {
                openIDServer.Text = string.Format(OpenIdServerLocation, Blog.OpenIdServer);
            }

            if (openIDDelegate != null && !string.IsNullOrEmpty(Blog.OpenIdDelegate))
            {
                openIDDelegate.Text = string.Format(OpenIdDelegateLocation, Blog.OpenIdDelegate);
            }

            if (metaTags != null)
            {
                metaTags.Blog = Blog;
            }
        }