Esempio n. 1
0
        public void BundlesOfDifferentTypesAreNotEqual()
        {
            Bundle bundle1 = new ScriptBundle("~");
            Bundle bundle2 = new StylesheetBundle("~");

            bundle1.Equals(bundle2).ShouldBeFalse();
        }
Esempio n. 2
0
        static StylesheetBundle StubStylesheetBundle(string path)
        {
            var bundle = new StylesheetBundle(path);
            var asset  = new Mock <IAsset>();

            asset.SetupGet(a => a.Hash).Returns(new byte[] { 1, 2, 3 });
            bundle.Assets.Add(asset.Object);
            return(bundle);
        }
Esempio n. 3
0
        static StylesheetBundle StubStylesheetBundle(string path)
        {
            var bundle = new StylesheetBundle(path)
            {
                Hash = new byte[] { 1, 2, 3 }
            };

            return(bundle);
        }
Esempio n. 4
0
        public void GivenTwoBundlesWithSamePathButDifferentType_WhenReferenceThePath_ThenBothBundlesAreReferenced()
        {
            var bundle1 = new ScriptBundle("~/test");
            var bundle2 = new StylesheetBundle("~/test");

            AddBundles(bundle1, bundle2);

            builder.Reference("~/test");
            builder.GetBundles(null).Count().ShouldEqual(2);
        }
 public StylesheetBundleManifest_Tests()
 {
     manifest = new StylesheetBundleManifest
     {
         Path = "~",
         Hash = new byte[0],
         Media = "MEDIA"
     };
     createdBundle = (StylesheetBundle)manifest.CreateBundle();
 }
Esempio n. 6
0
        public void GivenTwoBundlesWithSamePathButDifferentType_WhenReferenceThePath_ThenBothBundlesAreReferenced()
        {
            var bundle1 = new ScriptBundle("~/test");
            var bundle2 = new StylesheetBundle("~/test");

            bundleContainer.Setup(c => c.FindBundlesContainingPath("~/test"))
            .Returns(new Bundle[] { bundle1, bundle2 });

            builder.Reference("~/test");
            builder.GetBundles(null).Count().ShouldEqual(2);
        }
        public void ManifestMediaEqualsBundleMedia()
        {
            var bundle = new StylesheetBundle("~")
            {
                Media = "MEDIA-VALUE"
            };

            var builder  = new StylesheetBundleManifestBuilder();
            var manifest = builder.BuildManifest(bundle);

            manifest.Media.ShouldEqual(bundle.Media);
        }
        public void ManifestConditionEqualsBundleCondition()
        {
            var bundle = new StylesheetBundle("~")
            {
                Condition = "CONDITION"
            };

            var builder  = new StylesheetBundleManifestBuilder();
            var manifest = builder.BuildManifest(bundle);

            manifest.Condition.ShouldEqual(bundle.Condition);
        }
Esempio n. 9
0
        static StylesheetBundle CreateStylesheetBundle()
        {
            var bundle = new StylesheetBundle("~");
            var asset  = new StubAsset(
                "~/asset.css",
                ".a { background-image:url(image-a.png);background-repeat:no-repeat;width:20px;height:20px }\n" +
                ".b { background-image:url(image-b.png);background-repeat:no-repeat;width:20px;height:20px }"
                );

            bundle.Assets.Add(asset);
            return(bundle);
        }
Esempio n. 10
0
        public SpritingIntegrationTest()
        {
            container = CreateContainer();
            cache     = new TempDirectory();
            InitDirectories();

            bundle = CreateStylesheetBundle();

            // SpriteImages expects image URLs to be expanded into absolute Cassette file URLs.
            ExpandUrls(bundle);
            SpriteImages(bundle);
        }
Esempio n. 11
0
 public StylesheetBundleManifest_Tests()
 {
     settings = new CassetteSettings("");
     manifest = new StylesheetBundleManifest
     {
         Path  = "~",
         Hash  = new byte[0],
         Media = "MEDIA",
         Html  = () => "EXPECTED-HTML"
     };
     createdBundle = (StylesheetBundle)manifest.CreateBundle(settings);
 }
        public void ManifestMediaEqualsBundleMedia()
        {
            var bundle = new StylesheetBundle("~")
            {
                Media = "MEDIA-VALUE"
            };

            var builder = new StylesheetBundleManifestBuilder();
            var manifest = builder.BuildManifest(bundle);

            manifest.Media.ShouldEqual(bundle.Media);
        }
        public void ManifestConditionEqualsBundleCondition()
        {
            var bundle = new StylesheetBundle("~")
            {
                Condition = "CONDITION"
            };

            var builder = new StylesheetBundleManifestBuilder();
            var manifest = builder.BuildManifest(bundle);

            manifest.Condition.ShouldEqual(bundle.Condition);
        }
