Ejemplo n.º 1
0
        public void when_writing_a_style_tag()
        {
            MockFor <IMissingAssetHandler>().Stub(x => x.BuildTagsAndRecord(null))
            .Return(new HtmlTag[0])
            .IgnoreArguments();

            MockFor <IUrlRegistry>().Stub(x => x.UrlForAsset(AssetFolder.styles, "main.css"))
            .Return("http://myapp/_content/styles/main.css");

            var file = new AssetFile("main.css", AssetFolder.styles);
            var plan = AssetTagPlan.For(MimeType.Css, file);

            var tag = ClassUnderTest.Build(plan).Single();

            tag.ToString().ShouldEqual("<link href=\"http://myapp/_content/styles/main.css\" rel=\"stylesheet\" type=\"text/css\" />");
        }
Ejemplo n.º 2
0
        public void when_writing_a_script_tag()
        {
            MockFor <IMissingAssetHandler>().Stub(x => x.BuildTagsAndRecord(null))
            .Return(new HtmlTag[0])
            .IgnoreArguments();

            MockFor <IUrlRegistry>().Stub(x => x.UrlForAsset(AssetFolder.scripts, "script.js"))
            .Return("http://myapp/_content/scripts/script.js");

            var file = new AssetFile("script.js", AssetFolder.scripts);
            var plan = AssetTagPlan.For(MimeType.Javascript, file);

            var tag = ClassUnderTest.Build(plan).Single();

            tag.ToString().ShouldEqual("<script type=\"application/javascript\" src=\"http://myapp/_content/scripts/script.js\"></script>");
        }
Ejemplo n.º 3
0
        public void when_writing_a_tag_plan_with_missing_assets()
        {
            var file     = new AssetFile("main.css", AssetFolder.styles);
            var missing1 = new MissingAssetTagSubject("main.css");
            var missing2 = new MissingAssetTagSubject("other.css");
            var plan     = AssetTagPlan.For(MimeType.Css, file, missing1, missing2);

            var handler = new StubMissingAssetHandler();

            Services.Inject <IMissingAssetHandler>(handler);

            var allTags = ClassUnderTest.Build(plan);

            allTags.Count().ShouldEqual(3);

            handler.Subjects.ShouldHaveTheSameElementsAs(missing1, missing2);

            allTags.Contains(handler.Tags.First());
            allTags.Contains(handler.Tags.Last());
        }