Added tests to cover all reachable branches when backed by JsonNode (dotnet/corefx...
authorAntonLandor <55381413+AntonLandor@users.noreply.github.com>
Fri, 27 Sep 2019 22:17:59 +0000 (00:17 +0200)
committerSantiago Fernandez Madero <safern@microsoft.com>
Fri, 27 Sep 2019 22:17:59 +0000 (15:17 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/867c317528b0dfcebd608d10968f24320ee316ab

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

index 52fb218..d8f3d82 100644 (file)
@@ -85,6 +85,8 @@ namespace System.Text.Json.Tests
 
             JsonElement.ObjectEnumerator objectEnumerator = jsonObjectElement.EnumerateObject();
 
+            Assert.Equal(default, objectEnumerator.Current);
+
             for (int i = 1; i <= 3; i++)
             {
                 Assert.True(objectEnumerator.MoveNext());
@@ -118,6 +120,13 @@ namespace System.Text.Json.Tests
         }
 
         [Fact]
+        public static void TestBytesFromBase64()
+        {
+            Assert.Throws<NotSupportedException>(() => new JsonString().AsJsonElement().GetBytesFromBase64());
+            Assert.Throws<InvalidOperationException>(() => new JsonBoolean().AsJsonElement().GetBytesFromBase64());
+        }
+
+        [Fact]
         public static void TestByte()
         {
             Assert.Equal(byte.MaxValue, new JsonNumber(byte.MaxValue).AsJsonElement().GetByte());
@@ -282,6 +291,7 @@ namespace System.Text.Json.Tests
             Assert.True(arrayEnumerator.MoveNext());
             Assert.Equal(2, arrayEnumerator.Current.GetInt32());
             Assert.False(arrayEnumerator.MoveNext());
+            Assert.Equal(default, arrayEnumerator.Current);
 
             var jsonObjectFromCopy = (JsonObject)JsonNode.GetNode(jsonElementCopy);