Exemplo n.º 1
0
        public void Setup()
        {
            cssBundleFactory = new CssBundleFactory();
            var retryableFileOpener = new RetryableFileOpener();

            hasher = new Hasher(retryableFileOpener);
        }
Exemplo n.º 2
0
        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, 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")]);
        }
Exemplo n.º 3
0
        public void DoesNotRenderDuplicateArbitraryStringsInDebug()
        {
            var tag = new CssBundleFactory()
                      .WithDebuggingEnabled(true)
                      .Create()
                      .AddString(css)
                      .AddString(css)
                      .Render("doesn't matter where...");

            var expectedTag = string.Format("<style type=\"text/css\">{0}</style>\n", css);

            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }
Exemplo n.º 4
0
        public void CanRenderArbitraryStringsInDebug()
        {
            var css2Format = "{0}{1}";

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

            var tag = new CssBundleFactory()
                      .WithDebuggingEnabled(true)
                      .Create()
                      .AddString(css)
                      .AddString(css2Format, hrColor, p)
                      .Render("doesn't matter where...");

            var expectedTag = string.Format("<style type=\"text/css\">{0}</style>\n<style type=\"text/css\">{1}</style>\n", css, string.Format(css2Format, hrColor, p));

            Assert.AreEqual(expectedTag, TestUtilities.NormalizeLineEndings(tag));
        }