Example #1
0
        public void AddsMultipleAndRemovesSingleEntry()
        {
            var index = new SpatialIndex <MockGameObject>();

            var p1  = new Point(0, 0);
            var obj = new MockGameObject(p1);

            index.Insert(p1, obj);

            var p2 = new Point(-55, 654);

            index.Insert(p2, new MockGameObject(p2));

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 2);

            // Validate bucket count
            var bucket = index.Get(p1);

            Assert.AreEqual(bucket.Count, 1);

            index.Remove(p1, obj);

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 1);
        }
Example #2
0
        public void AddsAndRemovesSingleEntry()
        {
            var index = new SpatialIndex <MockGameObject>();

            var p   = new Point(0, 0);
            var obj = new MockGameObject(p);

            index.Insert(p, obj);

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 1);

            // Validate bucket count
            var bucket = index.Get(p);

            Assert.AreEqual(bucket.Count, 1);

            index.Remove(p, obj);

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 0);
        }