Exemple #1
0
        public void DoesNotRunWhenAllRequiredAttributesAreMissing()
        {
            // Arrange
            var context            = MakeTagHelperContext();
            var output             = MakeTagHelperOutput("link");
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                MakeUrlHelperFactory())
            {
                ViewContext = viewContext,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
            Assert.Empty(output.Attributes);
            Assert.True(output.PostElement.IsEmpty);
        }
Exemple #2
0
        public void RunsWhenRequiredAttributesArePresent_NoHref(
            TagHelperAttributeList attributes,
            Action <LinkTagHelper> setProperties)
        {
            // Arrange
            var context            = MakeTagHelperContext(attributes);
            var output             = MakeTagHelperOutput("link");
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var globbingUrlBuilder = new Mock <GlobbingUrlBuilder>();

            globbingUrlBuilder.Setup(g => g.BuildUrlList(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new[] { "/common.css" });

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                MakeUrlHelperFactory())
            {
                ViewContext        = viewContext,
                GlobbingUrlBuilder = globbingUrlBuilder.Object
            };

            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.True(output.IsContentModified);
            Assert.True(output.PostElement.IsModified);
        }
        public void RunsWhenRequiredAttributesArePresent(
            TagHelperAttributeList attributes,
            Action <LinkTagHelper> setProperties)
        {
            // Arrange
            var context            = MakeTagHelperContext(attributes);
            var output             = MakeTagHelperOutput("link");
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
            };

            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.NotNull(output.Content);
            Assert.True(output.IsContentModified);
        }
        public void DoesNotRunWhenAllRequiredAttributesAreMissing()
        {
            // Arrange
            var context            = MakeTagHelperContext();
            var output             = MakeTagHelperOutput("link");
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
        }
Exemple #5
0
        public void DoesNotRunWhenARequiredAttributeIsMissing(
            IDictionary <string, object> attributes,
            Action <LinkTagHelper> setProperties)
        {
            // Arrange
            var context            = MakeTagHelperContext(attributes);
            var output             = MakeTagHelperOutput("link");
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var helper             = new LinkTagHelper
            {
                Logger             = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext        = viewContext,
                Cache = MakeCache(),
            };

            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
        }
Exemple #6
0
        public void RunsWhenRequiredAttributesArePresent(
            IDictionary <string, object> attributes,
            Action <LinkTagHelper> setProperties)
        {
            // Arrange
            var context            = MakeTagHelperContext(attributes);
            var output             = MakeTagHelperOutput("link");
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var helper             = new LinkTagHelper
            {
                HtmlEncoder        = new HtmlEncoder(),
                JavaScriptEncoder  = new JavaScriptStringEncoder(),
                Logger             = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext        = viewContext,
                Cache = MakeCache()
            };

            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.NotNull(output.Content);
            Assert.True(output.IsContentModified);
        }
Exemple #7
0
        public void Process_HrefDefaultsToTagHelperOutputHrefAttributeAddedByOtherTagHelper(
            string href,
            string hrefOutput,
            string expectedHrefPrefix)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "asp-append-version", true },
            });
            var context          = MakeTagHelperContext(allAttributes);
            var outputAttributes = new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", hrefOutput },
            };
            var output             = MakeTagHelperOutput("link", outputAttributes);
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var urlHelper          = new Mock <IUrlHelper>();

            // Ensure expanded path does not look like an absolute path on Linux, avoiding
            // https://github.com/aspnet/External/issues/21
            urlHelper
            .Setup(urlhelper => urlhelper.Content(It.IsAny <string>()))
            .Returns(new Func <string, string>(url => url.Replace("~/", "virtualRoot/")));
            var urlHelperFactory = new Mock <IUrlHelperFactory>();

            urlHelperFactory
            .Setup(f => f.GetUrlHelper(It.IsAny <ActionContext>()))
            .Returns(urlHelper.Object);

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                urlHelperFactory.Object)
            {
                ViewContext   = viewContext,
                AppendVersion = true,
                Href          = href,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                expectedHrefPrefix + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                (string)output.Attributes["href"].Value,
                StringComparer.Ordinal);
        }
        public void Process_HrefDefaultsToTagHelperOutputHrefAttributeAddedByOtherTagHelper(
            string href,
            string hrefOutput,
            string expectedHrefPrefix)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "asp-append-version", true },
                });
            var context = MakeTagHelperContext(allAttributes);
            var outputAttributes = new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", hrefOutput },
                };
            var output = MakeTagHelperOutput("link", outputAttributes);
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var urlHelper = new Mock<IUrlHelper>();

            // Ensure expanded path does not look like an absolute path on Linux, avoiding
            // https://github.com/aspnet/External/issues/21
            urlHelper
                .Setup(urlhelper => urlhelper.Content(It.IsAny<string>()))
                .Returns(new Func<string, string>(url => url.Replace("~/", "virtualRoot/")));
            var urlHelperFactory = new Mock<IUrlHelperFactory>();
            urlHelperFactory
                .Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>()))
                .Returns(urlHelper.Object);

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                urlHelperFactory.Object)
            {
                ViewContext = viewContext,
                AppendVersion = true,
                Href = href,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                expectedHrefPrefix + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                (string)output.Attributes["href"].Value,
                StringComparer.Ordinal);
        }
