Exemple #1
0
        public void TestConnectTheNodeToOtherNode_Test2_RootTest()
        {
            //K
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            AddNodeWholeTreeTestHelper(ref tree);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEB", tree, "after initialization");
            Assert.AreEqual(2, tree.GetRoots().Count, "there should be 2 roots");
            tree.AddNode(L);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBL", tree, "after L adding");
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.AddNode(M);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBLM", tree, "after M adding");
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.ConnectTheNodeToOtherNode(L, 0, M, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBML", tree, "after connecting L and M");
            tree.AddNode(N);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBMLN", tree, "after N adding");
            tree.ConnectTheNodeToOtherNode(J, 0, L, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFMLJGDAKHIEBN", tree, "after connecting J and L");
        }
Exemple #2
0
        public void TestConnectTheNodeToOtherNode_Test2_RootTest2()
        {
            //K
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            AddNodeWholeTreeTestHelper(ref tree);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEB", tree, "after initialization");
            Assert.AreEqual(2, tree.GetRoots().Count, "there should be 2 roots");
            tree.AddNode(L);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBL", tree, "after L adding");
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.RemoveConnectionBetweeenParentAndChildAndMoveElementToRoots(K, A);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.AddNode(M);
            Assert.AreEqual(5, tree.GetRoots().Count, "there should be 5 roots");
            //do tego dazymy:
            //K M
            //|/
            //L  (to jest splitter)
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            tree.ConnectTheNodeToOtherNode(L, 0, A, 0);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.ConnectTheNodeToOtherNode(M, 0, L, 1);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.ConnectTheNodeToOtherNode(K, 0, L, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDALKHIEBM", tree, "after all (after splitter adding)");
        }