public void CompileLessReturnsTheSamePipeline()
        {
            var pipeline         = new StylesheetPipeline();
            var returnedPipeline = pipeline.CompileLess();

            returnedPipeline.ShouldBeSameAs(pipeline);
        }
Exemple #2
0
        public void CssReferencesAreParsed()
        {
            var pipeline = new StylesheetPipeline(container, settings);

            pipeline.Process(bundle);
            asset1.Verify(a => a.AddReference("asset2.css", 1));
        }
Exemple #3
0
        public void AssetsAreConcatenated()
        {
            var pipeline = new StylesheetPipeline(container, settings);

            pipeline.Process(bundle);

            bundle.Assets.Count.ShouldEqual(1);
        }
Exemple #4
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();
        }
Exemple #5
0
 public StylesheetPipelineWithSassCompilation()
 {
     asset = new Mock <IAsset>();
     asset.SetupGet(a => a.SourceFile.FullPath).Returns("asset.scss");
     asset.Setup(a => a.OpenStream()).Returns(() => "// @reference 'other.scss';".AsStream());
     bundle.Assets.Add(asset.Object);
     pipeline = new StylesheetPipeline().CompileSass();
 }
 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();
     pipeline.CompileLess = true;
 }
Exemple #7
0
        public void WhenProcessBundle_ThenHashIsAssigned()
        {
            var pipeline = new StylesheetPipeline();
            var bundle   = new StylesheetBundle("~");

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

            bundle.Hash.ShouldNotBeNull();
        }
Exemple #8
0
        public void WhenProcessBundle_ThenHashIsAssigned()
        {
            var bundle = new StylesheetBundle("~");

            var pipeline = new StylesheetPipeline(container, settings);

            pipeline.Process(bundle);

            bundle.Hash.ShouldNotBeNull();
        }
Exemple #9
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)
                                                     ));
        }
        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 void AssetsAreMinified()
        {
            var pipeline = new StylesheetPipeline();

            pipeline.Process(bundle, settings);

            using (var reader = new StreamReader(bundle.Assets[0].OpenStream()))
            {
                reader.ReadToEnd().ShouldEqual("p{color:#fff}");
            }
        }
        public StylesheetBundleExtensions_Tests()
        {
            var container = new TinyIoCContainer();
            var settings  = new CassetteSettings();

            container.Register(Mock.Of <IStylesheetMinifier>());
            container.Register(Mock.Of <IUrlGenerator>());
            container.Register(settings);
            pipeline = new StylesheetPipeline(container, settings);
            bundle   = new StylesheetBundle("~")
            {
                Pipeline = pipeline
            };
        }
Exemple #13
0
        public void GivenConvertImageUrlsToDataUrisIsFalse_WhenProcessBundle_ThenLessAssetHasNoDataUriTransformAdded()
        {
            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);

            pipeline.Process(bundle);

            asset.Verify(a => a.AddAssetTransformer(It.Is <IAssetTransformer>(t => t is CssImageToDataUriTransformer)), Times.Never());
        }
Exemple #14
0
        public void GivenCompileSassIsFalse_WhenProcessBundle_ThenSassAssetHasNoCompileAssetTransformAdded()
        {
            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();

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

            asset.Verify(a => a.AddAssetTransformer(It.Is <IAssetTransformer>(t => t is CompileAsset)), Times.Never());
        }
        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);
        }
        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)));
        }
Exemple #17
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)));
        }
Exemple #18
0
 public static StylesheetPipeline EmbedImages(this StylesheetPipeline pipeline)
 {
     return(pipeline.EmbedImages(url => true));
 }
Exemple #19
0
 public static StylesheetPipeline EmbedFonts(this StylesheetPipeline pipeline, Func <string, bool> shouldEmbedUrl)
 {
     pipeline.InsertBefore <ExpandCssUrls>(new ConvertFontUrlsToDataUris(shouldEmbedUrl));
     return(pipeline);
 }
Exemple #20
0
 public static StylesheetPipeline EmbedFonts(this StylesheetPipeline pipeline)
 {
     pipeline.InsertBefore <ExpandCssUrls>(new ConvertFontUrlsToDataUris());
     return(pipeline);
 }
Exemple #21
0
 public StylesheetBundle(string applicationRelativePath)
     : base(applicationRelativePath)
 {
     ContentType = "text/css";
     Processor   = new StylesheetPipeline();
 }