Exemple #9
0
        public void HandlesMultipleAttributesSameNameCorrectly(TagHelperAttributeList outputAttributes)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", "test.css" },
                { "asp-fallback-href", "test.css" },
                { "asp-fallback-test-class", "hidden" },
                { "asp-fallback-test-property", "visibility" },
                { "asp-fallback-test-value", "hidden" },
            }));
            var context = MakeTagHelperContext(allAttributes);
            var combinedOutputAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new[]
            {
                new TagHelperAttribute("rel", new HtmlString("stylesheet"))
            }));
            var output             = MakeTagHelperOutput("link", combinedOutputAttributes);
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext          = viewContext,
                FallbackHref         = "test.css",
                FallbackTestClass    = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue    = "hidden",
                Href = "test.css",
            };
            var expectedAttributes = new TagHelperAttributeList(output.Attributes);

            expectedAttributes.Add(new TagHelperAttribute("href", "test.css"));

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(expectedAttributes, output.Attributes);
        }
Exemple #10
0
        public void PreservesOrderOfNonHrefAttributes()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", "test.css" },
                { "data-extra", new HtmlString("something") },
                { "asp-fallback-href", "test.css" },
                { "asp-fallback-test-class", "hidden" },
                { "asp-fallback-test-property", "visibility" },
                { "asp-fallback-test-value", "hidden" },
            });
            var output = MakeTagHelperOutput("link",
                                             attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "data-extra", new HtmlString("something") },
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext          = viewContext,
                FallbackHref         = "test.css",
                FallbackTestClass    = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue    = "hidden",
                Href = "test.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("rel", output.Attributes[0].Name);
            Assert.Equal("href", output.Attributes[1].Name);
            Assert.Equal("data-extra", output.Attributes[2].Name);
        }
Exemple #11
0
        public void RendersLinkTags_GlobbedHref_AddsFileVersion()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", "/css/site.css" },
                { "asp-href-include", "**/*.css" },
                { "asp-append-version", "true" },
            });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var globbingUrlBuilder = new Mock <GlobbingUrlBuilder>();

            globbingUrlBuilder.Setup(g => g.BuildUrlList(null, "**/*.css", null))
            .Returns(new[] { "/base.css" });

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                ViewContext        = viewContext,
                Href          = "/css/site.css",
                HrefInclude   = "**/*.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("link", output.TagName);
            Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value);
            Assert.Equal("<link rel=\"stylesheet\" href=\"HtmlEncode[[/base.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                         output.PostElement.GetContent());
        }
        public void PreservesOrderOfSourceAttributesWhenRun()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "data-extra", new HtmlString("something") },
                { "href", "test.css" },
                { "asp-fallback-href", "test.css" },
                { "asp-fallback-test-class", "hidden" },
                { "asp-fallback-test-property", "visibility" },
                { "asp-fallback-test-value", "hidden" },
            });
            var output = MakeTagHelperOutput("link",
                                             attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "data-extra", new HtmlString("something") },
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext          = viewContext,
                FallbackHref         = "test.css",
                FallbackTestClass    = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue    = "hidden",
                Href = "test.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.StartsWith(
                "<link rel=\"stylesheet\" data-extra=\"something\" href=\"HtmlEncode[[test.css]]\"", output.Content.GetContent());
        }
