コード例 #1
0
        public void TestRemove()
        {
            var coordinates = new HugeCoordinateCollectionIndex(10);
            coordinates.Add(0, new CoordinateArrayCollection<GeoCoordinate>(
                new GeoCoordinate[] { }));

            coordinates.Remove(0);

            ICoordinateCollection actual;
            Assert.IsFalse(coordinates.TryGet(0, out actual));
            Assert.Catch<KeyNotFoundException>(() =>
            {
                actual = coordinates[0];
            });

            coordinates = new HugeCoordinateCollectionIndex(10);
            coordinates.Add(0, null);

            coordinates.Remove(0);

            Assert.IsFalse(coordinates.TryGet(0, out actual));
            Assert.Catch<KeyNotFoundException>(() =>
            {
                actual = coordinates[0];
            });
        }
コード例 #2
0
        public void TestCompress()
        {
            // build a coordinate collection.
            var coordinates = new HugeCoordinateCollectionIndex(100);
            coordinates.Add(0, new CoordinateArrayCollection<GeoCoordinate>(
                new GeoCoordinate[] {
                    new GeoCoordinate(0, 0),
                    new GeoCoordinate(1, 1) }));
            coordinates.Add(1, new CoordinateArrayCollection<GeoCoordinate>(
                new GeoCoordinate[] {
                    new GeoCoordinate(2, 2),
                    new GeoCoordinate(3, 3) }));

            // compress.
            coordinates.Compress();

            // check if everything is still there.
            Assert.AreEqual(8, coordinates.LengthCoordinates);
            Assert.AreEqual(2, coordinates.LengthIndex);
            Assert.IsTrue(coordinates[0].ElementAt(0).Latitude == 0);
            Assert.IsTrue(coordinates[0].ElementAt(0).Longitude == 0);
            Assert.IsTrue(coordinates[0].ElementAt(1).Latitude == 1);
            Assert.IsTrue(coordinates[0].ElementAt(1).Longitude == 1);
            Assert.IsTrue(coordinates[1].ElementAt(0).Latitude == 2);
            Assert.IsTrue(coordinates[1].ElementAt(0).Longitude == 2);
            Assert.IsTrue(coordinates[1].ElementAt(1).Latitude == 3);
            Assert.IsTrue(coordinates[1].ElementAt(1).Longitude == 3);

            // build a coordinate collection and remove some data.
            coordinates = new HugeCoordinateCollectionIndex(100);
            coordinates.Add(0, new CoordinateArrayCollection<GeoCoordinate>(
                new GeoCoordinate[] {
                    new GeoCoordinate(0, 0),
                    new GeoCoordinate(1, 1) }));
            coordinates.Add(1, new CoordinateArrayCollection<GeoCoordinate>(
                new GeoCoordinate[] {
                    new GeoCoordinate(2, 2),
                    new GeoCoordinate(3, 3) }));
            coordinates.Remove(0);

            // compress.
            coordinates.Compress();

            // check if everything is still there.
            Assert.AreEqual(4, coordinates.LengthCoordinates);
            Assert.AreEqual(2, coordinates.LengthIndex);
            ICoordinateCollection actual;
            Assert.IsFalse(coordinates.TryGet(0, out actual));
            Assert.IsTrue(coordinates[1].ElementAt(0).Latitude == 2);
            Assert.IsTrue(coordinates[1].ElementAt(0).Longitude == 2);
            Assert.IsTrue(coordinates[1].ElementAt(1).Latitude == 3);
            Assert.IsTrue(coordinates[1].ElementAt(1).Longitude == 3);
        }