Example #1
0
        public void GivenAssetWithUnknownDifferentBundleReference_ThenBuildReferencesThrowsAssetReferenceException()
        {
            var bundle = new TestableBundle("~/bundle-1");
            var asset  = new Mock <IAsset>();

            AssetAcceptsVisitor(asset);
            asset.SetupGet(a => a.Path).Returns("bundle-1\\a.js");
            asset.SetupGet(a => a.References)
            .Returns(new[] { new AssetReference(asset.Object.Path, "~\\fail\\fail.js", 0, AssetReferenceType.DifferentBundle) });
            bundle.Assets.Add(asset.Object);
            collection.Add(bundle);

            var exception = Assert.Throws <AssetReferenceException>(delegate
            {
                collection.BuildReferences();
            });

            exception.Message.ShouldEqual("Reference error in \"bundle-1\\a.js\". Cannot find \"~\\fail\\fail.js\".");
        }
 public void Initialize(BundleCollection bundleCollection)
 {
     using (bundleCollection.GetWriteLock())
     {
         bundles = bundleCollection;
         bundles.Clear();
         AddBundles();
         ProcessBundles();
         AddBundlesForUrlReferences();
         bundles.BuildReferences();
     }
 }
Example #3
0
        public void Initialize(BundleCollection bundleCollection)
        {
            using (bundleCollection.GetWriteLock())
            {
                bundles = bundleCollection;
                ClearBundles();
                if (ReadCache())
                {
                    if (IsStaticCache)
                    {
                        Trace.Source.TraceInformation("CacheAwareBundleCollectionInitializer using static cache");
                        UseCachedBundles();
                    }
                    else
                    {
                        AddBundlesFromConfigurations();
                        if (IsCacheValid)
                        {
                            Trace.Source.TraceInformation("CacheAwareBundleCollectionInitializer using runtime cache");
                            UseCachedBundles();
                        }
                        else
                        {
                            Trace.Source.TraceInformation("CacheAwareBundleCollectionInitializer runtime cache is invalid");
                            ProcessBundles();
                            WriteToCache();
                        }
                    }
                }
                else
                {
                    Trace.Source.TraceInformation("CacheAwareBundleCollectionInitializer failed to read from cache");
                    AddBundlesFromConfigurations();
                    ProcessBundles();
                    WriteToCache();
                }

                AddBundlesForUrlReferences();
                bundles.BuildReferences();
            }
        }
Example #4
0
 protected void AddBundles(params Bundle[] bundlesToAdd)
 {
     bundles.AddRange(bundlesToAdd);
     bundles.BuildReferences();
 }