當前位置: 首頁>>代碼示例>>C#>>正文


C# Helpers.JavaScriptBundleFactory類代碼示例

本文整理匯總了C#中SquishIt.Tests.Helpers.JavaScriptBundleFactory的典型用法代碼示例。如果您正苦於以下問題:C# JavaScriptBundleFactory類的具體用法?C# JavaScriptBundleFactory怎麽用?C# JavaScriptBundleFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JavaScriptBundleFactory類屬於SquishIt.Tests.Helpers命名空間,在下文中一共展示了JavaScriptBundleFactory類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Setup

 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory()
         .WithDebuggingEnabled(false)
         .WithHasher(new StubHasher("hash"))
         .WithContents(javaScript);
     //javaScriptBundleFactory.FileReaderFactory.SetContents(javaScript);
 }
開發者ID:mattbeckman,項目名稱:SquishIt,代碼行數:8,代碼來源:JavaScriptBundleTests.cs

示例2: CanBundleArbitraryContentsInRelease

        public void CanBundleArbitraryContentsInRelease()
        {
            var js2Format = "{0}{1}";

            var subtract = "function sub(a,b){return a-b}";
            var divide = "function div(a,b){return a/b}";

            var writerFactory = new StubFileWriterFactory();

            var tag = new JavaScriptBundleFactory()
                    .WithDebuggingEnabled(false)
                    .WithFileWriterFactory(writerFactory)
                    .WithHasher(new StubHasher("hashy"))
                    .Create()
                    .AddString(javaScript)
                    .AddString(js2Format, new[] { subtract, divide })
                    .Render("~/output.js");

            var expectedTag = "<script type=\"text/javascript\" src=\"output.js?r=hashy\"></script>";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var minifiedScript = "function product(n,t){return n*t}function sum(n,t){return n+t};function sub(n,t){return n-t}function div(n,t){return n/t};";
            Assert.AreEqual(minifiedScript, writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.js")]);
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:24,代碼來源:JavaScriptBundleTests.cs

示例3: CanRenderArbitraryStringsInDebugWithoutType

        public void CanRenderArbitraryStringsInDebugWithoutType()
        {
            var js2Format = "{0}{1}";

            var subtract = "function sub(a,b){return a-b}";
            var divide = "function div(a,b){return a/b}";

            var tag = new JavaScriptBundleFactory()
                .WithDebuggingEnabled(true)
                .Create()
                .AddString(javaScript)
                .AddString(js2Format, new[] { subtract, divide })
                .WithoutTypeAttribute()
                .Render("doesn't matter where...");

            var expectedTag = string.Format("<script>{0}</script>\n<script>{1}</script>\n", javaScript, string.Format(js2Format, subtract, divide));
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:18,代碼來源:JavaScriptBundleTests.cs

示例4: CanMaintainOrderBetweenArbitraryAndFileAssetsInRelease

        public void CanMaintainOrderBetweenArbitraryAndFileAssetsInRelease()
        {
            var file1 = "somefile.js";
            var file2 = "anotherfile.js";

            var subtract = "function sub(a,b){return a-b}";
            var minifiedSubtract = "function sub(n,t){return n-t};";

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file1), javaScript);
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file2), javaScript2);

            var writerFactory = new StubFileWriterFactory();

            var tag = new JavaScriptBundleFactory()
                .WithFileReaderFactory(readerFactory)
                .WithFileWriterFactory(writerFactory)
                .WithDebuggingEnabled(false)
                .Create()
                .Add(file1)
                .AddString(subtract)
                .Add(file2)
                .Render("test.js");

            var expectedTag = string.Format("<script type=\"text/javascript\" src=\"test.js?r=hash\"></script>");
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var combined = minifiedJavaScript + minifiedSubtract + minifiedJavaScript2;
            Assert.AreEqual(combined, writerFactory.Files[TestUtilities.PrepareRelativePath(@"test.js")]);
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:30,代碼來源:JavaScriptBundleTests.cs

