public void ImmutableList_SerializeAndDeserialize_CorrectResult() { // ARRANGE var objectUnderTest = new Test(); objectUnderTest.List = objectUnderTest.List.Add(1); objectUnderTest.List = objectUnderTest.List.Add(2); objectUnderTest.List = objectUnderTest.List.Add(3); // ACT var serialized = DataContractHelper.Serialize <Test>(objectUnderTest); var result = DataContractHelper.Deserialize <Test>(serialized); // ASSERT Assert.IsNotNull(result); Assert.IsNotNull(result.List); Assert.IsInstanceOfType(result.List, typeof(ImmutableList <int>)); CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, result.List); }
public void ImmutableDictionary_SerializeAndDeserialize_CorrectResult() { // ARRANGE var objectUnderTest = new Test(); objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(1, "one"); objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(2, "two"); objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(3, "three"); // ACT var serialized = DataContractHelper.Serialize <Test>(objectUnderTest); var result = DataContractHelper.Deserialize <Test>(serialized); // ASSERT Assert.IsNotNull(result); Assert.IsNotNull(result.Dictionary); Assert.IsInstanceOfType(result.Dictionary, typeof(ImmutableDictionary <int, string>)); Assert.AreEqual("one", result.Dictionary[1]); Assert.AreEqual("two", result.Dictionary[2]); Assert.AreEqual("three", result.Dictionary[3]); }
public static object?ReadXml(this XmlDictionaryReader?xmlDictionaryReader, Type type) => DataContractHelper.Deserialize(type, xmlDictionaryReader);
public static TValue?ReadXml <TValue>(this XmlDictionaryReader?xmlDictionaryReader) => DataContractHelper.Deserialize <TValue>(xmlDictionaryReader);