• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Stubs.StubFileWriterFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SquishIt.Tests.Stubs.StubFileWriterFactory的典型用法代码示例。如果您正苦于以下问题:C# StubFileWriterFactory类的具体用法?C# StubFileWriterFactory怎么用?C# StubFileWriterFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StubFileWriterFactory类属于SquishIt.Tests.Stubs命名空间,在下文中一共展示了StubFileWriterFactory类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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:QAmelie,项目名称:SquishIt,代码行数:27,代码来源:JavaScriptBundleTests.cs


示例2: CanBundleJavascriptInDebug

        public void CanBundleJavascriptInDebug(Type preprocessorType)
        {
            var preprocessor = Activator.CreateInstance(preprocessorType) as IPreprocessor;

            const string template = "<h1>{{message}}</h1>";
            var templateFileName = "test.hogan.html";
            var resolver = StubResolver.ForFile(TestUtilities.PrepareRelativePath(templateFileName));

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(templateFileName), template);

            var writerFactory = new StubFileWriterFactory();

            string tag;

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, resolver))
            {
                tag = javaScriptBundleFactory
                    .WithFileReaderFactory(readerFactory)
                    .WithFileWriterFactory(writerFactory)
                    .WithDebuggingEnabled(true)
                    .Create()
                    .WithPreprocessor(preprocessor)
                    .Add("~/" + templateFileName)
                    .Render("~/template.js");
            }

            var sb = new StringBuilder();
            sb.AppendLine(@"var JST = JST || {};");
            sb.AppendLine(@"JST['test'] = new Hogan.Template(function(c,p,i){var _=this;_.b(i=i||"""");_.b(""<h1>"");_.b(_.v(_.f(""message"",c,p,0)));_.b(""</h1>"");return _.fl();;},""" + template + "\",Hogan,{});");
            var compiled = sb.ToString();

            Assert.AreEqual(1, writerFactory.Files.Count);
            var expectedTag = "<script type=\"text/javascript\" src=\"test.hogan.html.squishit.debug.js\"></script>\n";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            Assert.AreEqual(compiled, writerFactory.Files[TestUtilities.PrepareRelativePath("test.hogan.html.squishit.debug.js")]);
        }
开发者ID:connectivedx,项目名称:SquishIt,代码行数:38,代码来源:HoganTests.cs


示例3: 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


示例4: CanBundleArbitraryContentsInRelease

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

            var hrColor = "hr {color:sienna;}";
            var p = "p {margin-left:20px;}";

            var writerFactory = new StubFileWriterFactory();

            var tag = new CSSBundleFactory()
                    .WithDebuggingEnabled(false)
                    .WithFileWriterFactory(writerFactory)
                    .WithHasher(new StubHasher("hashy"))
                    .Create()
                    .AddString(css)
                    .AddString(css2Format, new[] { hrColor, p })
                    .Render("~/output.css");

            var expectedTag = "<link rel=\"stylesheet\" type=\"text/css\" href=\"output.css?r=hashy\" />";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var minifiedScript = "li{margin-bottom:.1em;margin-left:0;margin-top:.1em}th{font-weight:normal;vertical-align:bottom}.FloatRight{float:right}.FloatLeft{float:left}hr{color:#a0522d}p{margin-left:20px}";
            Assert.AreEqual(minifiedScript, writerFactory.Files[TestUtilities.PrepareRelativePath("output.css")]);
        }
开发者ID:jincod,项目名称:SquishIt,代码行数:24,代码来源:CSSBundleTests.cs


示例5: CanBundleJavaScriptWithMinifiedDirectories

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

            var resolver = new Mock<IResolver>(MockBehavior.Strict);
            resolver.Setup(r => r.IsDirectory(It.IsAny<string>())).Returns(true);

            resolver.Setup(r =>
                r.ResolveFolder(TestUtilities.PrepareRelativePath(path), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<string>>()))
                .Returns(new[] { file1 });

            resolver.Setup(r =>
                r.ResolveFolder(TestUtilities.PrepareRelativePath(path2), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<string>>()))
                .Returns(new[] { file2 });

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, resolver.Object))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, javaScript);
                frf.SetContentsForFile(file2, javaScriptPreMinified);

                var writerFactory = new StubFileWriterFactory();

                var tag = javaScriptBundleFactory
                    .WithDebuggingEnabled(false)
                    .WithFileReaderFactory(frf)
                    .WithFileWriterFactory(writerFactory)
                    .Create()
                    .AddDirectory(path)
                    .AddMinifiedDirectory(path2)
                    .Render("~/output.js");

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

                var content = writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.js")];
                Assert.True(content.StartsWith(minifiedJavaScript));
                Assert.True(content.EndsWith(javaScriptPreMinified + ";"));
            }
        }