Esempio n. 14
0
 object StylesheetData(StylesheetBundle stylesheet)
 {
     return(new
     {
         stylesheet.Path,
         Url = BundleUrl(stylesheet),
         stylesheet.Media,
         stylesheet.Condition,
         Assets = AssetPaths(stylesheet),
         stylesheet.References,
         Size = BundleSize(stylesheet)
     });
 }
Esempio n. 15
0
        public void Configure(BundleCollection bundles, CassetteSettings settings)
        {
            var script = new ScriptBundle("cassette.web.jasmine");

            script.Processor = new ScriptPipeline();
            script.Assets.Add(new ResourceAsset("Cassette.Web.Jasmine.jasmine.js", GetType().Assembly));
            bundles.Add(script);

            var css = new StylesheetBundle("cassette.web.jasmine");

            css.Processor = new StylesheetPipeline();
            css.Assets.Add(new ResourceAsset("Cassette.Web.Jasmine.jasmine.css", GetType().Assembly));
            bundles.Add(css);
        }
Esempio n. 16
0
        object StylesheetData(StylesheetBundle stylesheet, IUrlGenerator urlGenerator)
        {
            var external = stylesheet as ExternalStylesheetBundle;

            return(new
            {
                stylesheet.Path,
                Url = external == null?urlGenerator.CreateBundleUrl(stylesheet) : external.Url,
                          stylesheet.Media,
                          stylesheet.Condition,
                          Assets = AssetPaths(stylesheet, urlGenerator),
                          stylesheet.References,
                          Size = BundleSize(stylesheet)
            });
        }
        public void SpriteImagesAddsSpriteImagesBundleProcessorToEndOfPipeline()
        {
            var       pipeline      = new Mock <IBundlePipeline <StylesheetBundle> >();
            const int endOfPipeline = 42;

            pipeline.SetupGet(p => p.Count).Returns(endOfPipeline);
            var bundle = new StylesheetBundle("~")
            {
                Pipeline = pipeline.Object
            };

            bundle.SpriteImages();

            pipeline.Verify(p => p.Insert <SpriteImages>(endOfPipeline));
        }
        public void WhenSortDifferentTypesOfBundle_ThenSortsArePartitioned()
        {
            var bundleA = new ScriptBundle("~/a");
            var bundleB = new StylesheetBundle("~/b");
            var bundleC = new ScriptBundle("~/c");

            var bundles = new Bundle[] { bundleA, bundleB, bundleC };
            var collection = CreateBundleCollection(bundles);
            collection.BuildReferences();
            var sorted = collection.SortBundles(bundles);

            sorted.ShouldEqual(new Bundle[]
            {
                bundleA,
                bundleC,
                bundleB
            });
        }
        public void WhenInterdependenciesBetweenBundlesOfDifferentType_DoesNotDuplicateBundles()
        {
            var bundleA = new ScriptBundle("~/a");
            var bundleB = new StylesheetBundle("~/b");
            var bundleC = new TestableBundle("~/c");
            bundleC.AddReference("~/a");

            var bundles = new Bundle[] { bundleA, bundleB, bundleC };
            var collection = CreateBundleCollection(bundles);
            collection.BuildReferences();
            var sorted = collection.SortBundles(bundles).ToArray();

            sorted.ShouldEqual(new Bundle[]
            {
                bundleB,
                bundleA,
                bundleC
            });
        }
Esempio n. 20
0
        public void DontSpriteWhenDebugging()
        {
            var bundle = new StylesheetBundle("~");
            var asset  = new StubAsset(
                "~/asset.css",
                ".a { background-image:url(image-a.png);width:20px;height:20px }\n" +
                ".b { background-image:url(image-b.png);width:20px;height:20px }"
                );

            bundle.Assets.Add(asset);

            var settings = new CassetteSettings
            {
                IsDebuggingEnabled = true,
                CacheDirectory     = new FakeFileSystem()
            };

            var processor = new SpriteImages(settings, () => null);

            processor.Process(bundle);
            // Would throw exception if it tried to sprite the CSS.
        }
Esempio n. 21
0
 public static void SpriteImages(this StylesheetBundle bundle)
 {
     bundle.Pipeline.Insert <SpriteImages>(bundle.Pipeline.Count);
 }
Esempio n. 22
0
 void ExpandUrls(StylesheetBundle bundle)
 {
     container.Resolve <ExpandCssUrls>().Process(bundle);
 }
Esempio n. 23
0
        void SpriteImages(StylesheetBundle bundle)
        {
            var processor = container.Resolve <SpriteImages>();

            processor.Process(bundle);
        }