예제 #1
0
 public void SuccessWhenRemoveNodeRightChildNoLeftChild()
 {
     //arrange
     var vm = new BinaryTree();
     var rightChildHasNoLeft = new List<Node>
     {
         new Node{Value = 4, IsExpanded = true, IsSelected = true},
         new Node{Value = 6, IsExpanded = true},
         new Node{Value = 5, IsExpanded = true},
         new Node{Value = 7, IsExpanded = true},
         new Node{Value = 8, IsExpanded = true},
     };
     rightChildHasNoLeft.ForEach(vm.AddSearchNode);
     var sixthNode = rightChildHasNoLeft.First(t => t.Value == 6);
     //act
     vm.RemoveNodeEntrance(sixthNode);
     //assert
     Assert.IsFalse(vm.Contains(sixthNode));
     Assert.IsTrue(vm.HeadNode.RightNode.Value == 7);
     Assert.IsTrue(vm.HeadNode.RightNode.LeftNode.Value == 5);
     Assert.IsTrue(vm.HeadNode.RightNode.RightNode.Value == 8);
 }
예제 #2
0
 public void SuccessWhenRemoveNodeNorightChild()
 {
     //arrange
     var vm = new BinaryTree();
     vm.AddDefaultTreeCommand.Execute(null);
     var eightNode = BinaryTree.NodeList.First(t => t.Value == 8);
     //act
     vm.RemoveNodeEntrance(eightNode);
     //assert
     Assert.IsFalse(vm.Contains(eightNode));
     Assert.IsTrue(vm.HeadNode.RightNode.Value == 6);
     Assert.IsTrue(vm.HeadNode.RightNode.LeftNode.Value == 5);
     Assert.IsTrue(vm.HeadNode.RightNode.RightNode.Value == 7);
 }