public void BundlesOfDifferentTypesAreNotEqual() { Bundle bundle1 = new ScriptBundle("~"); Bundle bundle2 = new StylesheetBundle("~"); bundle1.Equals(bundle2).ShouldBeFalse(); }
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); }
static StylesheetBundle StubStylesheetBundle(string path) { var bundle = new StylesheetBundle(path) { Hash = new byte[] { 1, 2, 3 } }; return(bundle); }
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(); }
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); }
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); }
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); }
public StylesheetBundleManifest_Tests() { settings = new CassetteSettings(""); manifest = new StylesheetBundleManifest { Path = "~", Hash = new byte[0], Media = "MEDIA", Html = () => "EXPECTED-HTML" }; createdBundle = (StylesheetBundle)manifest.CreateBundle(settings); }
object StylesheetData(StylesheetBundle stylesheet) { return(new { stylesheet.Path, Url = BundleUrl(stylesheet), stylesheet.Media, stylesheet.Condition, Assets = AssetPaths(stylesheet), stylesheet.References, Size = BundleSize(stylesheet) }); }
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); }
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 }); }
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. }
public static void SpriteImages(this StylesheetBundle bundle) { bundle.Pipeline.Insert <SpriteImages>(bundle.Pipeline.Count); }
void ExpandUrls(StylesheetBundle bundle) { container.Resolve <ExpandCssUrls>().Process(bundle); }
void SpriteImages(StylesheetBundle bundle) { var processor = container.Resolve <SpriteImages>(); processor.Process(bundle); }