public void Branch_RemoveUnknownBrush_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result = branch.Remove(brush); Assert.AreEqual(false, result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.AreEqual(false, brush.Dirty); Assert.AreEqual(false, branch.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(0, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void CreateBranch_WithoutUserID() { CSGTreeBranch branch = CSGTreeBranch.Create(); TestUtility.ExpectValidBranchWithUserID(ref branch, 0); Assert.IsTrue(branch.Dirty); }
public void BranchWithBranch_DestroyBranch_BranchIsEmpty() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2, new CSGTreeNode[] { branch1 }); CSGManager.ClearDirty(branch1); CSGManager.ClearDirty(branch2); var result = branch1.Destroy(); Assert.AreEqual(true, result); TestUtility.ExpectInvalidBranch(ref branch1); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(0, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(0, branch2.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(1, CSGManager.TreeNodeCount); }
public void Branch_AddBrush_ContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(userID: branchUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result = branch.Add(brush); Assert.AreEqual(true, result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(branch.NodeID, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(1, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void Tree_AddSameBranchTwice_ReturnsFalse() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CSGManager.ClearDirty(branch); CSGManager.ClearDirty(tree); var result1 = tree.Add(branch); var result2 = tree.Add(branch); Assert.AreEqual(true, result1); Assert.AreEqual(false, result2); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(0, tree.CountOfBrushesInTree); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(tree.NodeID, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void Tree_SetChildrenWithBranch_ContainsBranch() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CSGManager.ClearDirty(branch); CSGManager.ClearDirty(tree); tree.InsertRange(0, new CSGTreeNode[] { branch }); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(tree.NodeID, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void BranchWithChildBranch_Clear_BranchIsEmpty() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2, new CSGTreeNode[] { branch1 }); CSGManager.ClearDirty(branch1); CSGManager.ClearDirty(branch2); branch2.Clear(); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); Assert.AreEqual(true, branch1.Dirty); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(0, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(0, branch2.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void Tree_AddBranchAddBrushReversed_ContainsBranchThatContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; const int treeUserID = 12; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); var result1 = tree.Add(branch); var result2 = branch.Add(brush); Assert.IsTrue(result1); Assert.IsTrue(result2); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsTrue(branch.Dirty); Assert.IsTrue(tree.Dirty); Assert.IsTrue(brush.Dirty); Assert.IsTrue(TestUtility.IsInTree(tree, brush)); Assert.AreEqual(1, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Tree); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Tree); }
public void Branch_SetChildrenWithAncestore_DoesNotContainAncestor() { const int branchUserID1 = 10; const int branchUserID2 = 11; const int branchUserID3 = 12; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); var branch3 = CSGTreeBranch.Create(branchUserID3); branch1.Add(branch2); branch2.Add(branch3); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); CompactHierarchyManager.ClearDirty(branch3); branch3.InsertRange(0, new CSGTreeNode[] { branch1 }); LogAssert.Expect(LogType.Error, new Regex("Cannot add a descendant")); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); TestUtility.ExpectValidBranchWithUserID(ref branch3, branchUserID3); Assert.IsFalse(branch1.Dirty); Assert.IsFalse(branch2.Dirty); Assert.IsFalse(branch3.Dirty); Assert.IsFalse(branch3.Tree.Valid); Assert.IsFalse(branch2.Tree.Valid); Assert.IsFalse(branch1.Parent.Valid); Assert.IsFalse(branch1.Tree.Valid); Assert.AreEqual(1, branch2.Count); Assert.AreEqual(0, branch3.Count); Assert.AreEqual(1, branch1.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)branch3.Parent); Assert.AreEqual((CSGTreeNode)branch1, (CSGTreeNode)branch2.Parent); }
public void Branch_AddAncestor_ReturnsFalse() { const int branchUserID1 = 10; const int branchUserID2 = 11; const int branchUserID3 = 12; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); var branch3 = CSGTreeBranch.Create(branchUserID3); branch1.Add(branch2); branch2.Add(branch3); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); CompactHierarchyManager.ClearDirty(branch3); var result = branch3.Add(branch1); Assert.IsFalse(result); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); TestUtility.ExpectValidBranchWithUserID(ref branch3, branchUserID3); Assert.IsFalse(branch3.Tree.Valid); Assert.IsFalse(branch3.Dirty); Assert.IsFalse(branch2.Tree.Valid); Assert.IsFalse(branch2.Dirty); Assert.IsFalse(branch1.Parent.Valid); Assert.IsFalse(branch1.Tree.Valid); Assert.IsFalse(branch1.Dirty); Assert.AreEqual(0, branch3.Count); Assert.AreEqual(1, branch2.Count); Assert.AreEqual(1, branch1.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)branch3.Parent); Assert.AreEqual((CSGTreeNode)branch1, (CSGTreeNode)branch2.Parent); }
public void Branch_AddSameBranchTwice_ReturnsFalse() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); var result1 = branch2.Add(branch1); var result2 = branch2.Add(branch1); Assert.IsTrue(result1); Assert.IsFalse(result2); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.IsTrue(branch1.Dirty); Assert.IsTrue(branch2.Dirty); Assert.IsFalse(branch1.Tree.Valid); Assert.IsFalse(branch2.Parent.Valid); Assert.IsFalse(branch2.Tree.Valid); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(1, branch2.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)branch1.Parent); }
public void BranchWithSingleChild_RemoveLastNode_IsEmptyBranch() { const int branchUserID = 10; const int brushUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush }); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result = branch.RemoveAt(0); Assert.AreEqual(true, result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void Branch_InsertBrushNegativeIndex_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result = branch.Insert(-1, brush); Assert.AreEqual(false, result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.AreEqual(false, brush.Dirty); Assert.AreEqual(false, branch.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void Branch_SetChildrenWithBranch_ContainsBranch() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CSGManager.ClearDirty(branch1); CSGManager.ClearDirty(branch2); branch2.InsertRange(0, new CSGTreeNode[] { branch1 }); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.AreEqual(true, branch1.Dirty); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(branch2.NodeID, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(1, branch2.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(2, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void BranchWithTwoChildren_RemoveLastNode_StillHasFirstNode() { const int branchUserID = 10; const int brushUserID1 = 11; const int brushUserID2 = 12; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush1, brush2 }); CSGManager.ClearDirty(brush1); CSGManager.ClearDirty(brush2); CSGManager.ClearDirty(branch); var result = branch.RemoveAt(1); Assert.AreEqual(true, result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); Assert.AreEqual(false, brush1.Dirty); Assert.AreEqual(true, brush2.Dirty); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(branch.NodeID, brush1.Parent.NodeID); Assert.AreEqual(0, brush1.Tree.NodeID); Assert.AreEqual(0, brush2.Parent.NodeID); Assert.AreEqual(0, brush2.Tree.NodeID); Assert.AreEqual(1, branch.Count); Assert.AreEqual(brush1.NodeID, branch[0].NodeID); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(2, CSGManager.TreeBrushCount, "Expected 2 TreeBrushes to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); }
public void Tree_SetChildrenWithBranchWithBrushReversed_ContainsBranchThatContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; const int treeUserID = 12; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); tree.InsertRange(0, new CSGTreeNode[] { branch }); branch.InsertRange(0, new CSGTreeNode[] { brush }); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsTrue(brush.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsTrue(tree.Dirty); Assert.IsTrue(TestUtility.IsInTree(tree, brush)); Assert.AreEqual(1, TestUtility.CountOfBrushesInTree(tree)); Assert.AreEqual(1, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Tree); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Tree); }
public void GenerateAllTreeNodes() { var instanceID = GetInstanceID(); var instances = brushContainerAsset ? brushContainerAsset.Instances : null; var requiredNodeLength = RequiredNodeLength(instances); if (requiredNodeLength == 0) { Nodes = new CSGTreeNode[1]; Nodes[0] = CSGTreeBrush.Create(userID: instanceID, localTransformation: TopTransformation, operation: operation); } else if (requiredNodeLength == 1) { Nodes = new CSGTreeNode[1]; Nodes[0] = CSGTreeBrush.Create(userID: instanceID, localTransformation: TopTransformation, operation: operation); } else { Nodes = new CSGTreeNode[requiredNodeLength]; var children = new CSGTreeNode[requiredNodeLength - 1]; for (int i = 0; i < requiredNodeLength - 1; i++) { children[i] = CSGTreeBrush.Create(userID: instanceID); } Nodes[0] = CSGTreeBranch.Create(instanceID, operation, children); for (int i = 1; i < Nodes.Length; i++) { Nodes[i] = children[i - 1]; } } Nodes[0].Operation = operation; Nodes[0].LocalTransformation = TopTransformation; }
public void BranchWithTwoChildren_RemoveFirstNode_StillHasLastNode() { const int branchUserID = 10; const int brushUserID1 = 11; const int brushUserID2 = 12; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush1, brush2 }); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(branch); var result = branch.RemoveAt(0); Assert.IsTrue(result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); Assert.IsTrue(brush1.Dirty); Assert.IsFalse(brush2.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush1.Parent.Valid); Assert.IsFalse(brush1.Tree.Valid); Assert.IsFalse(brush2.Tree.Valid); Assert.AreEqual(1, branch.Count); Assert.AreEqual((CSGTreeNode)brush2, (CSGTreeNode)branch[0]); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush2.Parent); }
public void Tree_SetChildrenWithBranchWithBrushReversed_ContainsBranchThatContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; const int treeUserID = 12; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); CSGManager.ClearDirty(tree); tree.InsertRange(0, new CSGTreeNode[] { branch }); branch.InsertRange(0, new CSGTreeNode[] { brush }); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(true, tree.IsInTree(brush)); Assert.AreEqual(1, tree.CountOfBrushesInTree); Assert.AreEqual(branch.NodeID, brush.Parent.NodeID); Assert.AreEqual(tree.NodeID, brush.Tree.NodeID); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(tree.NodeID, branch.Tree.NodeID); Assert.AreEqual(1, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); }
public void Branch_AddSameBrushTwice_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result1 = branch.Add(brush); var result2 = branch.Add(brush); Assert.AreEqual(true, result1); Assert.AreEqual(false, result2); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(branch.NodeID, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(1, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void BranchWithChildBrush_Clear_BranchIsEmpty() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush }); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); branch.Clear(); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(0, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void Branch_AddBranch_ContainsBranch() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CSGManager.ClearDirty(branch1); CSGManager.ClearDirty(branch2); var result = branch2.Add(branch1); Assert.AreEqual(true, result); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.AreEqual(true, branch1.Dirty); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(branch2.NodeID, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(1, branch2.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void Branch_AddSameBranchTwice_ReturnsFalse() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CSGManager.ClearDirty(branch1); CSGManager.ClearDirty(branch2); var result1 = branch2.Add(branch1); var result2 = branch2.Add(branch1); Assert.AreEqual(true, result1); Assert.AreEqual(false, result2); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.AreEqual(true, branch1.Dirty); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(branch2.NodeID, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(1, branch2.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(2, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }
public void Tree_AddBranch_ContainsBranch() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CSGManager.ClearDirty(branch); CSGManager.ClearDirty(tree); var result = tree.Add(branch); Assert.AreEqual(true, result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(0, tree.CountOfBrushesInTree); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(tree.NodeID, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); }
public void CreateTreeWithChildren() { const int brushUserID = 10; const int branchUserID = 11; const int treeUserID = 12; CSGTreeBrush brush = CSGTreeBrush.Create(userID: brushUserID); CSGTreeBranch branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); CSGTree tree = CSGTree.Create(treeUserID, new CSGTreeNode[] { brush, branch }); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsTrue(branch.Dirty); Assert.IsTrue(tree.Dirty); Assert.IsTrue(brush.Dirty); Assert.AreEqual(0, branch.Count); Assert.AreEqual(2, tree.Count); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Tree); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Tree); }
public void CreateTreeWithChildren() { const int brushUserID = 10; const int branchUserID = 11; const int treeUserID = 12; CSGTreeBrush brush = CSGTreeBrush.Create(userID: brushUserID); CSGTreeBranch branch = CSGTreeBranch.Create(branchUserID); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); CSGTree tree = CSGTree.Create(treeUserID, new CSGTreeNode[] { brush, branch }); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(tree.NodeID, brush.Tree.NodeID); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(tree.NodeID, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(2, tree.Count); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(1, CSGManager.TreeCount); Assert.AreEqual(3, CSGManager.TreeNodeCount); }
public void CreateBranchWithChildren() { const int brushUserID = 10; const int branchUserID1 = 11; const int branchUserID2 = 12; CSGTreeBrush brush = CSGTreeBrush.Create(userID: brushUserID); CSGTreeBranch branch1 = CSGTreeBranch.Create(branchUserID1); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch1); CSGTreeBranch branch2 = CSGTreeBranch.Create(branchUserID2, new CSGTreeNode[] { brush, branch1 }); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.IsTrue(branch1.Dirty); Assert.IsTrue(branch2.Dirty); Assert.IsTrue(brush.Dirty); Assert.IsFalse(brush.Tree.Valid); Assert.IsFalse(branch1.Tree.Valid); Assert.IsFalse(branch2.Parent.Valid); Assert.IsFalse(branch2.Tree.Valid); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(2, branch2.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)branch1.Parent); }
public void CreateBranchWithChildren() { const int brushUserID = 10; const int branchUserID1 = 11; const int branchUserID2 = 12; CSGTreeBrush brush = CSGTreeBrush.Create(userID: brushUserID); CSGTreeBranch branch1 = CSGTreeBranch.Create(branchUserID1); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch1); CSGTreeBranch branch2 = CSGTreeBranch.Create(branchUserID2, new CSGTreeNode[] { brush, branch1 }); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.AreEqual(true, branch1.Dirty); Assert.AreEqual(true, branch2.Dirty); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(branch2.NodeID, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(branch2.NodeID, branch1.Parent.NodeID); Assert.AreEqual(0, branch1.Tree.NodeID); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(0, branch2.Parent.NodeID); Assert.AreEqual(0, branch2.Tree.NodeID); Assert.AreEqual(2, branch2.Count); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(2, CSGManager.TreeBranchCount); Assert.AreEqual(3, CSGManager.TreeNodeCount); }
public void TreeWithBranch_DestroyBranch_TreeIsEmpty() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); tree.InsertRange(0, new CSGTreeNode[] { branch }); CSGManager.ClearDirty(branch); CSGManager.ClearDirty(tree); var result = branch.Destroy(); Assert.AreEqual(true, result); TestUtility.ExpectInvalidBranch(ref branch); Assert.AreEqual(true, tree.Dirty); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(0, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, tree.Count); Assert.AreEqual(0, CSGManager.TreeBrushCount); Assert.AreEqual(0, CSGManager.TreeBranchCount); Assert.AreEqual(1, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeNodeCount); }
public void BranchWithChildBrush_RemoveSameBrushTwice_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush }); CSGManager.ClearDirty(brush); CSGManager.ClearDirty(branch); var result1 = branch.Remove(brush); var result2 = branch.Remove(brush); Assert.AreEqual(true, result1); Assert.AreEqual(false, result2); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.AreEqual(true, brush.Dirty); Assert.AreEqual(true, branch.Dirty); Assert.AreEqual(0, brush.Parent.NodeID); Assert.AreEqual(0, brush.Tree.NodeID); Assert.AreEqual(0, branch.Parent.NodeID); Assert.AreEqual(0, branch.Tree.NodeID); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, CSGManager.TreeCount); Assert.AreEqual(1, CSGManager.TreeBrushCount); Assert.AreEqual(1, CSGManager.TreeBranchCount); Assert.AreEqual(2, CSGManager.TreeNodeCount); }