From: Marcus Turewicz <24448509+marcusturewicz@users.noreply.github.com> Date: Wed, 15 Apr 2020 13:41:07 +0000 (+1000) Subject: Adds AssertContentsAgainstJsonNet to avoid unnecessary calls (#34931) X-Git-Tag: submit/tizen/20210909.063632~8562 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2eef5a3dc0f9afeb07a1aada1c5312fc013b7871;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Adds AssertContentsAgainstJsonNet to avoid unnecessary calls (#34931) * Adds AssertContentsAgainstJsonNet to avoid unnecessary calls Fixes #32351 * Remove temporary hack comments --- diff --git a/src/libraries/System.Text.Json/tests/JsonTestHelper.cs b/src/libraries/System.Text.Json/tests/JsonTestHelper.cs index 06ab14a..5bae2db 100644 --- a/src/libraries/System.Text.Json/tests/JsonTestHelper.cs +++ b/src/libraries/System.Text.Json/tests/JsonTestHelper.cs @@ -718,17 +718,14 @@ namespace System.Text.Json #endif ); - // Temporary hack until we can use the same escape algorithm on both sides and make sure we want uppercase hex. - // Todo: https://github.com/dotnet/runtime/issues/32351 - Assert.Equal(expectedValue.NormalizeToJsonNetFormat(), value.NormalizeToJsonNetFormat()); + AssertContentsAgainstJsonNet(expectedValue, value); } public static void AssertContents(string expectedValue, MemoryStream stream) { string value = Encoding.UTF8.GetString(stream.ToArray()); - // Temporary hack until we can use the same escape algorithm on both sides and make sure we want uppercase hex. - Assert.Equal(expectedValue.NormalizeToJsonNetFormat(), value.NormalizeToJsonNetFormat()); + AssertContentsAgainstJsonNet(expectedValue, value); } public static void AssertContentsNotEqual(string expectedValue, ArrayBufferWriter buffer) @@ -740,8 +737,16 @@ namespace System.Text.Json #endif ); - // Temporary hack until we can use the same escape algorithm on both sides and make sure we want uppercase hex. - // Todo: https://github.com/dotnet/runtime/issues/32351 + AssertContentsNotEqualAgainstJsonNet(expectedValue, value); + } + + public static void AssertContentsAgainstJsonNet(string expectedValue, string value) + { + Assert.Equal(expectedValue.NormalizeToJsonNetFormat(), value.NormalizeToJsonNetFormat()); + } + + public static void AssertContentsNotEqualAgainstJsonNet(string expectedValue, string value) + { Assert.NotEqual(expectedValue.NormalizeToJsonNetFormat(), value.NormalizeToJsonNetFormat()); }