开发者ID:rdumont,项目名称:SquishIt,代码行数:42,代码来源:JavaScriptBundleTests.cs


示例6: 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


示例7: 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


示例8: CanBundleJavascriptInRelease

        public void CanBundleJavascriptInRelease()
        {
            const string template = "<h1>{{message}}</h1>";
            var templateFileName = "test.hogan.html";
            var resolver = StubResolver.ForFile(TestUtilities.PrepareRelativePath(templateFileName));

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(templateFileName), template);

            var writerFactory = new StubFileWriterFactory();

            string tag;

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, resolver))
            {
                tag = javaScriptBundleFactory
                    .WithFileReaderFactory(readerFactory)
                    .WithFileWriterFactory(writerFactory)
                    .WithDebuggingEnabled(false)
                    .Create()
                    .WithPreprocessor(new HoganPreprocessor())
                    .Add("~/" + templateFileName)
                    .Render("~/template.js");
            }

            //are minifier's optimizations here OK?
            var compiled =
                @"var JST=JST||{};JST.test=new Hogan.Template(function(n,t,i){var r=this;return r.b(i=i||""""),r.b(""<h1>""),r.b(r.v(r.f(""message"",n,t,0))),r.b(""</h1>""),r.fl()})";

            Assert.AreEqual(1, writerFactory.Files.Count);
            var expectedTag = "<script type=\"text/javascript\" src=\"template.js?r=hash\"></script>";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var actual = writerFactory.Files[TestUtilities.PrepareRelativePath("template.js")];
            Assert.AreEqual(compiled, actual);
        }
开发者ID:paulyoder,项目名称:SquishIt,代码行数:36,代码来源:HoganTests.cs


示例9: CanBundleJavascriptInReleaseWithArbitraryHogan

        public void CanBundleJavascriptInReleaseWithArbitraryHogan()
        {
            const string template = "<h1>{{message}}</h1>";

            var writerFactory = new StubFileWriterFactory();

            string tag;

            tag = javaScriptBundleFactory
                    .WithFileWriterFactory(writerFactory)
                    .WithDebuggingEnabled(false)
                    .Create()
                    .WithPreprocessor(new HoganPreprocessor())
                    .AddString(template, ".hogan.html")
                    .Render("~/template.js");

            //are minifier's optimizations here OK?
            var compiled = @"var JST=JST||{};JST.dummy=new Hogan.Template(";

            Assert.AreEqual(1, writerFactory.Files.Count);
            var expectedTag = "<script type=\"text/javascript\" src=\"template.js?r=hash\"></script>";
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var actual = writerFactory.Files[TestUtilities.PrepareRelativePath("template.js")];
            Assert.IsTrue(actual.StartsWith(compiled));
        }
开发者ID:paulyoder,项目名称:SquishIt,代码行数:26,代码来源:HoganTests.cs


示例10: CanBundleDirectoryContentsInRelease_Ignores_Duplicates

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

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, StubResolver.ForDirectory(new[] { file1, file2 })))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, css2);
                frf.SetContentsForFile(file2, css);

                var writerFactory = new StubFileWriterFactory();

                var tag = cssBundleFactory.WithDebuggingEnabled(false)
                        .WithFileReaderFactory(frf)
                        .WithFileWriterFactory(writerFactory)
                        .Create()
                        .Add(path)
                        .Add(file1)
                        .Render("~/output.css");

                var expectedTag = "<link rel=\"stylesheet\" type=\"text/css\" href=\"output.css?r=hash\" />";
                Assert.AreEqual(expectedTag, tag);

                var combined = "li{margin-bottom:.1em;margin-left:0;margin-top:.1em}th{font-weight:normal;vertical-align:bottom}li{margin-bottom:.1em;margin-left:0;margin-top:.1em}th{font-weight:normal;vertical-align:bottom}.FloatRight{float:right}.FloatLeft{float:left}";
                Assert.AreEqual(combined, writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.css")]);
            }
        }
开发者ID:jincod,项目名称:SquishIt,代码行数:29,代码来源:CSSBundleTests.cs


示例11: CanBundleDirectoryContentsInDebug_Ignores_Duplicates

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

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, StubResolver.ForDirectory(new[] { file1, file2 })))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, css2);
                frf.SetContentsForFile(file2, css);

                var writerFactory = new StubFileWriterFactory();

                var tag = cssBundleFactory.WithDebuggingEnabled(true)
                        .WithFileReaderFactory(frf)
                        .WithFileWriterFactory(writerFactory)
                        .Create()
                        .Add(path)
                        .Render("~/output.css");

                var expectedTag = string.Format("<link rel=\"stylesheet\" type=\"text/css\" href=\"{0}/file1.css\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{0}/file2.css\" />\n", path);
                Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
            }
        }
开发者ID:jincod,项目名称:SquishIt,代码行数:25,代码来源:CSSBundleTests.cs


示例12: CanBundleCssWithMinifiedDirectories

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

            var resolver = new Mock<IResolver>(MockBehavior.Strict);
            resolver.Setup(r => r.IsDirectory(It.IsAny<string>())).Returns(true);

            resolver.Setup(r =>
                r.ResolveFolder(TestUtilities.PrepareRelativePath(path), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<string>>()))
                .Returns(new[] { file1 });

            resolver.Setup(r =>
                r.ResolveFolder(TestUtilities.PrepareRelativePath(path2), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<string>>()))
                .Returns(new[] { file2 });

            using(new ResolverFactoryScope(typeof(FileSystemResolver).FullName, resolver.Object))
            {
                var frf = new StubFileReaderFactory();
                frf.SetContentsForFile(file1, css2);
                frf.SetContentsForFile(file2, css);

                var writerFactory = new StubFileWriterFactory();

                var tag = cssBundleFactory.WithDebuggingEnabled(false)
                    .WithFileReaderFactory(frf)
                    .WithFileWriterFactory(writerFactory)
                    .WithHasher(new StubHasher("hashy"))
                    .Create()
                    .AddDirectory(path)
                    .AddMinifiedDirectory(path2)
                    .Render("~/output.css");

                Assert.AreEqual("<link rel=\"stylesheet\" type=\"text/css\" href=\"output.css?r=hashy\" />", tag);

                var content = writerFactory.Files[TestUtilities.PrepareRelativePath(@"output.css")];
                Assert.True(content.StartsWith(minifiedCss2));
                Assert.True(content.EndsWith(css));
            }
        }
开发者ID:jincod,项目名称:SquishIt,代码行数:42,代码来源:CSSBundleTests.cs


示例13: CanMaintainOrderBetweenArbitraryAndFileAssetsInDebug

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

            var arbitraryCss = ".someClass { color:red }";

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file1), css);
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file2), css2);

            var writerFactory = new StubFileWriterFactory();

            var tag = new CssBundleFactory()
                .WithFileReaderFactory(readerFactory)
                .WithFileWriterFactory(writerFactory)
                .WithDebuggingEnabled(true)
                .Create()
                .Add(file1)
                .AddString(arbitraryCss)
                .Add(file2)
                .Render("test.css");

            var expectedTag = string.Format("<link rel=\"stylesheet\" type=\"text/css\" href=\"somefile.css\" />\n<style type=\"text/css\">{0}</style>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"anotherfile.css\" />\n"
                , arbitraryCss);
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }
开发者ID:thomasvm,项目名称:SquishIt,代码行数:27,代码来源:CssBundleTests.cs


示例14: 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


示例15: 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


示例16: CanMaintainOrderBetweenArbitraryAndFileAssetsInRelease

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

            var arbitraryCss = ".someClass { color:red }";
            var minifiedArbitraryCss = ".someClass{color:red}";

            var readerFactory = new StubFileReaderFactory();
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file1), css);
            readerFactory.SetContentsForFile(TestUtilities.PrepareRelativePath(file2), css2);

            var writerFactory = new StubFileWriterFactory();

            var tag = new CSSBundleFactory()
                .WithFileReaderFactory(readerFactory)
                .WithFileWriterFactory(writerFactory)
                .WithDebuggingEnabled(false)
                .Create()
                .Add(file1)
                .AddString(arbitraryCss)
                .Add(file2)
                .Render("test.css");

            var expectedTag = string.Format("<link rel=\"stylesheet\" type=\"text/css\" href=\"test.css?r=hash\" />");
            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));

            var combined = minifiedCss + minifiedArbitraryCss + minifiedCss2;
            Assert.AreEqual(combined, writerFactory.Files[TestUtilities.PrepareRelativePath(@"test.css")]);
        }
开发者ID:jincod,项目名称:SquishIt,代码行数:30,代码来源:CSSBundleTests.cs


示例17: 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


示例18: Setup

        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);
        }
开发者ID:thomasvm,项目名称:SquishIt,代码行数:42,代码来源:JavaScriptBundleTests.cs



注:本文中的SquishIt.Tests.Stubs.StubFileWriterFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Irc.IrcChannel类代码示例发布时间:2022-05-26
下一篇:
C# Stubs.StubFileReaderFactory类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap