public void DeepCircularReferenceError() { Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.ErrorCircularReferences; string result = s.Serialize(deep); MockReferenceObject actual = s.Deserialize <MockReferenceObject>(result); }
public void CircularReferenceWrite() { Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.WriteIdentifier; string result = s.Serialize(simple); MockReferenceObject actual = s.Deserialize <MockReferenceObject>(result); Assert.AreSame(simple, simple.Reference.Reference, "References not equal"); }
public void DeepCircularReferenceIgnore() { Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.IgnoreCircularReferences; string result = s.Serialize(deep); MockReferenceObject actual = s.Deserialize <MockReferenceObject>(result); Assert.IsNull(actual.Reference.Reference.Reference.Reference); }
private void CreateSimpleReference() { simple = new MockReferenceObject(); MockReferenceObject m2 = new MockReferenceObject(); simple.Name = "m1"; m2.Name = "m2"; simple.Reference = m2; m2.Reference = simple; }
public void TestCollectionIndexReference() { MockReferenceObject[] mockArray = new MockReferenceObject[] { simple }; Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.WriteIdentifier; string result = s.Serialize(mockArray); MockReferenceObject[] actual = s.Deserialize <MockReferenceObject[]>(result); Assert.AreSame(actual[0], actual[0].Reference.Reference, "reference inside collection not equal"); }
public void BackwardsCompatibleDeepWrite() { Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.WriteIdentifier; s.Settings.IsCompact = true; string result = s.Serialize(deep); result = result.Replace("$['Reference']", "this.Reference"); MockReferenceObject actual = s.Deserialize <MockReferenceObject>(result); Assert.AreSame(deep.Reference, deep.Reference.Reference.Reference.Reference, "References not equal"); }
public void TestBackwardsCompatibleReference() { Serializer s = new Serializer(); s.Settings.ReferenceWritingType = ReferenceOption.WriteIdentifier; s.Settings.IsCompact = true; string result = s.Serialize(simple); result = result.Replace("$", "this"); MockReferenceObject actual = s.Deserialize <MockReferenceObject>(result); Assert.AreSame(simple, simple.Reference.Reference, "References not equal"); }
private void CreateDeepReference() { deep = new MockReferenceObject(); MockReferenceObject m2 = new MockReferenceObject(); MockReferenceObject m3 = new MockReferenceObject(); MockReferenceObject m4 = new MockReferenceObject(); deep.Name = "m1"; m2.Name = "m2"; m3.Name = "m3"; m4.Name = "m4"; deep.Reference = m2; m2.Reference = m3; m3.Reference = m4; m4.Reference = m2; }