public void CrossInnerReferenceSerializeDeserializeTest() { XElement xe1, xe2; Helpers.ClassA a1,a2; Helpers.ClassB b1; int ida1, ida2; using (SerializeScope.Create()) { using (a1 = new Helpers.ClassA()) using (a2 = new Helpers.ClassA()) using (b1 = new Helpers.ClassB()) { a1.Ref = a2; a2.Ref = a1; b1.Ref1 = a1; b1.Ref2 = a2; ida1 = a1.Id; ida2 = a2.Id; xe1 = XmlSerializeProvider.Serialize(b1); } } using (SerializeScope.Create()) b1 = XmlSerializeProvider.Deserialize<Helpers.ClassB>(xe1); a1 = b1.Ref1; a2 = b1.Ref2; using (SerializeScope.Create()) xe2 = XmlSerializeProvider.Serialize(b1); Assert.IsTrue(a1 != null); Assert.IsTrue(a2 != null); Assert.IsTrue(a1 != a2); Assert.IsTrue(a1.Ref == a2); Assert.IsTrue(a2.Ref == a1); Assert.IsTrue(a1.Id == ida1); Assert.IsTrue(a2.Id == ida2); }
public void CrossReferenceSerializeDeserializeTest() { XElement xe1, xe2; Helpers.ClassA a1, a2; using (SerializeScope.Create()) { using (a1 = new Helpers.ClassA()) using (a2 = new Helpers.ClassA()) { a1.Ref = a2; a2.Ref = a1; xe1 = XmlSerializeProvider.Serialize(a1); xe2 = XmlSerializeProvider.Serialize(a2); } } using (SerializeScope.Create()) { a1 = XmlSerializeProvider.Deserialize<Helpers.ClassA>(xe1); a2 = XmlSerializeProvider.Deserialize<Helpers.ClassA>(xe2); } Assert.IsTrue(a1.Ref == a2); Assert.IsTrue(a2.Ref == a1); }