Example #1
0
        public void AddTwoDifferentChildsChangeParentCheckStateToIndeterminate()
        {
            //Arrange
            node = new NestedTripleTreeNode("Root", null, System.Windows.Forms.CheckState.Checked);
            NestedTripleTreeNode child1 = new NestedTripleTreeNode("Child 1", null, System.Windows.Forms.CheckState.Unchecked);
            NestedTripleTreeNode child2 = new NestedTripleTreeNode("Child 2", null, System.Windows.Forms.CheckState.Checked);

            //Act
            node.AddChild(child1);
            node.AddChild(child2);

            //Assert
            Assert.AreEqual(System.Windows.Forms.CheckState.Indeterminate, node.CheckState);
            Assert.AreEqual(System.Windows.Forms.CheckState.Unchecked, child1.CheckState);
            Assert.AreEqual(System.Windows.Forms.CheckState.Checked, child2.CheckState);
        }
Example #2
0
        public void RemoveOneOfTwoDifferentChildrenFromIndeterminateParentChangeParentCheckState()
        {
            //Arrange
            node = new NestedTripleTreeNode("Root", value: null);
            NestedTripleTreeNode child1 = new NestedTripleTreeNode("Child 1", value: null, state: System.Windows.Forms.CheckState.Unchecked);
            NestedTripleTreeNode child2 = new NestedTripleTreeNode("Child 2", value: null, state: System.Windows.Forms.CheckState.Checked);

            node.AddChild(child1);
            node.AddChild(child2);

            //Act
            node.RemoveChild(child1);

            //Assert
            Assert.AreEqual(System.Windows.Forms.CheckState.Checked, node.CheckState);
            Assert.AreEqual(System.Windows.Forms.CheckState.Checked, child2.CheckState);
        }
Example #3
0
        /// <summary>
        /// Создает тестовое дерево, которое можно отобразить на TreeView.
        /// </summary>
        /// <returns>Корень тестового дерева.</returns>
        public static NestedTripleTreeNode CreateTestTree()
        {
            NestedTripleTreeNode node  = new NestedTripleTreeNode("Root");
            NestedTripleTreeNode node1 = new NestedTripleTreeNode("1");

            NestedTripleTreeNode node211 = new NestedTripleTreeNode("2.1.1");
            NestedTripleTreeNode node212 = new NestedTripleTreeNode("2.1.2");

            NestedTripleTreeNode node21 = new NestedTripleTreeNode("2.1");

            node21.AddChild(node211);
            node21.AddChild(node212);

            NestedTripleTreeNode node22 = new NestedTripleTreeNode("2.2");

            NestedTripleTreeNode node2 = new NestedTripleTreeNode("2");

            node2.AddChild(node21);
            node2.AddChild(node22);

            NestedTripleTreeNode node31 = new NestedTripleTreeNode("3.1");
            NestedTripleTreeNode node32 = new NestedTripleTreeNode("3.2");
            NestedTripleTreeNode node33 = new NestedTripleTreeNode("3.3");

            NestedTripleTreeNode node3 = new NestedTripleTreeNode("3");

            node3.AddChild(node31);
            node3.AddChild(node32);
            node3.AddChild(node33);

            NestedTripleTreeNode node4 = new NestedTripleTreeNode("4");

            node.AddChild(node1);
            node.AddChild(node2);
            node.AddChild(node3);
            node.AddChild(node4);

            return(node);
        }
Example #4
0
        public void AddUncheckedChildToCheckedParentChangeParentCheckStateToUnchecked()
        {
            //Arrange
            node = new NestedTripleTreeNode("Root", null, System.Windows.Forms.CheckState.Checked);
            NestedTripleTreeNode child = new NestedTripleTreeNode("Child 1", null, System.Windows.Forms.CheckState.Unchecked);

            //Act
            node.AddChild(child);

            //Assert
            Assert.AreEqual(System.Windows.Forms.CheckState.Unchecked, node.CheckState);
            Assert.AreEqual(System.Windows.Forms.CheckState.Unchecked, child.CheckState);
        }
Example #5
0
        public void RemoveSingleChildrenFromParentNotChangeParentCheckState()
        {
            //Arrange
            node = new NestedTripleTreeNode("Root", value: null);
            NestedTripleTreeNode child1 = new NestedTripleTreeNode("Child 1", value: null, state: System.Windows.Forms.CheckState.Unchecked);

            node.AddChild(child1);

            //Act
            node.RemoveChild(child1);

            //Assert
            Assert.AreEqual(System.Windows.Forms.CheckState.Unchecked, node.CheckState);
        }
Example #6
0
        public void CanAddChildNode()
        {
            //Arrange
            NestedTripleTreeNode child1 = new NestedTripleTreeNode("Child 1");

            //Act
            node.AddChild(child1);

            //Assert
            Assert.AreSame(child1, node.Nodes[0]);
            Assert.AreSame(node, child1.Parent);
        }