Esempio n. 1
0
        public void AssetsAreConcatenated()
        {
            var pipeline = new StylesheetPipeline(container, settings);
            pipeline.Process(bundle);

            bundle.Assets.Count.ShouldEqual(1);
        }
 public void CreateBundleAssignsSettingsDefaultProcessor()
 {
     var processor = new StylesheetPipeline();
     settings.SetDefaultBundleProcessor(processor);
     var bundle = factory.CreateBundle("~", Enumerable.Empty<IFile>(), new BundleDescriptor { AssetFilenames = { "*" } });
     bundle.Processor.ShouldBeSameAs(processor);
 }
 public StylesheetPipelineWhereLessCompilerTrue()
 {
     asset = new Mock<IAsset>();
     asset.SetupGet(a => a.SourceFile.FullPath).Returns("asset.less");
     asset.Setup(a => a.OpenStream()).Returns(() => "// @reference 'other.less';".AsStream());
     bundle.Assets.Add(asset.Object);
     pipeline = new StylesheetPipeline().CompileLess();
 }
Esempio n. 4
0
        public void AssetsAreMinified()
        {
            var pipeline = new StylesheetPipeline(container, settings);
            pipeline.Process(bundle);

            using (var reader = new StreamReader(bundle.Assets[0].OpenStream()))
            {
                reader.ReadToEnd().ShouldEqual("p{color:#fff}");
            }
        }
Esempio n. 5
0
        public void AssetsAreMinified()
        {
            var pipeline = new StylesheetPipeline();

            pipeline.Process(module, application.Object);

            using (var reader = new StreamReader(module.Assets[0].OpenStream()))
            {
                reader.ReadToEnd().ShouldEqual("p{color:#fff}");
            }
        }
 public void GivenCombinedStyleSheetBundle_WhenRenderedAndMinified_ThenCssIsProperlyMinifiedAsCssAndNotJavascript()
 {
     CassetteSettings settings = new CassetteSettings("1");
     IBundleProcessor<StylesheetBundle> processor = new StylesheetPipeline();
     underTest.Processor = processor;
     inner.Processor = processor;
     underTest.Process(settings);
     // underTest.Renderer = new StylesheetHtmlRenderer(new UrlGenerator(new UrlPlaceholderWrapper(), ""));
     var cssContent = underTest.OpenStream();
     string output = new StreamReader(cssContent).ReadToEnd();
     output.ShouldEqual(".className{display:none}");
 }
        public SassBundlePipelineModifier_Tests()
        {
            var minifier = Mock.Of<IStylesheetMinifier>();
            var urlGenerator = Mock.Of<IUrlGenerator>();
            var compiler = new Mock<ISassCompiler>();
            var settings = new CassetteSettings();
            var modifier = new SassBundlePipelineModifier();

            var container = new TinyIoCContainer();
            container.Register(compiler.Object);
            container.Register(minifier);
            container.Register(urlGenerator);
            container.Register(settings);

            originalPipeline = new StylesheetPipeline(container, settings);
            modifiedPipeline = modifier.Modify(originalPipeline);
        }
Esempio n. 8
0
        public void WhenProcessBundle_ThenHashIsAssigned()
        {
            var bundle = new StylesheetBundle("~");

            var pipeline = new StylesheetPipeline(container, settings);
            pipeline.Process(bundle);

            bundle.Hash.ShouldNotBeNull();
        }
Esempio n. 9
0
        public void GivenPipelineWithEmbedImages_WhenProcessBundle_ThenLessAssetHasDataUriTransformAdded()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.Path).Returns("~/file.less");
            asset.Setup(a => a.OpenStream()).Returns(Stream.Null);
            var bundle = new StylesheetBundle("~");
            bundle.Assets.Add(asset.Object);

            var pipeline = new StylesheetPipeline(container, settings);
            bundle.Pipeline = pipeline;
            bundle.EmbedImages();
            pipeline.Process(bundle);

            asset.Verify(a => a.AddAssetTransformer(It.Is<IAssetTransformer>(t => t is CssImageToDataUriTransformer)));
        }
