Ejemplo n.º 1
0
        void InitDirectories()
        {
            var cassetteSettings = container.Resolve <CassetteSettings>();

            sourceDirectory.Add("~/image-b.png", BluePng());
            sourceDirectory.Add("~/image-a.png", RedPng());
            sourceDirectory.Add("~/asset.css", "");
            cassetteSettings.CacheDirectory = new FileSystemDirectory(cache);
        }
Ejemplo n.º 2
0
        public void GivenCssWithRelativeUrl_WhenTransformed_ThenUrlIsExpanded()
        {
            fileSystem.Add("~/styles/test.png");

            var css       = "p { background-image: url(test.png); }";
            var getResult = transformer.Transform(css.AsStream, asset.Object);
            var output    = getResult().ReadToEnd();

            output.ShouldEqual("p { background-image: url(EXPANDED); }");

            urlGenerator.Verify(g => g.CreateRawFileUrl("~/styles/test.png", It.IsAny <string>()));
        }
Ejemplo n.º 3
0
        public void TransformInsertsImageUrlWithDataUriAfterTheExistingImage()
        {
            fileSystem.Add("~/test.png", new byte[] { 1, 2, 3 });

            var css       = "p { background-image: url(test.png); }";
            var getResult = transformer.Transform(css.AsStream, asset.Object);

            var expectedBase64 = Base64Encode(new byte[] { 1, 2, 3 });

            getResult().ReadToEnd().ShouldEqual(
                "p { background-image: url(test.png);background-image: url(data:image/png;base64," + expectedBase64 + "); }"
                );
        }
        public void WhenSettingsDoNotAllowRawFileRequest_ThenThrowException()
        {
            fileSystem.Add("~/web.config");
            fileAccessAuthorization.Setup(a => a.CanAccess("~/web.config")).Returns(false);
            var exception = Assert.Throws <Exception>(() => Bundles.FileUrl("~/web.config"));

            exception.Message.ShouldStartWith("The file ~/web.config cannot be requested.");
        }
Ejemplo n.º 5
0
 public void WritesCacheFileToOutputStream()
 {
     cacheDirectory.Add("~/file.png", new byte[] { 1, 2, 3 });
     handler.ProcessRequest("~/file.png");
     outputStream.ToArray().ShouldEqual(new byte[] { 1, 2, 3 });
 }