示例#1
0
        public void find_combination_in_the_underlying_storage()
        {
            var theCache     = new AssetCombinationCache();
            var scriptCombo1 = new ScriptFileCombination("script1", files(5));

            theCache.StoreCombination(MimeType.Javascript, scriptCombo1);
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script2", files(6)));
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script3", files(7)));
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script4", files(4)));


            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css1", null, files(10)));
            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css2", null, files(8)));
            var cssCombo3 = new StyleFileCombination("css3", null, files(12));

            theCache.StoreCombination(MimeType.Css, cssCombo3);
            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css4", null, files(15)));


            theCache.FindCombination("script1").ShouldBeTheSameAs(scriptCombo1);
            theCache.FindCombination("css3").ShouldBeTheSameAs(cssCombo3);


            theCache.FindCombination("something that does not exist").ShouldBeNull();
        }
        protected override void beforeEach()
        {
            theGraph = new AssetGraph();
            Services.Inject(theGraph);

            theCache = new AssetCombinationCache();
            Services.Inject <IAssetCombinationCache>(theCache);

            Services.Inject <IAssetFileGraph>(new StubAssetFileGraph());

            theGraph.AddToCombination("combo1", "a.js");
            theGraph.AddToCombination("combo1", "b.js");
            theGraph.AddToCombination("combo1", "c.js");

            theGraph.AddToCombination("combo2", "a.js");
            theGraph.AddToCombination("combo2", "b.js");

            ClassUnderTest.Activate(new IPackageInfo[0], MockFor <IPackageLog>());
        }
示例#3
0
        public void add_candidates_and_retrieve_by_mime_type()
        {
            var theCache = new AssetCombinationCache();

            theCache.AddFilesToCandidate(MimeType.Javascript, "js1", files(5));
            theCache.AddFilesToCandidate(MimeType.Javascript, "js2", files(6));
            theCache.AddFilesToCandidate(MimeType.Javascript, "js3", files(3));

            theCache.AddFilesToCandidate(MimeType.Css, "css1", files(3));
            theCache.AddFilesToCandidate(MimeType.Css, "css2", files(5));
            theCache.AddFilesToCandidate(MimeType.Css, "css3", files(2));

            theCache.OrderedCombinationCandidatesFor(MimeType.Javascript)
            .Select(x => x.Name)
            .ShouldHaveTheSameElementsAs("js2", "js1", "js3");

            theCache.OrderedCombinationCandidatesFor(MimeType.Css)
            .Select(x => x.Name)
            .ShouldHaveTheSameElementsAs("css2", "css1", "css3");
        }
示例#4
0
        public void store_combinations_and_pull_out_in_order_by_size()
        {
            var theCache = new AssetCombinationCache();

            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script1", files(5)));
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script2", files(6)));
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script3", files(7)));
            theCache.StoreCombination(MimeType.Javascript, new ScriptFileCombination("script4", files(4)));


            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css1", null, files(10)));
            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css2", null, files(8)));
            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css3", null, files(12)));
            theCache.StoreCombination(MimeType.Css, new StyleFileCombination("css4", null, files(15)));

            theCache.OrderedListOfCombinations(MimeType.Javascript).Select(x => x.Name)
            .ShouldHaveTheSameElementsAs("script3", "script2", "script1", "script4");

            theCache.OrderedListOfCombinations(MimeType.Css).Select(x => x.Name)
            .ShouldHaveTheSameElementsAs("css4", "css3", "css1", "css2");
        }
示例#5
0
        public ContentPlan BuildPlan()
        {
            var library      = new TransformerPolicyLibrary(_policies);
            var combinations = new AssetCombinationCache();

            if (_combination != null)
            {
                combinations.StoreCombination(_combination.MimeType, _combination);
            }

            var pipeline = new AssetPipeline();

            _files.Each(f =>
            {
                var path = new AssetPath(AssetPipeline.Application, f.Name, f.Folder);
                pipeline.AddFile(path, f);
            });

            var planner = new ContentPlanner(combinations, pipeline, library);

            return(planner.BuildPlanFor(_name));
        }