示例5: CanMaintainOrderBetweenArbitraryAndFileAssetsInDebug

        public void CanMaintainOrderBetweenArbitraryAndFileAssetsInDebug()
        {
            var file1 = "somefile.js";
            var file2 = "anotherfile.js";

            var subtract = "function sub(a,b){return a-b}";

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file1), javaScript);
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file2), javaScript2);

            var writerFactory = new StubFileWriterFactory();

            var tag = new JavaScriptBundleFactory()
                .WithFileReaderFactory(readerFactory)
                .WithFileWriterFactory(writerFactory)
                .WithDebuggingEnabled(true)
                .Create()
                .Add(file1)
                .AddString(subtract)
                .Add(file2)
                .Render("test.js");

            var expectedTag = string.Format("<script type=\"text/javascript\" src=\"somefile.js\"></script>\n<script type=\"text/javascript\">{0}</script>\n<script type=\"text/javascript\" src=\"anotherfile.js\"></script>\n"
                , subtract);
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:27,代碼來源:JavaScriptBundleTests.cs

示例6: CanBundleDirectoryContentsInDebug

        public void CanBundleDirectoryContentsInDebug()
        {
            var path = Guid.NewGuid().ToString();
            var file1 = TestUtilities.PreparePath(Environment.CurrentDirectory + "\\" + path + "\\file1.js");
            var file2 = TestUtilities.PreparePath(Environment.CurrentDirectory + "\\" + path + "\\file2.js");

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, StubResolver.ForDirectory(new[] { file1, file2 })))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, javaScript2.Replace("sum", "replace"));
                frf.SetContentsForFile(file2, javaScript);

                var writerFactory = new StubFileWriterFactory();

                var tag = new JavaScriptBundleFactory()
                        .WithDebuggingEnabled(true)
                        .WithFileReaderFactory(frf)
                        .WithFileWriterFactory(writerFactory)
                        .WithHasher(new StubHasher("hashy"))
                        .Create()
                        .Add(path)
                        .Render("~/output.js");

                var expectedTag = string.Format("<script type=\"text/javascript\" src=\"{0}/file1.js\"></script>\n<script type=\"text/javascript\" src=\"{0}/file2.js\"></script>\n", path);
                Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
            }
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:27,代碼來源:JavaScriptBundleTests.cs

示例7: CanBundleDirectoryContentsInRelease_Ignores_Duplicates

        public void CanBundleDirectoryContentsInRelease_Ignores_Duplicates()
        {
            var path = Guid.NewGuid().ToString();
            var file1 = TestUtilities.PrepareRelativePath(path + "\\file1.js");
            var file2 = TestUtilities.PrepareRelativePath(path + "\\file2.js");

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, StubResolver.ForDirectory(new[] { file1, file2 })))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, javaScript2.Replace("sum", "replace"));
                frf.SetContentsForFile(file2, javaScript);

                var writerFactory = new StubFileWriterFactory();

                var tag = new JavaScriptBundleFactory()
                        .WithDebuggingEnabled(false)
                        .WithFileReaderFactory(frf)
                        .WithFileWriterFactory(writerFactory)
                        .WithHasher(new StubHasher("hashy"))
                        .Create()
                        .Add(path)
                        .Add(file1)
                        .Render("~/output.js");

                var expectedTag = "<script type=\"text/javascript\" src=\"output.js?r=hashy\"></script>";
                Assert.AreEqual(expectedTag, tag);

                var combined = "function replace(n,t){return n+t};function product(n,t){return n*t}function sum(n,t){return n+t};";
                Assert.AreEqual(combined, writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.js")]);
            }
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:31,代碼來源:JavaScriptBundleTests.cs

