public void GivenCachedManifestWithOneBundle_WhenCreateWithMatchingUpToDateBundle_ThenCachedBundleIsReturned()
        {
            var cachedManifest = new CassetteManifest(
                "",
                new[]
            {
                new ScriptBundleManifest
                {
                    Path = "~",
                    Hash = new byte[] { 1, 2, 3 },
                    Html = () => ""
                }
            }
                );

            cache.Setup(c => c.LoadCassetteManifest()).Returns(cachedManifest);

            var urlModifier  = Mock.Of <IUrlModifier>();
            var scriptBundle = new ScriptBundle("~")
            {
                Renderer = new ConstantHtmlRenderer <ScriptBundle>("", urlModifier)
            };
            var factory   = CreateFactory(new[] { scriptBundle });
            var container = factory.CreateBundleContainer();

            var bundle = container.Bundles.Single();

            bundle.Hash.ShouldEqual(new byte[] { 1, 2, 3 });
        }
Beispiel #2
0
 BundleCollection CreateBundles(CassetteManifest cachedManifest, CassetteManifest currentManifest)
 {
     if (CanUseCachedBundles(cachedManifest, currentManifest))
     {
         Trace.Source.TraceInformation("Using cache.");
         return(cachedManifest.CreateBundleCollection(settings));
     }
     else
     {
         return(ProcessAndCacheAndGetRuntimeGeneratedBundles());
     }
 }
Beispiel #3
0
        void CompileTimeManifestWithBundleExists(string rootDirectory)
        {
            var bundle           = StubBundle();
            var bundleManifest   = bundle.CreateBundleManifest(true);
            var cassetteManifest = new CassetteManifest("", new[] { bundleManifest });

            var manifestFilename = PathUtilities.Combine(rootDirectory, "App_Data", "cassette.xml");

            Directory.CreateDirectory(Path.Combine(rootDirectory, "App_Data"));
            using (var outputStream = File.Open(manifestFilename, FileMode.Create, FileAccess.Write))
            {
                var writer = new CassetteManifestWriter(outputStream);
                writer.Write(cassetteManifest);
            }

            configurationSection.PrecompiledManifest = "App_Data/cassette.xml";
        }
Beispiel #4
0
 bool CanUseCachedBundles(CassetteManifest cachedManifest, CassetteManifest currentManifest)
 {
     return(cachedManifest.Equals(currentManifest) &&
            cachedManifest.IsUpToDateWithFileSystem(settings.SourceDirectory));
 }
        void WriteManifest()
        {
            var manifest = new CassetteManifest("", bundles.Select(bundle => bundle.CreateBundleManifest(true)));

            manifestWriter.Write(manifest);
        }