コード例 #1
0
        public void Insert_InsertStudentBAsLeftChildOfStudentA_ShouldReturnRootLeftInsertedNodeWithResult40()
        {
            //arrange
            Student          A      = new Student("", "", "", 50);
            Student          B      = new Student("", "", "", 40);
            BSTree <Student> bSTree = new BSTree <Student>(A);

            //act
            bSTree.Insert(B);
            BSTreeNode <Student> nodeRes = bSTree.Root.Left;
            Student inserted             = nodeRes.Data;

            //assert
            Assert.AreEqual(40, inserted.TestResult);
        }
コード例 #2
0
        public void Insert_InsertStudentsWithSameScoreButDiferentSurnames_BStudentShouldBeLeftChild()
        {
            //arrange
            Student          A      = new Student("", "Chumak", "", 50);
            Student          B      = new Student("", "Adamenko", "", 50);
            BSTree <Student> bSTree = new BSTree <Student>(A);

            //act
            bSTree.Insert(B);
            BSTreeNode <Student> nodeRes = bSTree.Root.Left;
            Student inserted             = nodeRes.Data;

            //assert
            Assert.AreEqual(50, inserted.TestResult);
        }
コード例 #3
0
        public void BSTreeTest_SetUp()
        {
            // Init IntTree.
            {
                var type = typeof(BSTree <int>);
                var prop = type.GetProperty("RootNode", BindingFlags.Instance | BindingFlags.NonPublic);

                this.IntTree.Insert(11); // { 01 }
                this.IntTree.Insert(07); // { 02 }
                this.IntTree.Insert(15); // { 03 }
                this.IntTree.Insert(05); // { 04 }
                this.IntTree.Insert(03); // { 05 }
                this.IntTree.Insert(09); // { 06 }
                this.IntTree.Insert(08); // { 07 }
                this.IntTree.Insert(10); // { 08 }
                this.IntTree.Insert(13); // { 09 }
                this.IntTree.Insert(12); // { 10 }
                this.IntTree.Insert(14); // { 11 }
                this.IntTree.Insert(20); // { 12 }
                this.IntTree.Insert(18); // { 13 }
                this.IntTree.Insert(25); // { 14 }

                this.IntTreeRootNode = prop.GetValue(this.IntTree) as BSTreeNode <int>;
            }

            // Init StrTree.
            {
                var type = typeof(BSTree <string>);
                var prop = type.GetProperty("RootNode", BindingFlags.Instance | BindingFlags.NonPublic);

                this.StrTree.Insert("Must");   // { 01 }
                this.StrTree.Insert("Have");   // { 02 }
                this.StrTree.Insert("Should"); // { 03 }
                this.StrTree.Insert("Was");    // { 04 }
                this.StrTree.Insert("Did");    // { 05 }
                this.StrTree.Insert("Will");   // { 06 }
                this.StrTree.Insert("They");   // { 07 }
                this.StrTree.Insert("I");      // { 08 }
                this.StrTree.Insert("She");    // { 09 }
                this.StrTree.Insert("He");     // { 10 }

                this.StrTreeRootNode = prop.GetValue(this.StrTree) as BSTreeNode <string>;
            }
        }