From 8a81e3a25f1452c06e8580e675b0380dd95abc39 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 1 Jul 2019 15:00:32 -0700 Subject: [PATCH] String content emoji (#11386) Test fix of high-ascii encoding. --- .../test/StringHtmlContentTest.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Mvc/Mvc.ViewFeatures/test/StringHtmlContentTest.cs b/src/Mvc/Mvc.ViewFeatures/test/StringHtmlContentTest.cs index a6114e7f4f..ff162712c4 100644 --- a/src/Mvc/Mvc.ViewFeatures/test/StringHtmlContentTest.cs +++ b/src/Mvc/Mvc.ViewFeatures/test/StringHtmlContentTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; +using System.Text.Encodings.Web; using Microsoft.Extensions.WebEncoders.Testing; using Xunit; @@ -22,5 +23,19 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures Assert.Equal("HtmlEncode[[Hello World]]", writer.ToString()); } } + + [Fact] + public void Emoji_EncodedCorrectly() + { + // Arrange & Act + var tearsOfJoy = new StringHtmlContent("😂2"); + + // Assert + using (var stringWriter = new StringWriter()) + { + tearsOfJoy.WriteTo(stringWriter, HtmlEncoder.Default); + Assert.Equal("😂2", stringWriter.ToString(), ignoreCase: true); + } + } } }