Exemple #13
0
        public void PreservesOrderOfSourceAttributesWhenRun()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary <string, object>
            {
                ["rel"]                        = new HtmlString("stylesheet"),
                ["data-extra"]                 = new HtmlString("something"),
                ["href"]                       = "test.css",
                ["asp-fallback-href"]          = "test.css",
                ["asp-fallback-test-class"]    = "hidden",
                ["asp-fallback-test-property"] = "visibility",
                ["asp-fallback-test-value"]    = "hidden"
            });
            var output = MakeTagHelperOutput("link",
                                             attributes: new Dictionary <string, object>
            {
                ["rel"]        = new HtmlString("stylesheet"),
                ["data-extra"] = new HtmlString("something"),
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var helper             = new LinkTagHelper
            {
                HtmlEncoder          = new HtmlEncoder(),
                JavaScriptEncoder    = new JavaScriptStringEncoder(),
                Logger               = logger.Object,
                HostingEnvironment   = hostingEnvironment,
                ViewContext          = viewContext,
                FallbackHref         = "test.css",
                FallbackTestClass    = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue    = "hidden",
                Href  = "test.css",
                Cache = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.StartsWith(
                "<link rel=\"stylesheet\" data-extra=\"something\" href=\"test.css\"", output.Content.GetContent());
        }
Exemple #14
0
        public void RendersLinkTagsForGlobbedHrefResults_UsingProvidedEncoder()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                ["rel"]              = "stylesheet",
                ["href"]             = "/css/site.css",
                ["asp-href-include"] = "**/*.css"
            });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                ["rel"] = "stylesheet",
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var globbingUrlBuilder = new Mock <GlobbingUrlBuilder>();

            globbingUrlBuilder.Setup(g => g.BuildUrlList(null, "**/*.css", null))
            .Returns(new[] { "/base.css" });

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                ViewContext        = viewContext,
                Href        = "/css/site.css",
                HrefInclude = "**/*.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("link", output.TagName);
            Assert.Equal("/css/site.css", output.Attributes["href"].Value);
            Assert.Equal("<link rel=\"HtmlEncode[[stylesheet]]\" href=\"HtmlEncode[[/base.css]]\" />",
                         output.PostElement.GetContent());
        }
Exemple #15
0
        public void RendersLinkTags_GlobbedHref_AddsFileVersion()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary <string, object>
            {
                ["rel"]              = new HtmlString("stylesheet"),
                ["href"]             = "/css/site.css",
                ["asp-href-include"] = "**/*.css",
                ["asp-file-version"] = "true"
            });
            var output = MakeTagHelperOutput("link", attributes: new Dictionary <string, object>
            {
                ["rel"] = new HtmlString("stylesheet"),
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var globbingUrlBuilder = new Mock <GlobbingUrlBuilder>();

            globbingUrlBuilder.Setup(g => g.BuildUrlList("/css/site.css", "**/*.css", null))
            .Returns(new[] { "/css/site.css", "/base.css" });
            var helper = new LinkTagHelper
            {
                HtmlEncoder        = new TestHtmlEncoder(),
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                Logger             = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext        = viewContext,
                Href        = "/css/site.css",
                HrefInclude = "**/*.css",
                FileVersion = true,
                Cache       = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />" +
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/base.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
Exemple #16
0
        public void RendersLinkTagsForGlobbedHrefResults_UsingProvidedEncoder()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary <string, object>
            {
                ["rel"]              = "stylesheet",
                ["href"]             = "/css/site.css",
                ["asp-href-include"] = "**/*.css"
            });
            var output = MakeTagHelperOutput("link", attributes: new Dictionary <string, object>
            {
                ["rel"] = "stylesheet",
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();
            var globbingUrlBuilder = new Mock <GlobbingUrlBuilder>();

            globbingUrlBuilder.Setup(g => g.BuildUrlList("/css/site.css", "**/*.css", null))
            .Returns(new[] { "/css/site.css", "/base.css" });
            var helper = new LinkTagHelper
            {
                HtmlEncoder        = new TestHtmlEncoder(),
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                Logger             = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext        = viewContext,
                Href        = "/css/site.css",
                HrefInclude = "**/*.css",
                Cache       = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"HtmlEncode[[stylesheet]]\" href=\"HtmlEncode[[/css/site.css]]\" />" +
                "<link rel=\"HtmlEncode[[stylesheet]]\" href=\"HtmlEncode[[/base.css]]\" />",
                output.Content.GetContent());
        }
        public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", "/bar/css/site.css" },
                { "asp-append-version", "true" },
            });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext("/bar");

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext   = viewContext,
                Href          = "/bar/css/site.css",
                HrefInclude   = "**/*.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
Exemple #18
0
        public void RendersLinkTags_AddsFileVersion()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
                { "href", "/css/site.css" },
                { "asp-append-version", "true" }
            });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext   = viewContext,
                Href          = "/css/site.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("link", output.TagName);
            Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value);
        }
