public void FindBundleContainingPathWithWrongPathReturnsNull() { var collection = new BundleCollection(new CassetteSettings(), Mock.Of <IFileSearchProvider>(), Mock.Of <IBundleFactoryProvider>()) { new TestableBundle("~/test") }; var actualBundle = collection.FindBundlesContainingPath("~/WRONG"); actualBundle.ShouldBeEmpty(); }
public void FindBundleContainingPathOfBundleWherePathIsMissingRootPrefixReturnsTheBundle() { var expectedBundle = new TestableBundle("~/test"); var collection = new BundleCollection(new CassetteSettings(), Mock.Of <IFileSearchProvider>(), Mock.Of <IBundleFactoryProvider>()) { expectedBundle }; var actualBundle = collection.FindBundlesContainingPath("test").First(); actualBundle.ShouldBeSameAs(expectedBundle); }
public void FindBundleContainingPathOfAssetReturnsTheBundle() { var expectedBundle = new TestableBundle("~/test"); var asset = new Mock <IAsset>(); AssetAcceptsVisitor(asset); asset.SetupGet(a => a.Path).Returns("~/test/test.js"); expectedBundle.Assets.Add(asset.Object); var bundles = new BundleCollection(new CassetteSettings(), Mock.Of <IFileSearchProvider>(), Mock.Of <IBundleFactoryProvider>()) { expectedBundle }; var actualBundle = bundles.FindBundlesContainingPath("~/test/test.js").First(); actualBundle.ShouldBeSameAs(expectedBundle); }
IEnumerable <Bundle> GetBundles(string path, Func <Bundle> createExternalBundle) { path = PathUtilities.AppRelative(path); var bundles = allBundles.FindBundlesContainingPath(path).ToArray(); if (bundles.Length == 0 && path.IsUrl()) { var bundle = createExternalBundle(); bundle.Process(settings); bundles = new[] { bundle }; } if (bundles.Length == 0) { throw new ArgumentException("Cannot find an asset bundle containing the path \"" + path + "\"."); } return(bundles); }