public async Task DictionaryArrayLoop() { DictionaryWithGenericCycleWithinList root = new DictionaryWithGenericCycleWithinList(); root["ArrayWithSelf"] = new List <DictionaryWithGenericCycleWithinList> { root }; string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = await JsonSerializerWrapperForString.SerializeWrapper(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); DictionaryWithGenericCycleWithinList rootCopy = await JsonSerializerWrapperForString.DeserializeWrapper <DictionaryWithGenericCycleWithinList>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy, rootCopy["ArrayWithSelf"][0]); }
public static void DictionaryArrayLoop() { DictionaryWithGenericCycleWithinList root = new DictionaryWithGenericCycleWithinList(); root["ArrayWithSelf"] = new List <DictionaryWithGenericCycleWithinList> { root }; string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = JsonSerializer.Serialize(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); DictionaryWithGenericCycleWithinList rootCopy = JsonSerializer.Deserialize <DictionaryWithGenericCycleWithinList>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy, rootCopy["ArrayWithSelf"][0]); }
public async Task DictionaryPreserveDuplicateArrays() { DictionaryWithGenericCycleWithinList root = new DictionaryWithGenericCycleWithinList(); root["Array1"] = new List <DictionaryWithGenericCycleWithinList> { root }; root["Array2"] = root["Array1"]; string expected = JsonConvert.SerializeObject(root, s_newtonsoftSerializerSettingsPreserve); string actual = await Serializer.SerializeWrapper(root, s_serializerOptionsPreserve); Assert.Equal(expected, actual); DictionaryWithGenericCycleWithinList rootCopy = await Serializer.DeserializeWrapper <DictionaryWithGenericCycleWithinList>(actual, s_serializerOptionsPreserve); Assert.Same(rootCopy, rootCopy["Array1"][0]); Assert.Same(rootCopy["Array2"], rootCopy["Array1"]); }