本文整理汇总了C#中Microsoft.AspNetCore.Razor.TagHelpers.DefaultTagHelperContent.GetContent方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultTagHelperContent.GetContent方法的具体用法?C# DefaultTagHelperContent.GetContent怎么用?C# DefaultTagHelperContent.GetContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNetCore.Razor.TagHelpers.DefaultTagHelperContent
的用法示例。
在下文中一共展示了DefaultTagHelperContent.GetContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetHtmlContent_TextIsNotFurtherEncoded
public void SetHtmlContent_TextIsNotFurtherEncoded()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
// Act
tagHelperContent.SetHtmlContent("Hi");
// Assert
Assert.Equal("Hi", tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例2: SetHtmlContent_ClearsExistingContent
public void SetHtmlContent_ClearsExistingContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
tagHelperContent.AppendHtml("Contoso");
// Act
tagHelperContent.SetHtmlContent("Hello World!");
// Assert
Assert.Equal("Hello World!", tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例3: Reset_ClearsTheExpectedFields
public void Reset_ClearsTheExpectedFields()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
tagHelperContent.SetContent("hello world");
// Act
tagHelperContent.Reinitialize();
Assert.False(tagHelperContent.IsModified);
Assert.Equal(string.Empty, tagHelperContent.GetContent());
}
示例4: CanSetContent
public void CanSetContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var expected = "HtmlEncode[[Hello World!]]";
// Act
tagHelperContent.SetContent("Hello World!");
// Assert
Assert.Equal(expected, tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例5: SetHtmlContent_WithTagHelperContent_WorksAsExpected
public void SetHtmlContent_WithTagHelperContent_WorksAsExpected(string content, string expected)
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var copiedTagHelperContent = new DefaultTagHelperContent();
tagHelperContent.SetContent(content);
// Act
copiedTagHelperContent.SetHtmlContent(tagHelperContent);
// Assert
Assert.Equal(expected, copiedTagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例6: Fluent_Clear_Set_Append_WritesExpectedContent
public void Fluent_Clear_Set_Append_WritesExpectedContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var expected = "HtmlEncode[[Hello ]]HtmlEncode[[World!]]";
tagHelperContent.SetContent("Some Random Content");
// Act
tagHelperContent.Clear().SetContent("Hello ").Append("World!");
// Assert
Assert.Equal(expected, tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例7: Fluent_SetContent_AppendFormat_Append_WritesExpectedContent
public void Fluent_SetContent_AppendFormat_Append_WritesExpectedContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var expected = "HtmlEncode[[First ]]HtmlEncode[[Second]] Third HtmlEncode[[Fourth]]";
// Act
tagHelperContent
.SetContent("First ")
.AppendFormat("{0} Third ", "Second")
.Append("Fourth");
// Assert
Assert.Equal(expected, tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例8: IsEmptyOrWhiteSpace_TrueAfterClear
public void IsEmptyOrWhiteSpace_TrueAfterClear()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
// Act
tagHelperContent.Clear();
// Assert
Assert.Equal(string.Empty, tagHelperContent.GetContent());
Assert.True(tagHelperContent.IsEmptyOrWhiteSpace);
}
示例9: CanIdentifyWhiteSpace_WithoutIgnoringStrings
public void CanIdentifyWhiteSpace_WithoutIgnoringStrings()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
// Act
tagHelperContent.SetContent(" ");
tagHelperContent.Append("Hello");
// Assert
Assert.True(tagHelperContent.GetContent().Length > 0);
Assert.False(tagHelperContent.IsEmptyOrWhiteSpace);
}
示例10: Append_WithTagHelperContent_MultipleAppends
public void Append_WithTagHelperContent_MultipleAppends()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var copiedTagHelperContent = new DefaultTagHelperContent();
var text1 = "Hello";
var text2 = " World!";
var expected = "HtmlEncode[[Hello]]HtmlEncode[[ World!]]";
tagHelperContent.Append(text1);
tagHelperContent.Append(text2);
// Act
copiedTagHelperContent.AppendHtml(tagHelperContent);
// Assert
Assert.Equal(expected, copiedTagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例11: CanAppendDefaultTagHelperContent
public void CanAppendDefaultTagHelperContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var helloWorldContent = new DefaultTagHelperContent();
helloWorldContent.SetContent("HelloWorld");
var expected = "Content was HtmlEncode[[HelloWorld]]";
// Act
tagHelperContent.AppendFormat("Content was {0}", helloWorldContent);
// Assert
Assert.Equal(expected, tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例12: CanAppendFormat_WithCulture
public void CanAppendFormat_WithCulture()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
// Act
tagHelperContent.AppendFormat(
CultureInfo.InvariantCulture,
"Numbers in InvariantCulture - {0:N} {1} {2} {3}!",
1.1,
2.98,
145.82,
32.86);
// Assert
Assert.Equal(
"Numbers in InvariantCulture - HtmlEncode[[1.10]] HtmlEncode[[2.98]] " +
"HtmlEncode[[145.82]] HtmlEncode[[32.86]]!",
tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例13: CanAppendFormatContent
public void CanAppendFormatContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
// Act
tagHelperContent.AppendFormat("{0} {1} {2} {3}!", "First", "Second", "Third", "Fourth");
// Assert
Assert.Equal(
"HtmlEncode[[First]] HtmlEncode[[Second]] HtmlEncode[[Third]] HtmlEncode[[Fourth]]!",
tagHelperContent.GetContent(new HtmlTestEncoder()));
}
示例14: CanGetContent
public void CanGetContent()
{
// Arrange
var tagHelperContent = new DefaultTagHelperContent();
var expected = "Hello World!";
tagHelperContent.SetContent(expected);
// Act
var actual = tagHelperContent.GetContent();
// Assert
Assert.Equal(expected, actual);
}
示例15: MoveTo_DoesDeepMove
public void MoveTo_DoesDeepMove()
{
// Arrange
var source = new DefaultTagHelperContent();
var nested = new DefaultTagHelperContent();
source.AppendHtml(nested);
nested.AppendHtml(new HtmlEncodedString("hello"));
source.Append("Test");
var items = new List<object>();
var destination = new HtmlContentBuilder(items);
destination.Append("some-content");
// Act
source.MoveTo(destination);
// Assert
Assert.Equal(string.Empty, source.GetContent());
Assert.Equal(string.Empty, nested.GetContent());
Assert.Equal(3, items.Count);
Assert.Equal("some-content", Assert.IsType<string>(items[0]));
Assert.Equal("hello", Assert.IsType<HtmlEncodedString>(items[1]).Value);
Assert.Equal("Test", Assert.IsType<string>(items[2]));
}