From 5b588fc0721e8e3c59dbd252a636d1c4418d47b7 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Thu, 31 Oct 2019 19:48:02 -0500 Subject: [PATCH] Extend BOM test (dotnet/corefx#42279) Commit migrated from https://github.com/dotnet/corefx/commit/5d92ba3e6bf4bf8f211f43ad4717572a2a3b4539 --- .../System.Text.Json/tests/Serialization/Stream.ReadTests.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/Serialization/Stream.ReadTests.cs b/src/libraries/System.Text.Json/tests/Serialization/Stream.ReadTests.cs index cfa4b33..d6d9818 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Stream.ReadTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Stream.ReadTests.cs @@ -203,9 +203,11 @@ namespace System.Text.Json.Serialization.Tests stream.Position = 0; value = await JsonSerializer.DeserializeAsync(stream, options); - // Verify first and last elements. - VerifyElement(0); - VerifyElement(count - 1); + // Verify each element. + for (int i = 0; i < count; i++) + { + VerifyElement(i); + } // Round trip and verify. stream.Position = 3; // Skip the BOM. @@ -218,10 +220,12 @@ namespace System.Text.Json.Serialization.Tests void VerifyElement(int index) { Assert.Equal(JsonValueKind.Object, value[index].GetProperty("Test").ValueKind); + Assert.False(value[index].GetProperty("Test").EnumerateObject().MoveNext()); Assert.Equal(JsonValueKind.Array, value[index].GetProperty("Test2").ValueKind); Assert.Equal(0, value[index].GetProperty("Test2").GetArrayLength()); Assert.Equal(JsonValueKind.Object, value[index].GetProperty("Test3").ValueKind); Assert.Equal(JsonValueKind.Object, value[index].GetProperty("Test3").GetProperty("Value").ValueKind); + Assert.False(value[index].GetProperty("Test3").GetProperty("Value").EnumerateObject().MoveNext()); Assert.Equal(0, value[index].GetProperty("PersonType").GetInt32()); Assert.Equal(2, value[index].GetProperty("Id").GetInt32()); } -- 2.7.4