Address nits from other PRs (dotnet/corefx#39482)
authorSteve Harter <steveharter@users.noreply.github.com>
Mon, 15 Jul 2019 17:29:03 +0000 (10:29 -0700)
committermsftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com>
Mon, 15 Jul 2019 17:29:03 +0000 (17:29 +0000)
Commit migrated from https://github.com/dotnet/corefx/commit/8af2b531bdd0ea41d3507870fadf9a26d663e700

src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs
src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.KeyPolicy.cs
src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs
src/libraries/System.Text.Json/tests/Serialization/Stream.WriteTests.cs

index d208f3a..4a2f2ca 100644 (file)
@@ -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<ClassWithPopulatedListAndNoSetter>(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<ClassWithPopulatedListAndSetter>(json);
             Assert.Equal(2, obj.MyList.Count);
index 65c97b1..707eab3 100644 (file)
@@ -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
index a81a68a..b787da4 100644 (file)
@@ -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
index a131f59..1aa8949 100644 (file)
@@ -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<SessionResponse>();
-            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<SessionResponse> deserializedList = JsonSerializer.Deserialize<List<SessionResponse>>(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<SessionResponse> deserializedList = await JsonSerializer.DeserializeAsync<List<SessionResponse>>(memoryStream, options);
-                Assert.Equal(100, deserializedList.Count);
+                Assert.Equal(SessionResponseCount, deserializedList.Count);
             }
         }
     }