本文整理汇总了C#中TagHelperAttributeList.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperAttributeList.Concat方法的具体用法?C# TagHelperAttributeList.Concat怎么用?C# TagHelperAttributeList.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagHelperAttributeList
的用法示例。
在下文中一共展示了TagHelperAttributeList.Concat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlesMultipleAttributesSameNameCorrectly
public async Task HandlesMultipleAttributesSameNameCorrectly(
TagHelperAttributeList outputAttributes,
string expectedAttributeString)
{
// Arrange
var allAttributes = new TagHelperAttributeList(
outputAttributes.Concat(
new TagHelperAttributeList
{
["data-extra"] = "something",
["src"] = "/blank.js",
["asp-fallback-src"] = "http://www.example.com/blank.js",
["asp-fallback-test"] = "isavailable()",
}));
var tagHelperContext = MakeTagHelperContext(allAttributes);
var viewContext = MakeViewContext();
var combinedOutputAttributes = new TagHelperAttributeList(
outputAttributes.Concat(
new[]
{
new TagHelperAttribute("data-extra", new HtmlString("something"))
}));
var output = MakeTagHelperOutput("script", combinedOutputAttributes);
var hostingEnvironment = MakeHostingEnvironment();
var helper = new ScriptTagHelper(
CreateLogger(),
hostingEnvironment,
MakeCache(),
new CommonTestEncoder(),
new CommonTestEncoder())
{
ViewContext = viewContext,
FallbackSrc = "~/blank.js",
FallbackTestExpression = "http://www.example.com/blank.js",
Src = "/blank.js",
};
// Act
await helper.ProcessAsync(tagHelperContext, output);
// Assert
Assert.StartsWith(
"<script " + expectedAttributeString + " data-extra=\"something\" " +
"src=\"HtmlEncode[[/blank.js]]\"",
output.Content.GetContent());
}
示例2: HandlesMultipleAttributesSameNameCorrectly
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());
}
示例3: HandlesMultipleAttributesSameNameCorrectly
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);
}
示例4: HandlesMultipleAttributesSameNameCorrectly
public async Task HandlesMultipleAttributesSameNameCorrectly(TagHelperAttributeList outputAttributes)
{
// Arrange
var allAttributes = new TagHelperAttributeList(
outputAttributes.Concat(
new TagHelperAttributeList
{
["data-extra"] = "something",
["src"] = "/blank.js",
["asp-fallback-src"] = "http://www.example.com/blank.js",
["asp-fallback-test"] = "isavailable()",
}));
var tagHelperContext = MakeTagHelperContext(allAttributes);
var viewContext = MakeViewContext();
var combinedOutputAttributes = new TagHelperAttributeList(
outputAttributes.Concat(
new[]
{
new TagHelperAttribute("data-extra", new HtmlString("something"))
}));
var output = MakeTagHelperOutput("script", combinedOutputAttributes);
var hostingEnvironment = MakeHostingEnvironment();
var helper = new ScriptTagHelper(
hostingEnvironment,
MakeCache(),
new HtmlTestEncoder(),
new JavaScriptTestEncoder(),
MakeUrlHelperFactory())
{
ViewContext = viewContext,
FallbackSrc = "~/blank.js",
FallbackTestExpression = "http://www.example.com/blank.js",
Src = "/blank.js",
};
var expectedAttributes = new TagHelperAttributeList(output.Attributes);
expectedAttributes.Add(new TagHelperAttribute("src", "/blank.js"));
// Act
await helper.ProcessAsync(tagHelperContext, output);
// Assert
Assert.Equal(expectedAttributes, output.Attributes);
}