public void Clone() { var crossSectionYZ = new CrossSectionDefinitionYZ(); //simple V profile crossSectionYZ.YZDataTable.AddCrossSectionYZRow(0, 10, 2); crossSectionYZ.YZDataTable.AddCrossSectionYZRow(5, 0, 1); crossSectionYZ.YZDataTable.AddCrossSectionYZRow(10, 10, 2); crossSectionYZ.Thalweg = 5.0; var clone = (CrossSectionDefinitionYZ)crossSectionYZ.Clone(); Assert.AreEqual(crossSectionYZ.Thalweg, clone.Thalweg); CrossSectionDataSet.CrossSectionYZDataTable yzDataTable = crossSectionYZ.YZDataTable; CrossSectionDataSet.CrossSectionYZDataTable cloneYZTable = clone.YZDataTable; Assert.AreEqual(yzDataTable.Rows.Count, cloneYZTable.Rows.Count); Assert.AreEqual(5.0, clone.Thalweg); for (int i = 0; i < yzDataTable.Count; i++) { Assert.AreEqual(yzDataTable[i].DeltaZStorage, cloneYZTable[i].DeltaZStorage); Assert.AreEqual(yzDataTable[i].Yq, cloneYZTable[i].Yq); Assert.AreEqual(yzDataTable[i].Z, cloneYZTable[i].Z); Assert.AreNotSame(yzDataTable[i], cloneYZTable[i]); } //assert a change in the original does not affect the clone yzDataTable[0].DeltaZStorage = 6; Assert.IsTrue(cloneYZTable.GetType() == typeof(FastYZDataTable)); Assert.AreNotEqual(6, cloneYZTable[0].DeltaZStorage); }
public void CopyFrom() { var crossSectionYZ = new CrossSectionDefinitionYZ(); //simple V profile crossSectionYZ.YZDataTable.AddCrossSectionYZRow(0, 10, 2); crossSectionYZ.YZDataTable.AddCrossSectionYZRow(5, 0, 1); crossSectionYZ.YZDataTable.AddCrossSectionYZRow(10, 10, 2); crossSectionYZ.Thalweg = 5.0; var copyFrom = new CrossSectionDefinitionYZ { Thalweg = 1.0 }; copyFrom.CopyFrom(crossSectionYZ); Assert.AreEqual(crossSectionYZ.Thalweg, copyFrom.Thalweg); CrossSectionDataSet.CrossSectionYZDataTable yzDataTable = crossSectionYZ.YZDataTable; CrossSectionDataSet.CrossSectionYZDataTable copyYZTable = copyFrom.YZDataTable; Assert.AreEqual(yzDataTable.Rows.Count, copyYZTable.Rows.Count); Assert.AreEqual(5.0, crossSectionYZ.Thalweg); for (int i = 0; i < yzDataTable.Count; i++) { Assert.AreEqual(yzDataTable[i].DeltaZStorage, copyYZTable[i].DeltaZStorage); Assert.AreEqual(yzDataTable[i].Yq, copyYZTable[i].Yq); Assert.AreEqual(yzDataTable[i].Z, copyYZTable[i].Z); Assert.AreNotSame(yzDataTable[i], copyYZTable[i]); } //assert a change in the original does not affect the clone yzDataTable[0].DeltaZStorage = 6; Assert.AreNotEqual(6, copyYZTable[0].DeltaZStorage); }