public void CorrectNodesWhenDefaultPathEntered()
 {
     //arrange
     var vm = new BinaryTree();
     //act
     vm.AddDefaultTreeCommand.Execute(null);
     //assert
     Assert.IsTrue(vm.Contains(BinaryTree.NodeList[1]));
 }
 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);
 }
 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);
 }
            public void CorrectOrderWhenFiveEntered()
            {
                //arrange
                /* before
                     10
                  5
                 4  6
                2
                 */
                //remove 5
                /* after
                    10
                 4
                2  6
                */
                var viewModel = new BinaryTree();

                viewModel.AddSearchNode(new Node
                {
                    Value = 10
                });

                var node = new Node
                    {
                        Value = 5
                    };

                viewModel.AddSearchNode(node);

                viewModel.AddSearchNode(new Node
                {
                    Value = 4
                });

                viewModel.AddSearchNode(new Node
                {
                    Value = 6
                });

                viewModel.AddSearchNode(new Node
                {
                    Value = 2
                });
                //state check
                Assert.IsTrue(viewModel.Contains(node));
                //act
                viewModel.RemoveNode(node);

                //assert
                Assert.IsFalse(viewModel.Contains(node));
            }