Adds AssertContentsAgainstJsonNet to avoid unnecessary calls (#34931)
authorMarcus Turewicz <24448509+marcusturewicz@users.noreply.github.com>
Wed, 15 Apr 2020 13:41:07 +0000 (23:41 +1000)
committerGitHub <noreply@github.com>
Wed, 15 Apr 2020 13:41:07 +0000 (06:41 -0700)
* Adds AssertContentsAgainstJsonNet to avoid unnecessary calls

Fixes #32351

* Remove temporary hack comments

src/libraries/System.Text.Json/tests/JsonTestHelper.cs

index 06ab14a..5bae2db 100644 (file)
@@ -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<byte> 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());
         }