Exemple #1
0
    public void EnableHierarchy_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.DisableHierarchy(five);
        tree.DisableHierarchy(four);
        string[] output = new string[5];
        int      i      = 0;

        tree.EnableHierarchy(two);
        tree.TraversePreOrder((item) => {
            output[i++] = item.name;
        });
        Assert.AreEqual(new[] { "one", "three", "four", "five", "six" }, output);
        Assert.AreEqual(5, tree.Size);
    }
Exemple #2
0
    public void Event_EnableHierarchy()
    {
        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.HierarchyEnabled)
            {
                callCount++;
            }
        };
        tree.AddItem(one);
        tree.AddItem(two);
        tree.DisableHierarchy(two);
        tree.EnableHierarchy(two);
        Assert.AreEqual(1, callCount);
    }