47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
// 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 System.IO;
|
|
using Microsoft.Framework.WebEncoders.Testing;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.AspNet.Mvc.Rendering
|
|
{
|
|
public class StringHtmlContentTest
|
|
{
|
|
[Fact]
|
|
public void ToString_ReturnsAString()
|
|
{
|
|
// Arrange & Act
|
|
var content = new StringHtmlContent("Hello World");
|
|
|
|
// Assert
|
|
Assert.Equal("Hello World", content.ToString());
|
|
}
|
|
|
|
[Fact]
|
|
public void ToString_ReturnsNullForNullInput()
|
|
{
|
|
// Arrange & Act
|
|
var content = new StringHtmlContent(null);
|
|
|
|
// Assert
|
|
Assert.Null(content.ToString());
|
|
}
|
|
|
|
[Fact]
|
|
public void WriteTo_WritesContent()
|
|
{
|
|
// Arrange & Act
|
|
var content = new StringHtmlContent("Hello World");
|
|
|
|
// Assert
|
|
using (var writer = new StringWriter())
|
|
{
|
|
content.WriteTo(writer, new CommonTestEncoder());
|
|
Assert.Equal("HtmlEncode[[Hello World]]", writer.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|