public virtual void testSerializeMultiPoint() { try { java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream(); java.io.ObjectOutputStream oo = new java.io.ObjectOutputStream(streamOut); com.esri.core.geometry.MultiPoint pt = new com.esri.core.geometry.MultiPoint(); pt.add(10, 30); pt.add(120, 40); oo.writeObject(pt); java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut .toByteArray()); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(streamIn); com.esri.core.geometry.MultiPoint ptRes = (com.esri.core.geometry.MultiPoint)ii.readObject (); NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt)); } catch (System.Exception) { fail("MultiPoint serialization failure"); } // try // { // FileOutputStream streamOut = new FileOutputStream(m_thisDirectory + // "savedMultiPoint.txt"); // ObjectOutputStream oo = new ObjectOutputStream(streamOut); // MultiPoint pt = new MultiPoint(); // pt.add(10, 30); // pt.add(120, 40); // oo.writeObject(pt); // } // catch(Exception ex) // { // fail("MultiPoint serialization failure"); // } try { java.io.InputStream s = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization )).getResourceAsStream("savedMultiPoint.txt"); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(s); com.esri.core.geometry.MultiPoint ptRes = (com.esri.core.geometry.MultiPoint)ii.readObject (); NUnit.Framework.Assert.IsTrue(ptRes.getPoint(1).getY() == 40); } catch (System.Exception) { fail("MultiPoint serialization failure"); } }
public static void testCopy() { com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint( ); com.esri.core.geometry.Point pt0 = new com.esri.core.geometry.Point(0.0, 0.0, -1.0 ); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(0.0, 0.0, 1.0 ); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(0.0, 1.0, 1.0 ); mpoint.add(pt0); mpoint.add(pt1); mpoint.add(pt2); mpoint.removePoint(1); com.esri.core.geometry.MultiPoint mpCopy = (com.esri.core.geometry.MultiPoint)mpoint .copy(); NUnit.Framework.Assert.IsTrue(mpCopy.Equals(mpoint)); com.esri.core.geometry.Point pt; pt = mpCopy.getPoint(0); NUnit.Framework.Assert.IsTrue(pt.getX() == pt0.getX() && pt.getY() == pt0.getY()); pt = mpCopy.getPoint(1); NUnit.Framework.Assert.IsTrue(pt.getX() == pt2.getX() && pt.getY() == pt2.getY()); NUnit.Framework.Assert.IsTrue(mpCopy.getPointCount() == 2); }