Exemple #19
0
        public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary <string, object>
            {
                ["rel"]              = new HtmlString("stylesheet"),
                ["href"]             = "/bar/css/site.css",
                ["asp-file-version"] = "true"
            });
            var output = MakeTagHelperOutput("link", attributes: new Dictionary <string, object>
            {
                ["rel"] = new HtmlString("stylesheet"),
            });
            var logger             = new Mock <ILogger <LinkTagHelper> >();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext        = MakeViewContext("/bar");
            var helper             = new LinkTagHelper
            {
                HtmlEncoder        = new TestHtmlEncoder(),
                Logger             = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext        = viewContext,
                Href        = "/bar/css/site.css",
                HrefInclude = "**/*.css",
                FileVersion = true,
                Cache       = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
        public void HandlesMultipleAttributesSameNameCorrectly(
            TagHelperAttributeList outputAttributes,
            string expectedAttributeString)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new TagHelperAttributeList
                    {
                        { "rel", new HtmlString("stylesheet") },
                        { "href", "test.css" },
                        { "asp-fallback-href", "test.css" },
                        { "asp-fallback-test-class", "hidden" },
                        { "asp-fallback-test-property", "visibility" },
                        { "asp-fallback-test-value", "hidden" },
                    }));
            var context = MakeTagHelperContext(allAttributes);
            var combinedOutputAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new[]
                    {
                        new TagHelperAttribute("rel", new HtmlString("stylesheet"))
                    }));
            var output = MakeTagHelperOutput("link", combinedOutputAttributes);
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.StartsWith("<link " + expectedAttributeString + " rel=\"stylesheet\"", output.Content.GetContent());
        }
        public void RendersLinkTags_GlobbedHref_AddsFileVersion()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", "/css/site.css" },
                    { "asp-href-include", "**/*.css" },
                    { "asp-append-version", "true" },
                });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
            globbingUrlBuilder.Setup(g => g.BuildUrlList("/css/site.css", "**/*.css", null))
                .Returns(new[] { "/css/site.css", "/base.css" });

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                ViewContext = viewContext,
                Href = "/css/site.css",
                HrefInclude = "**/*.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />" +
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/base.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
        public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", "/bar/css/site.css" },
                    { "asp-append-version", "true" },
                });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext("/bar");

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
                Href = "/bar/css/site.css",
                HrefInclude = "**/*.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
        public void RendersLinkTagsForGlobbedHrefResults_UsingProvidedEncoder()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    ["rel"] = "stylesheet",
                    ["href"] = "/css/site.css",
                    ["asp-href-include"] = "**/*.css"
                });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                ["rel"] = "stylesheet",
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
            globbingUrlBuilder.Setup(g => g.BuildUrlList("/css/site.css", "**/*.css", null))
                .Returns(new[] { "/css/site.css", "/base.css" });

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                ViewContext = viewContext,
                Href = "/css/site.css",
                HrefInclude = "**/*.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"HtmlEncode[[stylesheet]]\" href=\"HtmlEncode[[/css/site.css]]\" />" +
                "<link rel=\"HtmlEncode[[stylesheet]]\" href=\"HtmlEncode[[/base.css]]\" />",
                output.Content.GetContent());
        }
        public void DoesNotRunWhenAllRequiredAttributesAreMissing()
        {
            // Arrange
            var context = MakeTagHelperContext();
            var output = MakeTagHelperOutput("link");
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
        }
        public void PreservesOrderOfSourceAttributesWhenRun()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "data-extra", new HtmlString("something") },
                    { "href", "test.css" },
                    { "asp-fallback-href", "test.css" },
                    { "asp-fallback-test-class", "hidden" },
                    { "asp-fallback-test-property", "visibility" },
                    { "asp-fallback-test-value", "hidden" },
                });
            var output = MakeTagHelperOutput("link",
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "data-extra", new HtmlString("something") },
                });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.StartsWith(
                "<link rel=\"stylesheet\" data-extra=\"something\" href=\"HtmlEncode[[test.css]]\"", output.Content.GetContent());
        }
        public void RunsWhenRequiredAttributesArePresent(
            TagHelperAttributeList attributes,
            Action<LinkTagHelper> setProperties)
        {
            // Arrange
            var context = MakeTagHelperContext(attributes);
            var output = MakeTagHelperOutput("link");
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
            };
            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.NotNull(output.Content);
            Assert.True(output.IsContentModified);
        }
