コード例 #1
0
        public void CanCreateCachedBundleAssetTag()
        {
            javaScriptBundle
            .Add("~/js/test.js")
            .AsCached("Test", "~/assets/js/main");

            var content = javaScriptBundle.RenderCached("Test");

            javaScriptBundle.ClearCache();
            var tag = javaScriptBundle.RenderCachedAssetTag("Test");

            Assert.AreEqual("<script type=\"text/javascript\" src=\"assets/js/main?r=E36D384488ABCF73BCCE650C627FB74F\"></script>", tag);
            Assert.AreEqual("function product(a,b){return a*b}function sum(a,b){return a+b}", content);
        }
コード例 #2
0
        public void CanCreateCachedBundleAssetTag()
        {
            javaScriptBundle
            .Add("~/js/test.js")
            .AsCached("Test", "~/assets/js/main");

            var content = javaScriptBundle.RenderCached("Test");

            javaScriptBundle.ClearCache();
            var tag = javaScriptBundle.RenderCachedAssetTag("Test");

            Assert.AreEqual("<script type=\"text/javascript\" src=\"assets/js/main?r=36286D0CEA57C5ED24B868EB0D2898E9\"></script>", tag);
            Assert.AreEqual("function product(n,t){return n*t}function sum(n,t){return n+t}", content);
        }
コード例 #3
0
        public void CanCreateCachedBundleAssetTag()
        {
            javaScriptBundle.ClearCache();

            javaScriptBundle
            .Add(Test1Path)
            .AsCached("Test", "~/assets/js/main");

            var content = javaScriptBundle.RenderCached("Test");

            var tag = javaScriptBundle.RenderCachedAssetTag("Test");

            //Assert.AreEqual("<script type=\"text/javascript\" src=\"assets/js/main?r=E36D384488ABCF73BCCE650C627FB74F\"></script>", tag);
            Assert.AreEqual(TEST1_MINIFIED, content);
        }
コード例 #4
0
        public void CanCreateCachedBundleWithForceRelease()
        {
            var tag1 = debugJavaScriptBundle
                       .Add("~/js/test.js")
                       .ForceRelease()
                       .AsCached("Test", "~/assets/js/main");

            var content = debugJavaScriptBundle.RenderCached("Test");

            javaScriptBundle.ClearCache();
            var tag2 = debugJavaScriptBundle.RenderCachedAssetTag("Test");

            Assert.AreEqual(tag1, tag2);
            Assert.AreEqual("<script type=\"text/javascript\" src=\"assets/js/main?r=36286D0CEA57C5ED24B868EB0D2898E9\"></script>", tag1);
            Assert.AreEqual(minifiedJavaScript, content);
        }
コード例 #5
0
 /// <summary>
 ///   Render current <see cref="JavaScriptBundle" /> as a cached asset tag
 /// </summary>
 /// <param name="javaScriptBundle">Current javascript bundle</param>
 /// <param name="name">javascript bundle name</param>
 /// <returns>Current bundle as a cached asset tag</returns>
 public static IHtmlString MvcRenderCachedAssetTag(this JavaScriptBundle javaScriptBundle, string name)
 {
     return(new NonEncodedHtmlString(javaScriptBundle.RenderCachedAssetTag(name)));
 }
コード例 #6
0
 public static MvcHtmlString MvcRenderCachedAssetTag(this JavaScriptBundle javaScriptBundle, string name)
 {
     return(MvcHtmlString.Create(javaScriptBundle.RenderCachedAssetTag(name)));
 }