Add tests to account for aspnet/Razor#220.
- Added unit and functional test.
This commit is contained in:
parent
247625dcab
commit
12e4307f3a
|
|
@ -35,7 +35,7 @@
|
||||||
<h3 style="font-family: cursive;">Current Tag Cloud from Tag Helper</h3>
|
<h3 style="font-family: cursive;">Current Tag Cloud from Tag Helper</h3>
|
||||||
<div>["Lorem","ipsum","dolor","sit","amet","consectetur","adipisicing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliquaUt","enim"]</div>
|
<div>["Lorem","ipsum","dolor","sit","amet","consectetur","adipisicing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliquaUt","enim"]</div>
|
||||||
<h3 style="font-family: cursive;">Current Tag Cloud from ViewComponentHelper:</h3>
|
<h3 style="font-family: cursive;">Current Tag Cloud from ViewComponentHelper:</h3>
|
||||||
<section>["Lorem","ipsum","dolor","sit","amet","consectetur","adipisicing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore"]</section>
|
<section><b>["Lorem","ipsum","dolor","sit","amet","consectetur","adipisicing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore"]</b></section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
public void IsSectionDefined_ThrowsIfPreviousSectionWritersIsNotRegistered()
|
public void IsSectionDefined_ThrowsIfPreviousSectionWritersIsNotRegistered()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var page = CreatePage(v =>
|
var page = CreatePage(v =>
|
||||||
{
|
{
|
||||||
v.Path = "/Views/TestPath/Test.cshtml";
|
v.Path = "/Views/TestPath/Test.cshtml";
|
||||||
});
|
});
|
||||||
|
|
@ -804,6 +804,89 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
postElement: null),
|
postElement: null),
|
||||||
"<p test=\"HtmlEncode[[testVal]]\" something=\"HtmlEncode[[ spaced ]]\">Hello World!</p>"
|
"<p test=\"HtmlEncode[[testVal]]\" something=\"HtmlEncode[[ spaced ]]\">Hello World!</p>"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
GetTagHelperOutput(
|
||||||
|
tagName: "p",
|
||||||
|
attributes: new TagHelperAttributeList()
|
||||||
|
{
|
||||||
|
["test"] = new TagHelperAttribute
|
||||||
|
{
|
||||||
|
Name = "test",
|
||||||
|
Minimized = true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selfClosing: false,
|
||||||
|
preElement: null,
|
||||||
|
preContent: null,
|
||||||
|
content: "Hello World!",
|
||||||
|
postContent: null,
|
||||||
|
postElement: null),
|
||||||
|
"<p test>Hello World!</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
GetTagHelperOutput(
|
||||||
|
tagName: "p",
|
||||||
|
attributes: new TagHelperAttributeList()
|
||||||
|
{
|
||||||
|
["test"] = new TagHelperAttribute
|
||||||
|
{
|
||||||
|
Name = "test",
|
||||||
|
Minimized = true
|
||||||
|
},
|
||||||
|
["test2"] = new TagHelperAttribute
|
||||||
|
{
|
||||||
|
Name = "test2",
|
||||||
|
Minimized = true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selfClosing: false,
|
||||||
|
preElement: null,
|
||||||
|
preContent: null,
|
||||||
|
content: "Hello World!",
|
||||||
|
postContent: null,
|
||||||
|
postElement: null),
|
||||||
|
"<p test test2>Hello World!</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
GetTagHelperOutput(
|
||||||
|
tagName: "p",
|
||||||
|
attributes: new TagHelperAttributeList()
|
||||||
|
{
|
||||||
|
["first"] = "unminimized",
|
||||||
|
["test"] = new TagHelperAttribute
|
||||||
|
{
|
||||||
|
Name = "test",
|
||||||
|
Minimized = true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selfClosing: false,
|
||||||
|
preElement: null,
|
||||||
|
preContent: null,
|
||||||
|
content: "Hello World!",
|
||||||
|
postContent: null,
|
||||||
|
postElement: null),
|
||||||
|
"<p first=\"HtmlEncode[[unminimized]]\" test>Hello World!</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
GetTagHelperOutput(
|
||||||
|
tagName: "p",
|
||||||
|
attributes: new TagHelperAttributeList()
|
||||||
|
{
|
||||||
|
["test"] = new TagHelperAttribute
|
||||||
|
{
|
||||||
|
Name = "test",
|
||||||
|
Minimized = true
|
||||||
|
},
|
||||||
|
["last"] = "unminimized",
|
||||||
|
},
|
||||||
|
selfClosing: false,
|
||||||
|
preElement: null,
|
||||||
|
preContent: null,
|
||||||
|
content: "Hello World!",
|
||||||
|
postContent: null,
|
||||||
|
postElement: null),
|
||||||
|
"<p test last=\"HtmlEncode[[unminimized]]\">Hello World!</p>"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
GetTagHelperOutput(
|
GetTagHelperOutput(
|
||||||
tagName: "p",
|
tagName: "p",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||||
|
|
||||||
|
namespace TagHelpersWebSite.TagHelpers
|
||||||
|
{
|
||||||
|
[TargetElement(Attributes = "bold")]
|
||||||
|
public class BoldTagHelper : TagHelper
|
||||||
|
{
|
||||||
|
public override int Order
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return int.MinValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||||
|
{
|
||||||
|
output.Attributes.RemoveAll("bold");
|
||||||
|
output.PreContent.SetContent("<b>");
|
||||||
|
output.PostContent.SetContent("</b>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,9 +24,9 @@
|
||||||
<h3>Current Tag Cloud from Tag Helper</h3>
|
<h3>Current Tag Cloud from Tag Helper</h3>
|
||||||
<tag-cloud count="Model.TagsToShow" surround="div" />
|
<tag-cloud count="Model.TagsToShow" surround="div" />
|
||||||
<h3>Current Tag Cloud from ViewComponentHelper:</h3>
|
<h3>Current Tag Cloud from ViewComponentHelper:</h3>
|
||||||
<section>@await Component.InvokeAsync("Tags", 15)</section>
|
<section bold>@await Component.InvokeAsync("Tags", 15)</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section footerContent {
|
@section footerContent {
|
||||||
<p condition="Model.Approved" surround="section">© @Model.CopyrightYear - My ASP.NET Application</p>
|
<p condition="Model.Approved" bold surround="section">© @Model.CopyrightYear - My ASP.NET Application</p>
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue