예제 #1
0
        public void only_requests_the_plan_once()
        {
            var key1 = new AssetPlanKey(MimeType.Javascript, new string[] { "a.js", "b.js", "c.js" });
            var key2 = new AssetPlanKey(MimeType.Javascript, new string[] { "d.js", "b.js", "c.js" });
            var key3 = new AssetPlanKey(MimeType.Javascript, new string[] { "e.js", "b.js", "c.js" });

            var otherKey = new AssetPlanKey(MimeType.Javascript, key1.Names);

            otherKey.ShouldEqual(key1);

            var plan1 = new AssetTagPlan(MimeType.Javascript);
            var plan2 = new AssetTagPlan(MimeType.Javascript);
            var plan3 = new AssetTagPlan(MimeType.Javascript);

            var planner = MockFor <IAssetTagPlanner>();

            planner.Expect(x => x.BuildPlan(key1)).Return(plan1).Repeat.Once();
            planner.Expect(x => x.BuildPlan(key2)).Return(plan2).Repeat.Once();
            planner.Expect(x => x.BuildPlan(key3)).Return(plan3).Repeat.Once();

            ClassUnderTest.PlanFor(key1.MimeType, key1.Names).ShouldBeTheSameAs(plan1);
            ClassUnderTest.PlanFor(key1.MimeType, key1.Names).ShouldBeTheSameAs(plan1);
            ClassUnderTest.PlanFor(key1.MimeType, key1.Names).ShouldBeTheSameAs(plan1);

            ClassUnderTest.PlanFor(key2.MimeType, key2.Names).ShouldBeTheSameAs(plan2);
            ClassUnderTest.PlanFor(key2.MimeType, key2.Names).ShouldBeTheSameAs(plan2);
            ClassUnderTest.PlanFor(key2.MimeType, key2.Names).ShouldBeTheSameAs(plan2);

            ClassUnderTest.PlanFor(key3.MimeType, key3.Names).ShouldBeTheSameAs(plan3);
            ClassUnderTest.PlanFor(key3.MimeType, key3.Names).ShouldBeTheSameAs(plan3);
            ClassUnderTest.PlanFor(key3.MimeType, key3.Names).ShouldBeTheSameAs(plan3);

            planner.VerifyAllExpectations();
        }
        public void dequeue_all_assets()
        {
            ClassUnderTest.Require("main.css", "a.css", "b.css");
            ClassUnderTest.Require("main.js", "a.js", "b.js");

            ClassUnderTest.DequeueAssetsToRender().OrderBy(x => x.MimeType.Value)
            .ShouldHaveTheSameElementsAs(
                AssetPlanKey.For(MimeType.Javascript, "a.js", "b.js", "main.js"),
                AssetPlanKey.For(MimeType.Css, "a.css", "b.css", "main.css")
                );
        }
예제 #3
0
        public void tags_for_plan_should_pull_the_plan_from_the_cache_before_building()
        {
            var tags    = new HtmlTag[0];
            var key     = AssetPlanKey.For(MimeType.Javascript, "a.js");
            var thePlan = new AssetTagPlan(MimeType.Javascript);

            MockFor <IAssetTagPlanCache>().Stub(x => x.PlanFor(key)).Return(thePlan);
            MockFor <IAssetTagBuilder>().Stub(x => x.Build(thePlan)).Return(tags);

            ClassUnderTest.TagsForPlan(key).ShouldBeTheSameAs(tags);
        }
        public void dequeue_assets_should_record_they_are_rendered()
        {
            ClassUnderTest.Require("jquery.js", "jquery.foo.js", "jquery.bar.js", "jquery.baz.js");
            // Dequeue jquery
            ClassUnderTest.DequeueAssets(MimeType.Javascript, "jquery.js")
            .ShouldHaveTheSameElementsAs(AssetPlanKey.For(MimeType.Javascript, "jquery.js"));

            //Now dequeue all
            ClassUnderTest.Require("jquery.js", "jquery.foo.js", "jquery.bar.js", "jquery.baz.js");

            ClassUnderTest.DequeueAssetsToRender()
            .ShouldHaveTheSameElementsAs(
                AssetPlanKey.For(MimeType.Javascript, "jquery.bar.js", "jquery.baz.js", "jquery.foo.js")
                );
        }
예제 #5
0
 public IEnumerable<HtmlTag> TagsForPlan(AssetPlanKey key)
 {
     var plan = _planCache.PlanFor(key);
     return _builder.Build(plan);
 }
 public AssetTagPlan BuildPlan(AssetPlanKey key)
 {
     return BuildPlan(key.MimeType, key.Names);
 }
예제 #7
0
 public AssetTagPlan PlanFor(AssetPlanKey key)
 {
     return _plans[key];
 }
예제 #8
0
 public AssetTagPlan PlanFor(MimeType mimeType, IEnumerable<string> names)
 {
     var key = new AssetPlanKey(mimeType, names);
     return PlanFor(key);
 }