public void RemoveManyTest() { var tree = MakeTree(); var inserted = new List <QuadtreeData>(); var numTargets = 1000; for (int i = 0; i < numTargets; i++) { var data = new QuadtreeData(new BasicActor() { Bounds = new RectangleF(0, 0, 1, 1) }); tree.Insert(data); inserted.Add(data); } var inTree = numTargets; Assert.Equal(inTree, tree.NumTargets()); foreach (var data in inserted) { data.RemoveFromAllParents(); Assert.Equal(--inTree, tree.NumTargets()); } }
public void ShakeAfterSplittingNotEmptyTest() { var tree = MakeTree(); tree.Split(); var data = new QuadtreeData(new BasicActor()); tree.Insert(data); tree.Shake(); Assert.Equal(1, tree.NumTargets()); }
public void ShakeWhenContainingManyTest() { var tree = MakeTree(); var numTargets = Quadtree.DefaultMaxObjectsPerNode + 1; for (int i = 0; i < numTargets; i++) { var data = new QuadtreeData(new BasicActor()); tree.Insert(data); } tree.Shake(); Assert.Equal(numTargets, tree.NumTargets()); }
public void ShakeWhenContainingThreeTest() { var tree = MakeTree(); var numTargets = 3; for (int i = 0; i < numTargets; i++) { var data = new QuadtreeData(new BasicActor()); tree.Insert(data); } tree.Shake(); Assert.Equal(numTargets, tree.NumTargets()); }
public void RemoveToEmptyTest() { var actor = new BasicActor() { Bounds = new RectangleF(-5f, -7f, 10.0f, 15.0f) }; var data = new QuadtreeData(actor); var tree = MakeTree(); tree.Insert(data); tree.Remove(data); Assert.Equal(0, tree.NumTargets()); }
public void QueryNonLeafManyTest() { var tree = MakeTree(); var numTargets = 2 * Quadtree.DefaultMaxObjectsPerNode; for (int i = 0; i < numTargets; i++) { var data = new QuadtreeData(new BasicActor()); tree.Insert(data); } var query = tree.Query(_quadTreeArea); Assert.Equal(numTargets, query.Count); Assert.Equal(tree.NumTargets(), query.Count); }