Provides rendering facilities for script elements in the head element of the page
Esempio n. 1
0
        public void MergedScriptIsCorrect(string skinKey, int expectedStyles)
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);
            MockRepository mocks = new MockRepository();

            VirtualPathProvider pathProvider = GetTemplatesPathProviderMock(mocks);
            mocks.ReplayAll();

            SkinTemplateCollection templates = new SkinTemplateCollection(pathProvider);
            ScriptElementCollectionRenderer renderer = new ScriptElementCollectionRenderer(templates);
            int mergedStyles = renderer.GetScriptsToBeMerged(skinKey).Count;

            Assert.AreEqual(expectedStyles, mergedStyles, String.Format("Skin {0} should have {1} merged scripts but found {2}", skinKey, expectedStyles, mergedStyles));
        }
Esempio n. 2
0
        public void ScriptElementCollectionRendererRendersJSHandlerScript()
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);

            var pathProvider = new Mock<VirtualPathProvider>();
            pathProvider.SetupSkins();
            var skinEngine = new SkinEngine(pathProvider.Object);

            var renderer = new ScriptElementCollectionRenderer(skinEngine);
            string scriptElements = renderer.RenderScriptElementCollection("RedBook-Blue.css");

            string script =
                @"<script type=""text/javascript"" src=""/Skins/RedBook/js.axd?name=RedBook-Blue.css""></script>";
            Assert.IsTrue(scriptElements.Contains(script), "Rendered the script improperly.");
        }
Esempio n. 3
0
        public void ScriptElementCollectionRendererRendersScriptElements()
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);

            var pathProvider = new Mock<VirtualPathProvider>();
            pathProvider.SetupSkins();
            var skinEngine = new SkinEngine(pathProvider.Object);
            var renderer = new ScriptElementCollectionRenderer(skinEngine);
            string scriptElements = renderer.RenderScriptElementCollection("RedBook-Green.css");

            string script = @"<script type=""text/javascript"" src=""/Skins/RedBook/blah.js""></script>";
            Assert.IsTrue(scriptElements.Contains(script), "Rendered the script improperly.");

            scriptElements = renderer.RenderScriptElementCollection("Nature-Leafy.css");
            script = @"<script type=""text/javascript"" src=""/scripts/XFNHighlighter.js""></script>";
            Assert.IsTrue(scriptElements.Contains(script), "Rendered the script improperly. We got: " + scriptElements);
        }
Esempio n. 4
0
        public void ScriptElementCollectionRendererRendersJSHandlerScript()
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);
            MockRepository mocks = new MockRepository();

            VirtualPathProvider pathProvider = GetTemplatesPathProviderMock(mocks);
            mocks.ReplayAll();

            SkinTemplateCollection templates = new SkinTemplateCollection(pathProvider);
            ScriptElementCollectionRenderer renderer = new ScriptElementCollectionRenderer(templates);
            string scriptElements = renderer.RenderScriptElementCollection("RedBook-Blue.css");

            Console.WriteLine(scriptElements);

            string script = @"<script type=""text/javascript"" src=""/Skins/RedBook/js.axd?name=RedBook-Blue.css""></script>";
            Assert.IsTrue(scriptElements.IndexOf(script) > -1, "Rendered the script improperly.");
        }