diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ActivatorTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ActivatorTests.cs
index fd3e27da20..dd18dca5ec 100644
--- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ActivatorTests.cs
+++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ActivatorTests.cs
@@ -172,5 +172,28 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
Assert.Equal(typeof(InvalidOperationException).FullName, exception.ExceptionType);
Assert.Equal(expectedMessage, exception.ExceptionMessage);
}
+
+ [Fact]
+ public async Task TagHelperActivation_ActivateHtmlHelper_RendersProperly()
+ {
+ // Arrange
+ var server = TestServer.Create(_provider, _app);
+ var client = server.CreateClient();
+ var expected = "
Activation Test
" +
+ Environment.NewLine +
+ "FakeFakeFake
" +
+ Environment.NewLine +
+ "" +
+ "" +
+ "" +
+ Environment.NewLine +
+ "";
+
+ // Act
+ var body = await client.GetStringAsync("http://localhost/View/UseTagHelper");
+
+ // Assert
+ Assert.Equal(expected, body.Trim());
+ }
}
}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/Controllers/ViewController.cs b/test/WebSites/ActivatorWebSite/Controllers/ViewController.cs
index aa9208c3dd..5957d4b661 100644
--- a/test/WebSites/ActivatorWebSite/Controllers/ViewController.cs
+++ b/test/WebSites/ActivatorWebSite/Controllers/ViewController.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using ActivatorWebSite.Models;
using Microsoft.AspNet.Mvc;
namespace ActivatorWebSite
@@ -44,5 +45,14 @@ namespace ActivatorWebSite
{
return View();
}
+
+ public ViewResult UseTagHelper()
+ {
+ var item = new Item
+ {
+ Name = "Fake"
+ };
+ return View(item);
+ }
}
}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/Models/Item.cs b/test/WebSites/ActivatorWebSite/Models/Item.cs
new file mode 100644
index 0000000000..31b0c7971d
--- /dev/null
+++ b/test/WebSites/ActivatorWebSite/Models/Item.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace ActivatorWebSite.Models
+{
+ public class Item
+ {
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs b/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs
new file mode 100644
index 0000000000..7ae6c102d9
--- /dev/null
+++ b/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs
@@ -0,0 +1,22 @@
+using Microsoft.AspNet.Mvc;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.AspNet.Razor.Runtime.TagHelpers;
+using Microsoft.AspNet.Razor.TagHelpers;
+
+namespace ActivatorWebSite.TagHelpers
+{
+ [HtmlElementName("span")]
+ [ContentBehavior(ContentBehavior.Modify)]
+ public class HiddenTagHelper : TagHelper
+ {
+ public string Name { get; set; }
+
+ [Activate]
+ public IHtmlHelper HtmlHelper { get; set; }
+
+ public override void Process(TagHelperContext context, TagHelperOutput output)
+ {
+ output.Content = HtmlHelper.Hidden(Name, output.Content).ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/TagHelpers/RepeatContentTagHelper.cs b/test/WebSites/ActivatorWebSite/TagHelpers/RepeatContentTagHelper.cs
new file mode 100644
index 0000000000..5cce698c8c
--- /dev/null
+++ b/test/WebSites/ActivatorWebSite/TagHelpers/RepeatContentTagHelper.cs
@@ -0,0 +1,36 @@
+using Microsoft.AspNet.Mvc;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.AspNet.Razor.Runtime.TagHelpers;
+using Microsoft.AspNet.Razor.TagHelpers;
+
+namespace ActivatorWebSite.TagHelpers
+{
+ [HtmlElementName("div")]
+ [ContentBehavior(ContentBehavior.Modify)]
+ public class RepeatContentTagHelper : TagHelper
+ {
+ public int RepeatContent { get; set; }
+
+ public ModelExpression Expression { get; set; }
+
+ [Activate]
+ public IHtmlHelper HtmlHelper { get; set; }
+
+ public override void Process(TagHelperContext context, TagHelperOutput output)
+ {
+ var repeatContent = HtmlHelper.Encode(Expression.Metadata.Model.ToString());
+
+ if (string.IsNullOrEmpty(repeatContent))
+ {
+ repeatContent = output.Content;
+ output.Content = string.Empty;
+ }
+
+ for (int i = 0; i < RepeatContent; i++)
+ {
+ output.Content += repeatContent;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/TagHelpers/TitleTagHelper.cs b/test/WebSites/ActivatorWebSite/TagHelpers/TitleTagHelper.cs
new file mode 100644
index 0000000000..e21f326fc8
--- /dev/null
+++ b/test/WebSites/ActivatorWebSite/TagHelpers/TitleTagHelper.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNet.Mvc;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.AspNet.Razor.Runtime.TagHelpers;
+using Microsoft.AspNet.Razor.TagHelpers;
+
+namespace ActivatorWebSite.TagHelpers
+{
+ [HtmlElementName("body")]
+ [ContentBehavior(ContentBehavior.Prepend)]
+ public class TitleTagHelper : TagHelper
+ {
+ [Activate]
+ public IHtmlHelper HtmlHelper { get; set; }
+
+ [Activate]
+ public ViewContext ViewContext { get; set; }
+
+ public override void Process(TagHelperContext context, TagHelperOutput output)
+ {
+ var builder = new TagBuilder("h2");
+ var title = ViewContext.ViewBag.Title;
+ builder.InnerHtml = HtmlHelper.Encode(title);
+ output.Content = builder.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/WebSites/ActivatorWebSite/Views/View/UseTagHelper.cshtml b/test/WebSites/ActivatorWebSite/Views/View/UseTagHelper.cshtml
new file mode 100644
index 0000000000..f87669fbca
--- /dev/null
+++ b/test/WebSites/ActivatorWebSite/Views/View/UseTagHelper.cshtml
@@ -0,0 +1,13 @@
+@using ActivatorWebSite.Models
+@model Item
+
+@addtaghelper "ActivatorWebSite"
+
+@{
+ ViewBag.Title = "Activation Test";
+}
+
+
+
+test content
+
\ No newline at end of file