Exemple #27
0
        public void RendersLinkTags_AddsFileVersion()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", "/css/site.css" },
                    { "asp-append-version", "true" }
                });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext = viewContext,
                Href = "/css/site.css",
                AppendVersion = true
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("link", output.TagName);
            Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value);
        }
Exemple #28
0
        public void PreservesOrderOfNonHrefAttributes()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", "test.css" },
                    { "data-extra", new HtmlString("something") },
                    { "asp-fallback-href", "test.css" },
                    { "asp-fallback-test-class", "hidden" },
                    { "asp-fallback-test-property", "visibility" },
                    { "asp-fallback-test-value", "hidden" },
                });
            var output = MakeTagHelperOutput("link",
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "data-extra", new HtmlString("something") },
                });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("rel", output.Attributes[0].Name);
            Assert.Equal("href", output.Attributes[1].Name);
            Assert.Equal("data-extra", output.Attributes[2].Name);
        }
        public void DoesNotRunWhenAllRequiredAttributesAreMissing()
        {
            // Arrange
            var context = MakeTagHelperContext();
            var output = MakeTagHelperOutput("link");
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                MakeUrlHelperFactory())
            {
                ViewContext = viewContext,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
            Assert.Empty(output.Attributes);
            Assert.True(output.PostElement.IsEmpty);
        }
        public void RendersLinkTagsForGlobbedHrefResults()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", "/css/site.css" },
                    { "asp-href-include", "**/*.css" },
                });
            var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
            {
                { "rel", new HtmlString("stylesheet") },
            });
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
            globbingUrlBuilder.Setup(g => g.BuildUrlList(null, "**/*.css", null))
                .Returns(new[] { "/base.css" });

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                MakeUrlHelperFactory())
            {
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                ViewContext = viewContext,
                Href = "/css/site.css",
                HrefInclude = "**/*.css",
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal("link", output.TagName);
            Assert.Equal("/css/site.css", output.Attributes["href"].Value);
            Assert.Equal("<link rel=\"stylesheet\" href=\"HtmlEncode[[/base.css]]\" />", output.PostElement.GetContent());
        }
        public void HandlesMultipleAttributesSameNameCorrectly(TagHelperAttributeList outputAttributes)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new TagHelperAttributeList
                    {
                        { "rel", new HtmlString("stylesheet") },
                        { "href", "test.css" },
                        { "asp-fallback-href", "test.css" },
                        { "asp-fallback-test-class", "hidden" },
                        { "asp-fallback-test-property", "visibility" },
                        { "asp-fallback-test-value", "hidden" },
                    }));
            var context = MakeTagHelperContext(allAttributes);
            var combinedOutputAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new[]
                    {
                        new TagHelperAttribute("rel", new HtmlString("stylesheet"))
                    }));
            var output = MakeTagHelperOutput("link", combinedOutputAttributes);
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                MakeUrlHelperFactory())
            {
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
            };
            var expectedAttributes = new TagHelperAttributeList(output.Attributes);
            expectedAttributes.Add(new TagHelperAttribute("href", "test.css"));

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(expectedAttributes, output.Attributes);
        }
        public void PreservesOrderOfSourceAttributesWhenRun()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary<string, object>
                {
                    ["rel"] = new HtmlString("stylesheet"),
                    ["data-extra"] = new HtmlString("something"),
                    ["href"] = "test.css",
                    ["asp-fallback-href"] = "test.css",
                    ["asp-fallback-test-class"] = "hidden",
                    ["asp-fallback-test-property"] = "visibility",
                    ["asp-fallback-test-value"] = "hidden"
                });
            var output = MakeTagHelperOutput("link",
                attributes: new Dictionary<string, object>
                {
                    ["rel"] = new HtmlString("stylesheet"),
                    ["data-extra"] = new HtmlString("something"),
                });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var helper = new LinkTagHelper
            {
                HtmlEncoder = new HtmlEncoder(),
                JavaScriptEncoder = new JavaScriptStringEncoder(),
                Logger = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
                Cache = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.StartsWith(
                "<link rel=\"stylesheet\" data-extra=\"something\" href=\"test.css\"", output.Content.GetContent());
        }
        public void RunsWhenRequiredAttributesArePresent(
            IDictionary<string, object> attributes,
            Action<LinkTagHelper> setProperties)
        {
            // Arrange
            var context = MakeTagHelperContext(attributes);
            var output = MakeTagHelperOutput("link");
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var helper = new LinkTagHelper
            {
                HtmlEncoder = new HtmlEncoder(),
                JavaScriptEncoder = new JavaScriptStringEncoder(),
                Logger = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext = viewContext,
                Cache = MakeCache()
            };
            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.NotNull(output.Content);
            Assert.True(output.IsContentModified);
        }
        public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary<string, object>
                {
                    ["rel"] = new HtmlString("stylesheet"),
                    ["href"] = "/bar/css/site.css",
                    ["asp-file-version"] = "true"
                });
            var output = MakeTagHelperOutput("link", attributes: new Dictionary<string, object>
            {
                ["rel"] = new HtmlString("stylesheet"),
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext("/bar");
            var helper = new LinkTagHelper
            {
                HtmlEncoder = new TestHtmlEncoder(),
                Logger = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext = viewContext,
                Href = "/bar/css/site.css",
                HrefInclude = "**/*.css",
                FileVersion = true,
                Cache = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"HtmlEncode[[/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\" />",
                output.Content.GetContent());
        }
        public void DoesNotRunWhenARequiredAttributeIsMissing(
            IDictionary<string, object> attributes,
            Action<LinkTagHelper> setProperties)
        {
            // Arrange
            var context = MakeTagHelperContext(attributes);
            var output = MakeTagHelperOutput("link");
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var helper = new LinkTagHelper
            {
                Logger = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext = viewContext,
                Cache = MakeCache(),
            };
            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.NotNull(output.TagName);
            Assert.False(output.IsContentModified);
        }
Exemple #36
0
        public void RunsWhenRequiredAttributesArePresent_NoHref(
            TagHelperAttributeList attributes,
            Action<LinkTagHelper> setProperties)
        {
            // Arrange
            var context = MakeTagHelperContext(attributes);
            var output = MakeTagHelperOutput("link");
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
            globbingUrlBuilder.Setup(g => g.BuildUrlList(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new[] { "/common.css" });

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext = viewContext,
                GlobbingUrlBuilder = globbingUrlBuilder.Object
            };
            setProperties(helper);

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.True(output.IsContentModified);
            Assert.True(output.PostElement.IsModified);
        }
        public void RendersLinkTagsForGlobbedHrefResults()
        {
            // Arrange
            var context = MakeTagHelperContext(
                attributes: new Dictionary<string, object>
                {
                    ["rel"] = new HtmlString("stylesheet"),
                    ["href"] = "/css/site.css",
                    ["asp-href-include"] = "**/*.css"
                });
            var output = MakeTagHelperOutput("link", attributes: new Dictionary<string, object>
            {
                ["rel"] = new HtmlString("stylesheet"),
            });
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
            globbingUrlBuilder.Setup(g => g.BuildUrlList("/css/site.css", "**/*.css", null))
                .Returns(new[] { "/css/site.css", "/base.css" });
            var helper = new LinkTagHelper
            {
                HtmlEncoder = new HtmlEncoder(),
                GlobbingUrlBuilder = globbingUrlBuilder.Object,
                Logger = logger.Object,
                HostingEnvironment = hostingEnvironment,
                ViewContext = viewContext,
                Href = "/css/site.css",
                HrefInclude = "**/*.css",
                Cache = MakeCache(),
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                "<link rel=\"stylesheet\" href=\"/css/site.css\" />" +
                "<link rel=\"stylesheet\" href=\"/base.css\" />",
                output.Content.GetContent());
        }