From c02ad968ed8ea629c8a3b249a175d145637e6b26 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Mon, 15 Jul 2019 10:29:03 -0700 Subject: [PATCH] Address nits from other PRs (dotnet/corefx#39482) Commit migrated from https://github.com/dotnet/corefx/commit/8af2b531bdd0ea41d3507870fadf9a26d663e700 --- .../System.Text.Json/tests/Serialization/Array.ReadTests.cs | 4 ++-- .../tests/Serialization/DictionaryTests.KeyPolicy.cs | 2 -- .../System.Text.Json/tests/Serialization/DictionaryTests.cs | 1 - .../System.Text.Json/tests/Serialization/Stream.WriteTests.cs | 8 +++++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs b/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs index d208f3a..4a2f2ca 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs @@ -419,7 +419,7 @@ namespace System.Text.Json.Serialization.Tests [Fact] public static void ClassWithNoSetter() { - // We don't attempt to deserialize into collections without a setter. + // We replace the contents of this collection; we don't attempt to add items to the existing collection instance. string json = @"{""MyList"":[1,2]}"; ClassWithPopulatedListAndNoSetter obj = JsonSerializer.Deserialize(json); Assert.Equal(1, obj.MyList.Count); @@ -433,7 +433,7 @@ namespace System.Text.Json.Serialization.Tests [Fact] public static void ClassWithPopulatedList() { - // We don't attempt to deserialize into collections without a setter. + // We replace the contents of this collection; we don't attempt to add items to the existing collection instance. string json = @"{""MyList"":[2,3]}"; ClassWithPopulatedListAndSetter obj = JsonSerializer.Deserialize(json); Assert.Equal(2, obj.MyList.Count); diff --git a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.KeyPolicy.cs b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.KeyPolicy.cs index 65c97b1..707eab3 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.KeyPolicy.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.KeyPolicy.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Runtime.Serialization; -using Newtonsoft.Json; using Xunit; namespace System.Text.Json.Serialization.Tests diff --git a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs index a81a68a..b787da4 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; -using Newtonsoft.Json; using Xunit; namespace System.Text.Json.Serialization.Tests diff --git a/src/libraries/System.Text.Json/tests/Serialization/Stream.WriteTests.cs b/src/libraries/System.Text.Json/tests/Serialization/Stream.WriteTests.cs index a131f59..1aa8949 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Stream.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Stream.WriteTests.cs @@ -191,9 +191,11 @@ namespace System.Text.Json.Serialization.Tests [InlineData(16000)] public static async Task LargeJsonFile(int bufferSize) { + const int SessionResponseCount = 100; + // Build up a large list to serialize. var list = new List(); - for (int i = 0; i < 100; i++) + for (int i = 0; i < SessionResponseCount; i++) { SessionResponse response = new SessionResponse { @@ -238,7 +240,7 @@ namespace System.Text.Json.Serialization.Tests // Sync case. { List deserializedList = JsonSerializer.Deserialize>(json, options); - Assert.Equal(100, deserializedList.Count); + Assert.Equal(SessionResponseCount, deserializedList.Count); string jsonSerialized = JsonSerializer.Serialize(deserializedList, options); Assert.Equal(json, jsonSerialized); @@ -253,7 +255,7 @@ namespace System.Text.Json.Serialization.Tests memoryStream.Position = 0; List deserializedList = await JsonSerializer.DeserializeAsync>(memoryStream, options); - Assert.Equal(100, deserializedList.Count); + Assert.Equal(SessionResponseCount, deserializedList.Count); } } } -- 2.7.4