Fix outerloop JsonWriter test by creating new instance of the writer when writing...
authorAhson Khan <ahkha@microsoft.com>
Thu, 17 Jan 2019 20:52:13 +0000 (12:52 -0800)
committerGitHub <noreply@github.com>
Thu, 17 Jan 2019 20:52:13 +0000 (12:52 -0800)
* Re-initialize json writer within invalid test that throws to avoid writing a value in a JSON object.

* Uncomment outerloop attribute.

Commit migrated from https://github.com/dotnet/corefx/commit/54f3a59c5e0cd0db90e9c74cd11eebfd28f028b7

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

index 1f05b84229aec897e8783cef4d54cc32b6461828..f282ff3f27f2989ffc5f4b095b325ee4b72d6988 100644 (file)
@@ -2917,10 +2917,10 @@ namespace System.Text.Json.Tests
             value.Fill((byte)'b');
 
             var output = new ArrayBufferWriter(1024);
-            var jsonUtf8 = new Utf8JsonWriter(output, state);
 
             try
             {
+                var jsonUtf8 = new Utf8JsonWriter(output, state);
                 jsonUtf8.WriteStartObject();
                 jsonUtf8.WriteString(key, DateTime.Now, escape: false);
                 Assert.True(false, $"Expected ArgumentException for data too large wasn't thrown. KeyLength: {key.Length}");
@@ -2929,6 +2929,7 @@ namespace System.Text.Json.Tests
 
             try
             {
+                var jsonUtf8 = new Utf8JsonWriter(output, state);
                 jsonUtf8.WriteStartArray();
                 jsonUtf8.WriteStringValue(value, escape: false);
                 Assert.True(false, $"Expected ArgumentException for data too large wasn't thrown. ValueLength: {value.Length}");