Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit 219b671

Browse files
buyaa-nahsonkhan
authored andcommitted
Enable fixed tests, formatting update (#38909)
1 parent dad20ba commit 219b671

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/System.Text.Json/tests/Serialization/Object.ReadTests.cs

+13-7
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ public static void ReadObject_PublicIndexer()
282282
Assert.Equal(-1, indexer[0]);
283283
}
284284

285-
[ActiveIssue(38414)]
286285
[Fact]
287286
public static void ReadSimpleStructWithSimpleClass()
288287
{
@@ -294,7 +293,6 @@ public static void ReadSimpleStructWithSimpleClass()
294293
obj.Verify();
295294
}
296295

297-
[ActiveIssue(38490)]
298296
[Fact]
299297
public static void ReadSimpleTestStructWithSimpleTestClass()
300298
{
@@ -304,7 +302,10 @@ public static void ReadSimpleTestStructWithSimpleTestClass()
304302

305303
string json = JsonSerializer.ToString(testObject);
306304
SimpleTestStruct parsedObject = JsonSerializer.Parse<SimpleTestStruct>(json);
305+
307306
parsedObject.Verify();
307+
Assert.Equal(3.14, parsedObject.MySimpleTestClass.MyDouble);
308+
Assert.Equal("Hello", parsedObject.MySimpleTestClass.MyString);
308309
}
309310

310311
[Fact]
@@ -316,15 +317,18 @@ public static void ReadSimpleTestClassWithSimpleTestStruct()
316317

317318
string json = JsonSerializer.ToString(testObject);
318319
SimpleTestClass parsedObject = JsonSerializer.Parse<SimpleTestClass>(json);
320+
319321
parsedObject.Verify();
322+
Assert.Equal(64, parsedObject.MySimpleTestStruct.MyInt64);
323+
Assert.Equal("Hello", parsedObject.MySimpleTestStruct.MyString);
324+
Assert.Equal(32, parsedObject.MySimpleTestStruct.MyInt32Array[0]);
320325
}
321326

322-
[ActiveIssue(38414)]
323327
[Fact]
324328
public static void OuterClassHavingPropertiesDefinedAfterClassWithDictionaryTest()
325329
{
326330
OuterClassHavingPropertiesDefinedAfterClassWithDictionary testObject = new OuterClassHavingPropertiesDefinedAfterClassWithDictionary { MyInt = 10, MyIntArray = new int[] { 3 },
327-
MyDouble= 3.14, MyList =new List<string> { "Hello" }, MyString = "World", MyInnerTestClass = new SimpleClassWithDictionary { MyInt = 2 } };
331+
MyDouble= 3.14, MyList = new List<string> { "Hello" }, MyString = "World", MyInnerTestClass = new SimpleClassWithDictionary { MyInt = 2 } };
328332
string json = JsonSerializer.ToString(testObject);
329333

330334
OuterClassHavingPropertiesDefinedAfterClassWithDictionary parsedObject = JsonSerializer.Parse<OuterClassHavingPropertiesDefinedAfterClassWithDictionary>(json);
@@ -337,12 +341,14 @@ public static void OuterClassHavingPropertiesDefinedAfterClassWithDictionaryTest
337341
Assert.Equal(2, parsedObject.MyInnerTestClass.MyInt);
338342
}
339343

340-
[ActiveIssue(38435)]
341344
[Fact]
342-
public static void ReadStructWithSimpleClassValueTest()
345+
public static void ReadStructWithSimpleClassArrayValueTest()
343346
{
344347
string json = "{\"MySimpleTestClass\":{\"MyInt32Array\":[1],\"MyStringToStringDict\":null,\"MyStringToStringIDict\":null},\"MyInt32Array\":[2]}";
345-
SimpleTestStruct obj3 = JsonSerializer.Parse<SimpleTestStruct>(json);
348+
SimpleTestStruct parsedObject = JsonSerializer.Parse<SimpleTestStruct>(json);
349+
350+
Assert.Equal(1, parsedObject.MySimpleTestClass.MyInt32Array[0]);
351+
Assert.Equal(2, parsedObject.MyInt32Array[0]);
346352
}
347353
}
348354
}

src/System.Text.Json/tests/Serialization/TestClasses.SimpleTestClass.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ public class SimpleTestClass : ITestClass
7676
public IReadOnlyCollection<string> MyStringIReadOnlyCollectionT { get; set; }
7777
public IReadOnlyList<string> MyStringIReadOnlyListT { get; set; }
7878
public ISet<string> MyStringISetT { get; set; }
79-
//todo: enable once we can write a custom converter for KeyValuePair:
80-
// public KeyValuePair<string, string> MyStringToStringKeyValuePair { get; set; }
79+
public KeyValuePair<string, string> MyStringToStringKeyValuePair { get; set; }
8180
public IDictionary MyStringToStringIDict { get; set; }
8281
public Dictionary<string, string> MyStringToStringGenericDict { get; set; }
8382
public IDictionary<string, string> MyStringToStringGenericIDict { get; set; }
@@ -127,7 +126,7 @@ public class SimpleTestClass : ITestClass
127126
@"""MyEnum"" : 2," + // int by default
128127
@"""MyInt64Enum"" : -9223372036854775808," +
129128
@"""MyUInt64Enum"" : 18446744073709551615," +
130-
//@"""MyStringToStringKeyValuePair"" : {""Key"" : ""myKey"", ""Value"" : ""myValue""}," +
129+
@"""MyStringToStringKeyValuePair"" : {""Key"" : ""myKey"", ""Value"" : ""myValue""}," +
131130
@"""MyStringToStringIDict"" : {""key"" : ""value""}," +
132131
@"""MyStringToStringGenericDict"" : {""key"" : ""value""}," +
133132
@"""MyStringToStringGenericIDict"" : {""key"" : ""value""}," +
@@ -277,7 +276,7 @@ public void Initialize()
277276
MyStringIReadOnlyListT = new string[] { "Hello" };
278277
MyStringISetT = new HashSet<string> { "Hello" };
279278

280-
//MyStringToStringKeyValuePair = new KeyValuePair<string, string>("myKey", "myValue");
279+
MyStringToStringKeyValuePair = new KeyValuePair<string, string>("myKey", "myValue");
281280
MyStringToStringIDict = new Dictionary<string, string> { { "key", "value" } };
282281

283282
MyStringToStringGenericDict = new Dictionary<string, string> { { "key", "value" } };
@@ -477,8 +476,8 @@ public void Verify()
477476
Assert.Equal("value", MyStringToStringIImmutableDict["key"]);
478477
Assert.Equal("value", MyStringToStringImmutableSortedDict["key"]);
479478

480-
//Assert.Equal("myKey", MyStringToStringKeyValuePair.Key);
481-
//Assert.Equal("myValue", MyStringToStringKeyValuePair.Value);
479+
Assert.Equal("myKey", MyStringToStringKeyValuePair.Key);
480+
Assert.Equal("myValue", MyStringToStringKeyValuePair.Value);
482481

483482
Assert.Equal(2, MyStringStackT.Count);
484483
Assert.True(MyStringStackT.Contains("Hello"));

0 commit comments

Comments
 (0)