public void DeserializeComplex_TypedObject_MultiLevel() { var objTyped = new RecursiveClass() { MyProp = 1, RecursiveProperty = new RecursiveClass() { MyProp = 2, RecursiveProperty = new RecursiveClass() { MyProp = 3, RecursiveProperty = new RecursiveClass() { MyProp = 4, RecursiveProperty = null, ZProp = "D" }, ZProp = "C" }, ZProp = "B" }, ZProp = "A" }; var expressionStr = objTyped.AsExpression().DefaultSerializer.Serialize(); var deserializer = new ComplexEntityExpressionDeserializer(); var deserialized = (RecursiveClass)deserializer.Deserialize(expressionStr, objTyped.GetType()); Assert.IsType <RecursiveClass>(deserialized); Assert.Equal(1, deserialized.MyProp); Assert.Equal("A", deserialized.ZProp); Assert.Equal(2, deserialized.RecursiveProperty.MyProp); Assert.Equal("B", deserialized.RecursiveProperty.ZProp); Assert.Equal(3, deserialized.RecursiveProperty.RecursiveProperty.MyProp); Assert.Equal("C", deserialized.RecursiveProperty.RecursiveProperty.ZProp); Assert.Equal(4, deserialized.RecursiveProperty.RecursiveProperty.RecursiveProperty.MyProp); Assert.Equal("D", deserialized.RecursiveProperty.RecursiveProperty.RecursiveProperty.ZProp); }
public void DeserializeComplex_TypedObject_RecursiveAntiparalell() { var objTyped1 = new RecursiveClass() { MyProp = 100, RecursiveProperty = null }; var objTyped2 = new RecursiveClass() { MyProp = 120, RecursiveProperty = objTyped1 }; objTyped1.RecursiveProperty = objTyped2; var expressionStr = objTyped1.AsExpression().DefaultSerializer.Serialize(); var deserializer = new ComplexEntityExpressionDeserializer(); var deserialized = (RecursiveClass)deserializer.Deserialize(expressionStr, objTyped1.GetType()); Assert.IsType <RecursiveClass>(deserialized); Assert.Equal(100, deserialized.MyProp); Assert.Equal(120, deserialized.RecursiveProperty.MyProp); Assert.Same(deserialized, deserialized.RecursiveProperty.RecursiveProperty); }