From: Santiago Fernandez Madero Date: Thu, 20 Feb 2020 16:51:04 +0000 (-0800) Subject: Cleanup System.Text.Json tests names with issue number (#32562) X-Git-Tag: submit/tizen/20210909.063632~9596 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87a536ee9e7608164981611291c2890d2400b54c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Cleanup System.Text.Json tests names with issue number (#32562) * Cleanup System.Text.Json tests names with issue number * Fix build * Cleanup more test/classes names * PR Feedback --- 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 fd3ab1c..4d732b8 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Array.ReadTests.cs @@ -94,7 +94,7 @@ namespace System.Text.Json.Serialization.Tests } [Fact] - public static void DeserializeObjectArray_36167() + public static void DeserializeObjectArray() { // https://github.com/dotnet/runtime/issues/29019 object[] data = JsonSerializer.Deserialize("[1]"); diff --git a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs index d48e02e..ba9729e 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs @@ -619,7 +619,7 @@ namespace System.Text.Json.Serialization.Tests } [Fact] - public static void DictionaryOfObject_37569() + public static void DictionaryOfObject_NonPrimitiveTypes() { // https://github.com/dotnet/runtime/issues/29504 Dictionary dictionary = new Dictionary @@ -1637,15 +1637,16 @@ namespace System.Text.Json.Serialization.Tests Assert.Null(obj.MyDictionary); } + // https://github.com/dotnet/runtime/issues/29933 [Fact] - public static void Regression38643_Serialize() + public static void Serialize_IDictionaryOfPoco() { // Arrange - var value = new Regression38643_Parent() + var value = new AllSingleUpperPropertiesParent() { - Child = new Dictionary() + Child = new Dictionary() { - ["1"] = new Regression38643_Child() + ["1"] = new AllSingleUpperProperties_Child() { A = "1", B = string.Empty, @@ -1664,13 +1665,14 @@ namespace System.Text.Json.Serialization.Tests Assert.NotEmpty(actual); } + // https://github.com/dotnet/runtime/issues/29933 [Fact] - public static void Regression38643_Deserialize() + public static void Deserialize_IDictionaryOfPoco() { // Arrange string json = "{\"child\":{\"1\":{\"a\":\"1\",\"b\":\"\",\"c\":[],\"d\":[],\"e\":null,\"f\":[],\"g\":null,\"h\":null,\"i\":null,\"j\":null,\"k\":[]}}}"; - var actual = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); + var actual = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); // Assert Assert.NotNull(actual); @@ -1680,24 +1682,26 @@ namespace System.Text.Json.Serialization.Tests Assert.Equal("1", actual.Child["1"].A); } + // https://github.com/dotnet/runtime/issues/29893 [Fact] - public static void Regression38565_Serialize() + public static void ShouldHandleNullInDictionaries_Serialize() { - var value = new Regression38565_Parent() + var value = new ClassWithDictionaryOfString_ChildWithDictionaryOfString() { Test = "value1", - Child = new Regression38565_Child() + Child = new ClassWithDictionaryOfString() }; var actual = JsonSerializer.Serialize(value); Assert.Equal("{\"Test\":\"value1\",\"Dict\":null,\"Child\":{\"Test\":null,\"Dict\":null}}", actual); } + // https://github.com/dotnet/runtime/issues/29893 [Fact] - public static void Regression38565_Deserialize() + public static void ShouldHandleNullInDictionaries_Deserialize() { var json = "{\"Test\":\"value1\",\"Dict\":null,\"Child\":{\"Test\":null,\"Dict\":null}}"; - Regression38565_Parent actual = JsonSerializer.Deserialize(json); + ClassWithDictionaryOfString_ChildWithDictionaryOfString actual = JsonSerializer.Deserialize(json); Assert.Equal("value1", actual.Test); Assert.Null(actual.Dict); @@ -1706,24 +1710,26 @@ namespace System.Text.Json.Serialization.Tests Assert.Null(actual.Child.Test); } + // https://github.com/dotnet/runtime/issues/29893 [Fact] - public static void Regression38565_Serialize_IgnoreNullValues() + public static void ShouldHandleNullInDictionaries_Serialize_IgnoreNullValues() { - var value = new Regression38565_Parent() + var value = new ClassWithDictionaryOfString_ChildWithDictionaryOfString() { Test = "value1", - Child = new Regression38565_Child() + Child = new ClassWithDictionaryOfString() }; var actual = JsonSerializer.Serialize(value, new JsonSerializerOptions { IgnoreNullValues = true }); Assert.Equal("{\"Test\":\"value1\",\"Child\":{}}", actual); } + // https://github.com/dotnet/runtime/issues/29893 [Fact] - public static void Regression38565_Deserialize_IgnoreNullValues() + public static void ShouldHandleNullInDictionaries_Deserialize_IgnoreNullValues() { var json = "{\"Test\":\"value1\",\"Child\":{}}"; - Regression38565_Parent actual = JsonSerializer.Deserialize(json); + ClassWithDictionaryOfString_ChildWithDictionaryOfString actual = JsonSerializer.Deserialize(json); Assert.Equal("value1", actual.Test); Assert.Null(actual.Dict); @@ -1732,10 +1738,11 @@ namespace System.Text.Json.Serialization.Tests Assert.Null(actual.Child.Test); } + // https://github.com/dotnet/runtime/issues/29888 [Fact] - public static void Regression38557_Serialize() + public static void DictionaryWithNullShouldPreserveOrder_Serialize() { - var dictionaryFirst = new Regression38557_DictionaryFirst() + var dictionaryFirst = new ClassWithDictionaryAndProperty_DictionaryFirst() { Test = "value1" }; @@ -1743,7 +1750,7 @@ namespace System.Text.Json.Serialization.Tests var actual = JsonSerializer.Serialize(dictionaryFirst); Assert.Equal("{\"Dict\":null,\"Test\":\"value1\"}", actual); - var dictionaryLast = new Regression38557_DictionaryLast() + var dictionaryLast = new ClassWithDictionaryAndProperty_DictionaryLast() { Test = "value1" }; @@ -1752,26 +1759,28 @@ namespace System.Text.Json.Serialization.Tests Assert.Equal("{\"Test\":\"value1\",\"Dict\":null}", actual); } + // https://github.com/dotnet/runtime/issues/29888 [Fact] - public static void Regression38557_Deserialize() + public static void DictionaryWithNullShouldPreserveOrder_Deserialize() { var json = "{\"Dict\":null,\"Test\":\"value1\"}"; - Regression38557_DictionaryFirst dictionaryFirst = JsonSerializer.Deserialize(json); + ClassWithDictionaryAndProperty_DictionaryFirst dictionaryFirst = JsonSerializer.Deserialize(json); Assert.Equal("value1", dictionaryFirst.Test); Assert.Null(dictionaryFirst.Dict); json = "{\"Test\":\"value1\",\"Dict\":null}"; - Regression38557_DictionaryLast dictionaryLast = JsonSerializer.Deserialize(json); + ClassWithDictionaryAndProperty_DictionaryLast dictionaryLast = JsonSerializer.Deserialize(json); Assert.Equal("value1", dictionaryLast.Test); Assert.Null(dictionaryLast.Dict); } + // https://github.com/dotnet/runtime/issues/29888 [Fact] - public static void Regression38557_Serialize_IgnoreNullValues() + public static void DictionaryWithNullShouldPreserveOrder_Serialize_IgnoreNullValues() { - var dictionaryFirst = new Regression38557_DictionaryFirst() + var dictionaryFirst = new ClassWithDictionaryAndProperty_DictionaryFirst() { Test = "value1" }; @@ -1779,7 +1788,7 @@ namespace System.Text.Json.Serialization.Tests var actual = JsonSerializer.Serialize(dictionaryFirst, new JsonSerializerOptions { IgnoreNullValues = true }); Assert.Equal("{\"Test\":\"value1\"}", actual); - var dictionaryLast = new Regression38557_DictionaryLast() + var dictionaryLast = new ClassWithDictionaryAndProperty_DictionaryLast() { Test = "value1" }; @@ -1788,17 +1797,18 @@ namespace System.Text.Json.Serialization.Tests Assert.Equal("{\"Test\":\"value1\"}", actual); } + // https://github.com/dotnet/runtime/issues/29888 [Fact] - public static void Regression38557_Deserialize_IgnoreNullValues() + public static void DictionaryWithNullShouldPreserveOrder_Deserialize_IgnoreNullValues() { var json = "{\"Test\":\"value1\"}"; - Regression38557_DictionaryFirst dictionaryFirst = JsonSerializer.Deserialize(json); + ClassWithDictionaryAndProperty_DictionaryFirst dictionaryFirst = JsonSerializer.Deserialize(json); Assert.Equal("value1", dictionaryFirst.Test); Assert.Null(dictionaryFirst.Dict); json = "{\"Test\":\"value1\"}"; - Regression38557_DictionaryLast dictionaryLast = JsonSerializer.Deserialize(json); + ClassWithDictionaryAndProperty_DictionaryLast dictionaryLast = JsonSerializer.Deserialize(json); Assert.Equal("value1", dictionaryLast.Test); Assert.Null(dictionaryLast.Dict); @@ -1844,12 +1854,12 @@ namespace System.Text.Json.Serialization.Tests [JsonIgnore] public Dictionary MyDictionary { get; set; } } - public class Regression38643_Parent + public class AllSingleUpperPropertiesParent { - public IDictionary Child { get; set; } + public IDictionary Child { get; set; } } - public class Regression38643_Child + public class AllSingleUpperProperties_Child { public string A { get; set; } public string B { get; set; } @@ -1864,26 +1874,26 @@ namespace System.Text.Json.Serialization.Tests public string[] K { get; set; } } - public class Regression38565_Parent + public class ClassWithDictionaryOfString_ChildWithDictionaryOfString { public string Test { get; set; } public Dictionary Dict { get; set; } - public Regression38565_Child Child { get; set; } + public ClassWithDictionaryOfString Child { get; set; } } - public class Regression38565_Child + public class ClassWithDictionaryOfString { public string Test { get; set; } public Dictionary Dict { get; set; } } - public class Regression38557_DictionaryLast + public class ClassWithDictionaryAndProperty_DictionaryLast { public string Test { get; set; } public Dictionary Dict { get; set; } } - public class Regression38557_DictionaryFirst + public class ClassWithDictionaryAndProperty_DictionaryFirst { public Dictionary Dict { get; set; } public string Test { get; set; } diff --git a/src/libraries/System.Text.Json/tests/Serialization/Object.WriteTests.cs b/src/libraries/System.Text.Json/tests/Serialization/Object.WriteTests.cs index 34f96cc..c099efa 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Object.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Object.WriteTests.cs @@ -129,7 +129,7 @@ namespace System.Text.Json.Serialization.Tests // https://github.com/dotnet/corefx/issues/40979 [Fact] - public static void EscapingShouldntStackOverflow_40979() + public static void EscapingShouldntStackOverflow() { var test = new { Name = "\u6D4B\u8A6611" }; diff --git a/src/libraries/System.Text.Json/tests/Serialization/ReadScenarioTests.cs b/src/libraries/System.Text.Json/tests/Serialization/ReadScenarioTests.cs index dfad875..f949cab 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/ReadScenarioTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/ReadScenarioTests.cs @@ -33,41 +33,38 @@ namespace System.Text.Json.Serialization.Tests Converters = { new JsonStringEnumConverter(), - new Types38568.MyDateTimeConverter() + new MyDateTimeConverter() } }; - Types38568.Model model = JsonSerializer.Deserialize(json, options); - Assert.Equal(Types38568.Color.Brown, model.EyeColor); + Model model = JsonSerializer.Deserialize(json, options); + Assert.Equal(Color.Brown, model.EyeColor); Assert.Equal(@"http://placehold.it/32x32", model.Picture.OriginalString); Assert.Equal(DateTime.Parse("2015-05-30T01:50:21 -01:00"), model.Registered); } - public class Types38568 + // The built-in DateTime parser is stricter than DateTime.Parse. + public class MyDateTimeConverter : JsonConverter { - // The built-in DateTime parser is stricter than DateTime.Parse. - public class MyDateTimeConverter : JsonConverter - { - public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - => DateTime.Parse(reader.GetString()); + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + => DateTime.Parse(reader.GetString()); - public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) - => writer.WriteStringValue(value.ToString("O")); - } + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + => writer.WriteStringValue(value.ToString("O")); + } - public sealed class Model - { - public Color EyeColor { get; set; } - public Uri Picture { get; set; } - public DateTime Registered { get; set; } - } + public sealed class Model + { + public Color EyeColor { get; set; } + public Uri Picture { get; set; } + public DateTime Registered { get; set; } + } - public enum Color - { - Blue, - Green, - Brown - } + public enum Color + { + Blue, + Green, + Brown } } } diff --git a/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.GenericCollections.cs b/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.GenericCollections.cs index 2cb4b28..327d5a6 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.GenericCollections.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.GenericCollections.cs @@ -826,7 +826,7 @@ namespace System.Text.Json.Serialization.Tests // https://github.com/dotnet/runtime/issues/30388 [Fact] - public static void WriteClassWithNullKeyValuePairValues_Regression39808() + public static void WriteClassWithNullKeyValuePairValues_NullWrittenAsEmptyObject() { var value = new SimpleClassWithKeyValuePairs() { diff --git a/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.Date.cs b/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.Date.cs index ce4a76c..5fb2e63 100644 --- a/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.Date.cs +++ b/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.Date.cs @@ -149,8 +149,8 @@ namespace System.Text.Json.Tests } [Fact] - // https://github.com/dotnet/runtime/issues/30095. - public static void Regression39067_TestingDateTimeMinValue() + // https://github.com/dotnet/runtime/issues/30095 + public static void TestingDateTimeMinValue_UtcOffsetGreaterThan0() { string jsonString = @"""0001-01-01T00:00:00"""; string expectedString = "0001-01-01T00:00:00";