public void UpdateItemBoundsDoesNotCallAddRemoveNotificationMethods() { var c2 = new SpatialCollection <BoundedObject>(); var c3 = new SpatialCollection <BoundedObject>(); var a = new BoundedObjectWithParentList(new Vector2(0, 0), new Vector2(15, 15)); Collection.Add(a); c2.Add(a); c3.Add(a); a.Bounds = a.Bounds.Translate(Vector2.One * 128f); foreach (var collection in a.Parents) { var strongCollection = (SpatialCollection <BoundedObject>)collection.Target; strongCollection.UpdateItemBounds(a); } }
public void BasicTest() { var a = new BoundedObject(new Vector2(0, 0), new Vector2(15, 15)); var b = new BoundedObject(new Vector2(8, 8), new Vector2(23, 23)); var c = new BoundedObject(new Vector2(16, 16), new Vector2(31, 31)); Collection.Add(a); Collection.Add(b); Collection.Add(c); Assert.AreEqual(Sorted(a, b, c), Sorted(Collection.ToArray())); Assert.AreEqual(Sorted(a, b), Sorted(Collection.GetItemsFromBounds(a.Bounds).ToArray())); Assert.AreEqual(Sorted(a, b, c), Sorted(Collection.GetItemsFromBounds(b.Bounds).ToArray())); Assert.AreEqual(Sorted(b, c), Sorted(Collection.GetItemsFromBounds(c.Bounds).ToArray())); a.Bounds = new Bounds(new Vector2(24, 24), new Vector2(47, 47)); Collection.UpdateItemBounds(a); Assert.AreEqual(Sorted(b, c, a), Sorted(Collection.GetItemsFromBounds(a.Bounds).ToArray())); Assert.AreEqual(Sorted(b, c, a), Sorted(Collection.GetItemsFromBounds(b.Bounds).ToArray())); Assert.AreEqual(Sorted(b, c, a), Sorted(Collection.GetItemsFromBounds(c.Bounds).ToArray())); }