コード例 #1
0
        public void Setup()
        {
            var nonDebugStatusReader = new StubDebugStatusReader(false);
            var debugStatusReader = new StubDebugStatusReader(true);
            fileWriterFactory = new StubFileWriterFactory();
            fileReaderFactory = new StubFileReaderFactory();
            currentDirectoryWrapper = new StubCurrentDirectoryWrapper();
            stubBundleCache = new StubBundleCache();

            var retryableFileOpener = new RetryableFileOpener();
            hasher = new Hasher(retryableFileOpener);

            fileReaderFactory.SetContents(javaScript);

            javaScriptBundle = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            javaScriptBundle2 = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle2 = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);
        }
コード例 #2
0
 public void CanMarkJavaScriptBundleAsPackageable()
 {
     IJavaScriptBundle jsBundle = new JavaScriptBundle(mockDebugStatusReader,
                                          mockFileWriterFactory,
                                          jsMockFileReaderFactory);
     string tag = jsBundle
         .Add("/js/test.js")
         .AsPackageable()
         .Render("/js/render_differently_if_packaged_#.js");
 }
コード例 #3
0
        public void Setup()
        {
            var nonDebugStatusReader = new StubDebugStatusReader(false);
            var debugStatusReader = new StubDebugStatusReader(true);
            currentDirectoryWrapper = new StubCurrentDirectoryWrapper();
            stubBundleCache = new ApplicationCache();

            var retryableFileOpener = new RetryableFileOpener();
            hasher = new Hasher(retryableFileOpener);

            //fileReaderFactory.SetContents(javaScript);

            javaScriptBundle = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            javaScriptBundle2 = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle2 = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            outputFileNumber += 1;
            currentOutputFile = outputFileRoot + outputFileNumber + ".js";
        }
コード例 #4
0
        public void CanGetOutputUrlForMultipleFilesInReleaseMode()
        {
            var file1 = TestUtilities.PrepareRelativePath("\\js\\test1.js");
            var file2 = TestUtilities.PrepareRelativePath("\\js\\test2.js");
            var subtract = @"function sub (a, b) {
                                return a - b
                             }";
            var divide = @"function div (a, b) {
                                return a / b
                           }";
            fileReaderFactory.SetContentsForFile(file1, javaScript);
            fileReaderFactory.SetContentsForFile(file2, subtract + divide);

            var nonDebugStatusReader = new StubDebugStatusReader(false);

            javaScriptBundle = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            var names = javaScriptBundle
                    .Add("~/js/test1.js")
                    .Add("~/js/test2.js")
                    .SquishAndGetUrls("~/js/output_#.js");

            var str = string.Join(",", names.ToArray());
            Assert.AreEqual("js/output_9D7D22AD1BA5843A6E174D152332A1CC.js", str);

            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}";
            var actualScript = fileWriterFactory.Files[TestUtilities.PrepareRelativePath(@"js\output_9D7D22AD1BA5843A6E174D152332A1CC.js")];
            Assert.AreEqual (minifiedScript, actualScript);
        }