public void GetHashCodeTest() { DataTable table = new DataTable(); table.Columns.Add("column1"); table.Columns.Add("column2"); DataRow row = table.NewRow(); row[0] = 111; row[1] = 222; table.Rows.Add(row); Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; List <Point3D> list = new List <Point3D>() { testPoint1 }; FeatureObject featureObject = new FeatureObject() { Coordinates = list, LayerName = "test1", FeatureAttribute = row }; FeatureObject featureObject2 = new FeatureObject() { Coordinates = list, LayerName = "test1", FeatureAttribute = row }; Assert.AreEqual(featureObject.GetHashCode(), featureObject2.GetHashCode()); var obj = featureObject.Clone(); Assert.AreNotEqual(featureObject.GetHashCode(), obj.GetHashCode()); }
public void DeepCloneTest()//深拷贝测试 { DataTable table = new DataTable(); table.Columns.Add("column1"); table.Columns.Add("column2"); DataRow row = table.NewRow(); row[0] = 111; row[1] = 222; table.Rows.Add(row); Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; FeatureObject featureObject = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint1 }, LayerName = "test1", FeatureAttribute = row }; var obj = featureObject.Clone(); Assert.AreNotEqual(featureObject.GetHashCode(), obj.GetHashCode()); var result = featureObject.Equals(obj); Assert.AreEqual(result, true); }