Esempio n. 10
0
        public void CanProvideMinifier()
        {
            var bundle = new StylesheetBundle("~");
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.Path).Returns("~/asset.css");
            asset.Setup(a => a.OpenStream()).Returns(Stream.Null);
            bundle.Assets.Add(asset.Object);

            // Remove the ConcatenateAssets step, so the transformer is added to our mock asset instead of the concatenated asset object.
            var pipeline = new StylesheetPipeline(container, settings);
            pipeline.RemoveAt(pipeline.Count - 2);

            pipeline.Process(bundle);

            asset.Verify(a => a.AddAssetTransformer(It.Is<IAssetTransformer>(t => t == minifier.Object)));
        }
Esempio n. 11
0
 public void GivenDebugMode_ThenCssUrlsAreExpanded()
 {
     settings.IsDebuggingEnabled = false;
     var pipeline = new StylesheetPipeline(container, settings);
     pipeline.Process(bundle);
     asset2.Verify(a => a.AddAssetTransformer(It.Is<IAssetTransformer>(
         transformer => transformer is ExpandCssUrlsAssetTransformer)
     ));
 }
Esempio n. 12
0
 public void CssReferencesAreParsed()
 {
     var pipeline = new StylesheetPipeline(container, settings);
     pipeline.Process(bundle);
     asset1.Verify(a => a.AddReference("asset2.css", 1));
 }
        public void GivenCompileSassIsTrue_WhenProcessBundle_ThenSassAssetHasCompileAssetTransformAdded()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.SourceFile.FullPath).Returns("~/file.sass");
            asset.Setup(a => a.OpenStream()).Returns(Stream.Null);
            var bundle = new StylesheetBundle("~");
            bundle.Assets.Add(asset.Object);

            var pipeline = new StylesheetPipeline().CompileSass();
            pipeline.Process(bundle, new CassetteSettings(""));

            asset.Verify(a => a.AddAssetTransformer(It.Is<IAssetTransformer>(t => t is CompileAsset)));
        }
        public void WhenProcessBundle_ThenHashIsAssigned()
        {
            var pipeline = new StylesheetPipeline();
            var bundle = new StylesheetBundle("~");

            pipeline.Process(bundle, new CassetteSettings(""));

            bundle.Hash.ShouldNotBeNull();
        }
        public void GivenConvertImageUrlsToDataUrisIsTrue_WhenProcessBundle_ThenLessAssetHasDataUriTransformAdded()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.SourceFile.FullPath).Returns("~/file.less");
            asset.Setup(a => a.OpenStream()).Returns(Stream.Null);
            var bundle = new StylesheetBundle("~");
            bundle.Assets.Add(asset.Object);

            var pipeline = new StylesheetPipeline { ConvertImageUrlsToDataUris = true };
            pipeline.Process(bundle, new CassetteSettings(""));

            asset.Verify(a => a.AddAssetTransformer(It.Is<IAssetTransformer>(t => t is CssImageToDataUriTransformer)));
        }
Esempio n. 16
0
 public void AssetsAreSortedByDependency()
 {
     settings.IsDebuggingEnabled = true;
     var pipeline = new StylesheetPipeline(container, settings);
     pipeline.Process(bundle);
     bundle.Assets.SequenceEqual(new[] { asset2.Object, asset1.Object }).ShouldBeTrue();
 }
Esempio n. 17
0
 public StylesheetBundle(string applicationRelativePath)
     : base(applicationRelativePath)
 {
     ContentType = "text/css";
     Processor = new StylesheetPipeline();
 }
 public void CompileLessReturnsTheSamePipeline()
 {
     var pipeline = new StylesheetPipeline();
     var returnedPipeline = pipeline.CompileLess();
     returnedPipeline.ShouldBeSameAs(pipeline);
 }