public void TestAddWithElevation() { using (var map = new MemoryMapStream()) { var array = new ShapesArray(map, 1024); array.Set(0, new Coordinate(0, 0.1f, 10), new Coordinate(1, 1.1f, 11)); var shape = array[0]; Assert.IsNotNull(shape); Assert.AreEqual(2, shape.Count); Assert.AreEqual(0, shape[0].Latitude, .00001); Assert.AreEqual(0.1, shape[0].Longitude, .00001); Assert.AreEqual(10, shape[0].Elevation); Assert.AreEqual(1, shape[1].Latitude, .00001); Assert.AreEqual(1.1, shape[1].Longitude, .00001); Assert.AreEqual(11, shape[1].Elevation); } using (var map = new MemoryMapStream()) { var box = new Box( new Coordinate(-90, -180), new Coordinate(90, 180)); var refArray = new ShapeBase[1024]; var array = new ShapesArray(map, 1024); var rand = new Randomizer(1587341311); for (var i = 0; i < 1024; i++) { var count = rand.Next(10); var newShape = new List <Coordinate>(count); for (var j = 0; j < count; j++) { newShape.Add(box.GenerateRandomIn()); } var shape = new ShapeEnumerable(newShape); refArray[i] = shape; array[i] = shape; } for (var i = 0; i < refArray.Length; i++) { var refShape = refArray[i]; var shape = array[i]; Assert.IsNotNull(shape); for (var j = 0; j < shape.Count; j++) { Assert.AreEqual(refShape[j].Latitude, shape[j].Latitude); Assert.AreEqual(refShape[j].Longitude, shape[j].Longitude); Assert.AreEqual(refShape[j].Elevation, shape[j].Elevation); } } } }
public void TestCopyTo() { using (var map = new MemoryMapStream()) { var array = new ShapesArray(map, 1); array.Set(0, new Coordinate(0, 0.1f), new Coordinate(1, 1.1f)); using (var stream = new MemoryStream()) { Assert.AreEqual(16 + 8 + (4 * 4), array.CopyTo(stream)); } } }
public void TestSettingNull() { using (var map = new MemoryMapStream()) { var array = new ShapesArray(map, 10); array.Set(0, new Coordinate(0.0f, 0.1f), new Coordinate(1.0f, 1.1f)); array[0] = null; Assert.IsNull(array[0]); Assert.IsNull(array[4]); Assert.IsNull(array[7]); Assert.IsNull(array[2]); Assert.IsNull(array[8]); } }