src/GenFx.Components.Tests/TreeHelperTest.cs
/// <summary>
/// Tests that the <see cref="TreeHelper.Swap"/> method works correctly.
/// </summary>
Tests that the  method works correctly.
Tests that the method works correctly .
[Fact]
        public void TreeHelper_Swap()
        {
            TestTree entity1 = new TestTree();
            TreeNode node1 = new TreeNode();
            entity1.SetRootNode(node1);
            TreeNode childNode1 = new TreeNode();
            TreeNode grandChildNode1 = new TreeNode();
            node1.AppendChild(childNode1);
            childNode1.AppendChild(grandChildNode1);
            TestTree entity2 = new TestTree();
            TreeNode node2 = new TreeNode();
            entity2.SetRootNode(node2);
            TreeNode childNode2 = new TreeNode();
            TreeNode grandChildNode2 = new TreeNode();
            node2.AppendChild(childNode2);
            childNode2.AppendChild(grandChildNode2);
            TreeHelper.Swap(entity1.RootNode, entity2.RootNode.ChildNodes[0]);
            Assert.Same(childNode2, entity1.RootNode);
            Assert.Null(childNode2.ParentNode);
            Assert.Same(entity1, childNode2.Tree);
            Assert.Same(entity1, grandChildNode2.Tree);
            Assert.Same(node2, entity2.RootNode);
            Assert.Same(node1, entity2.RootNode.ChildNodes[0]);
            Assert.Same(node2, node1.ParentNode);
            Assert.Same(entity2, node1.Tree);
            Assert.Same(entity2, childNode1.Tree);
            Assert.Same(entity2, grandChildNode1.Tree);
        }
[ Fact ] public void TreeHelper_Swap ( ) { TestTree entity1 = new TestTree ( ) ; TreeNode node1 = new TreeNode ( ) ; entity1 . SetRootNode ( node1 ) ; TreeNode childNode1 = new TreeNode ( ) ; TreeNode grandChildNode1 = new TreeNode ( ) ; node1 . AppendChild ( childNode1 ) ; childNode1 . AppendChild ( grandChildNode1 ) ; TestTree entity2 = new TestTree ( ) ; TreeNode node2 = new TreeNode ( ) ; entity2 . SetRootNode ( node2 ) ; TreeNode childNode2 = new TreeNode ( ) ; TreeNode grandChildNode2 = new TreeNode ( ) ; node2 . AppendChild ( childNode2 ) ; childNode2 . AppendChild ( grandChildNode2 ) ; TreeHelper . Swap ( entity1 . RootNode , entity2 . RootNode . ChildNodes [ 0 ] ) ; Assert . Same ( childNode2 , entity1 . RootNode ) ; Assert . Null ( childNode2 . ParentNode ) ; Assert . Same ( entity1 , childNode2 . Tree ) ; Assert . Same ( entity1 , grandChildNode2 . Tree ) ; Assert . Same ( node2 , entity2 . RootNode ) ; Assert . Same ( node1 , entity2 . RootNode . ChildNodes [ 0 ] ) ; Assert . Same ( node2 , node1 . ParentNode ) ; Assert . Same ( entity2 , node1 . Tree ) ; Assert . Same ( entity2 , childNode1 . Tree ) ; Assert . Same ( entity2 , grandChildNode1 . Tree ) ; }
Tests that the  method works correctly.
Tests that the method works correctly .