示例8: CanBundleDirectoryContentsInDebug_Writes_And_Ignores_Preprocessed_Debug_Files

        public void CanBundleDirectoryContentsInDebug_Writes_And_Ignores_Preprocessed_Debug_Files()
        {
            var path = Guid.NewGuid().ToString();
            var file1 = TestUtilities.PrepareRelativePath(path + "\\file1.script.js");
            var file2 = TestUtilities.PrepareRelativePath(path + "\\file1.script.js.squishit.debug.js");
            var content = "some stuffs";

            var preprocessor = new StubScriptPreprocessor();

            using(new ScriptPreprocessorScope<StubScriptPreprocessor>(preprocessor))
            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, StubResolver.ForDirectory(new[] { file1, file2 })))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, content);

                var writerFactory = new StubFileWriterFactory();

                var tag = new JavaScriptBundleFactory()
                        .WithDebuggingEnabled(true)
                        .WithFileReaderFactory(frf)
                        .WithFileWriterFactory(writerFactory)
                        .WithHasher(new StubHasher("hashy"))
                        .Create()
                        .Add(path)
                        .Render("~/output.js");

                var expectedTag = string.Format("<script type=\"text/javascript\" src=\"{0}/file1.script.js.squishit.debug.js\"></script>\n", path);
                Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
                Assert.AreEqual(content, preprocessor.CalledWith);
                Assert.AreEqual(1, writerFactory.Files.Count);
                Assert.AreEqual("scripty", writerFactory.Files[file1 + ".squishit.debug.js"]);
            }
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:33,代碼來源:JavaScriptBundleTests.cs

示例9: DoesNotRenderDuplicateArbitraryStringsInDebug

        public void DoesNotRenderDuplicateArbitraryStringsInDebug()
        {
            var tag = new JavaScriptBundleFactory()
                .WithDebuggingEnabled(true)
                .Create()
                .AddString(javaScript)
                .AddString(javaScript)
                .Render("doesn't matter where...");

            var expectedTag = string.Format("<script type=\"text/javascript\">{0}</script>\n", javaScript);
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }
開發者ID:rdumont,項目名稱:SquishIt,代碼行數:12,代碼來源:JavaScriptBundleTests.cs

示例10: Setup

 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory();
 }
開發者ID:paulyoder,項目名稱:SquishIt,代碼行數:4,代碼來源:HoganTests.cs

示例11: Includes_Semicolon_And_Newline_Between_Scripts

        public void Includes_Semicolon_And_Newline_Between_Scripts()
        {
            var writerFactory = new StubFileWriterFactory();

            var tag = new JavaScriptBundleFactory()
                    .WithDebuggingEnabled(false)
                    .WithFileWriterFactory(writerFactory)
                    .WithHasher(new StubHasher("hashy"))
                    .Create()
                    .AddString("first")
                    .AddString("second")
                    .Render("~/output.js");

            var expectedTag = "<script type=\"text/javascript\" src=\"output.js?r=hashy\"></script>";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var minifiedScript = "first;\nsecond;\n";
            Assert.AreEqual(minifiedScript, writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.js")]);
        }
開發者ID:mattbeckman,項目名稱:SquishIt,代碼行數:19,代碼來源:JavaScriptBundleTests.cs

示例12: Setup

 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory()
         .WithDebuggingEnabled(false);
     javaScriptBundleFactory.FileReaderFactory.SetContents(javaScript);
     var retryableFileOpener = new RetryableFileOpener();
     hasher = new Hasher(retryableFileOpener);
 }
開發者ID:paulyoder,項目名稱:SquishIt,代碼行數:8,代碼來源:JavaScriptBundleTests.cs

示例13: Setup

 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory();
     var retryableFileOpener = new RetryableFileOpener();
     hasher = new Hasher(retryableFileOpener);
 }
開發者ID:paulyoder,項目名稱:SquishIt,代碼行數:6,代碼來源:ScriptPreprocessorPipelineTests.cs

示例14: Setup

 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory();
     hasher = new StubHasher("hash");
 }
開發者ID:nbone,項目名稱:SquishIt,代碼行數:5,代碼來源:ScriptPreprocessorPipelineTests.cs


注:本文中的SquishIt.Tests.Helpers.JavaScriptBundleFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。