public void RemoveAnElementHierarchy_NodeNotInTree() { SkipTree <Item> tree = new SkipTree <Item>(); var one = new Item(null, "one"); var two = new Item(null, "two"); var three = new Item(null, "three"); var four = new Item(two, "four"); var five = new Item(two, "five"); var six = new Item(two, "six"); tree.AddItem(one); // two not in tree tree.AddItem(three); tree.AddItem(four); tree.AddItem(five); tree.AddItem(six); tree.RemoveHierarchy(two); string[] output = new string[2]; int i = 0; tree.TraversePreOrder((item) => { output[i++] = item.name; }); Assert.AreEqual(new[] { "one", "three" }, output); Assert.AreEqual(2, tree.Size); }
public void Event_RemoveHierarchy() { int callCount = 0; SkipTree <Item> tree = new SkipTree <Item>(); var one = new Item(null, "one"); var two = new Item(null, "two"); tree.onTreeChanged += (changeType) => { if (changeType == SkipTree <Item> .TreeChangeType.HierarchyRemoved) { callCount++; } }; tree.AddItem(one); tree.AddItem(two); tree.DisableHierarchy(two); tree.RemoveHierarchy(two); Assert.AreEqual(1, callCount); }