public new bool Equals(Object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (!(obj is PofMaster)) { return(false); } PofMaster other = (PofMaster)obj; return(NestedTypeWithReference.ArrayEqual(getList1(), other.getList1()) && NestedTypeWithReference.ArrayEqual(getList2(), other.getList2()) && NestedTypeWithReference.ArrayEqual(getList3(), other.getList3()) && NestedTypeWithReference.MapEqual(getMap1(), other.getMap1()) && NestedTypeWithReference.MapEqual(getMap2(), other.getMap2()) && NestedTypeWithReference.MapEqual(getMap3(), other.getMap3()) && getNumber() == other.getNumber() && getText().Equals(other.getText()) && NestedTypeWithReference.ArrayEqual(getChildren(), other.getChildren())); }
public void testNestedReferences() { const String sPath = "config/reference-pof-config.xml"; m_ctx = new ConfigurablePofContext(sPath); IXmlElement config = ((ConfigurablePofContext)m_ctx).Config; var pm = new PofMaster(); var pc1 = new PofChild(); var pc2 = new PofChild(); ArrayList list1 = null; var list2 = new ArrayList(); var list3 = new ArrayList(); IDictionary map1 = null; IDictionary map2 = new Hashtable(); IDictionary map3 = map2; list3.Add(0); map3.Add("key1", pc1); map3.Add("key2", pc2); pc1.setId("child1"); pc2.setId("child2"); pm.setList1(list1); pm.setList2(list2); pm.setList3(list3); pm.setMap1(map1); pm.setMap2(map2); pm.setMap3(map3); pm.setNumber(9999); pm.setText("cross fingers"); pm.setChildren(new PofChild[] { pc1, pc2, pc2 }); initPOFWriter(); m_ctx.Serialize(m_writer, pm); initPOFReader(); var pm2 = (PofMaster)m_ctx.Deserialize(m_reader); Assert.IsTrue(pm.Equals(pm2)); IDictionary map2R = pm2.getMap2(); IDictionary map3R = pm2.getMap3(); Assert.IsTrue(map2R != map3R); Assert.IsTrue(map2R["key1"] == map3R["key1"]); Assert.IsTrue(map2R["key2"] == map3R["key2"]); PofChild[] children = pm2.getChildren(); Assert.IsTrue(children[0] == map2R["key1"]); Assert.IsTrue(children[1] == children[2]); }