public async Task ArrayDictionaryLoop() { ListWithGenericCycleWithinDictionary root = new ListWithGenericCycleWithinDictionary(); root.Add(new Dictionary <string, ListWithGenericCycleWithinDictionary> { { "Root", root } }); string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = await JsonSerializerWrapperForString.SerializeWrapper(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); ListWithGenericCycleWithinDictionary rootCopy = await JsonSerializerWrapperForString.DeserializeWrapper <ListWithGenericCycleWithinDictionary>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy, rootCopy[0]["Root"]); }
public static void ArrayDictionaryLoop() { ListWithGenericCycleWithinDictionary root = new ListWithGenericCycleWithinDictionary(); root.Add(new Dictionary <string, ListWithGenericCycleWithinDictionary> { { "Root", root } }); string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = JsonSerializer.Serialize(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); ListWithGenericCycleWithinDictionary rootCopy = JsonSerializer.Deserialize <ListWithGenericCycleWithinDictionary>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy, rootCopy[0]["Root"]); }
public async Task ArrayPreserveDuplicateDictionaries() { ListWithGenericCycleWithinDictionary root = new ListWithGenericCycleWithinDictionary { new Dictionary <string, ListWithGenericCycleWithinDictionary>() }; root.Add(root[0]); string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = await JsonSerializerWrapperForString.SerializeWrapper(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); ListWithGenericCycleWithinDictionary rootCopy = await JsonSerializerWrapperForString.DeserializeWrapper <ListWithGenericCycleWithinDictionary>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy[0], rootCopy[1]); }
public static void ArrayPreserveDuplicateDictionaries() { ListWithGenericCycleWithinDictionary root = new ListWithGenericCycleWithinDictionary { new Dictionary <string, ListWithGenericCycleWithinDictionary>() }; root.Add(root[0]); string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = JsonSerializer.Serialize(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); ListWithGenericCycleWithinDictionary rootCopy = JsonSerializer.Deserialize <ListWithGenericCycleWithinDictionary>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy[0], rootCopy[1]); }