.
This commit is contained in:
@@ -237,7 +237,6 @@ public class HierarchyTests
|
||||
_hierarchy.AddChild(parent1, child);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
// Reparent the child to parent2
|
||||
_hierarchy.AddChild(parent2, child);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
@@ -333,13 +332,11 @@ public class HierarchyTests
|
||||
_hierarchy.Add(child1);
|
||||
_hierarchy.Add(child2);
|
||||
|
||||
// Initial hierarchy setup
|
||||
_hierarchy.AddChild(grandParent, parent);
|
||||
_hierarchy.AddChild(parent, child1);
|
||||
_hierarchy.AddChild(parent, child2);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
// Reparent child1 to child2
|
||||
_hierarchy.AddChild(child2, child1);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
@@ -357,14 +354,12 @@ public class HierarchyTests
|
||||
const int hierarchyDepth = 100;
|
||||
var objects = new object[hierarchyDepth];
|
||||
|
||||
// Create objects
|
||||
for (var i = 0; i < hierarchyDepth; i++)
|
||||
{
|
||||
objects[i] = new object();
|
||||
_hierarchy.Add(objects[i]);
|
||||
}
|
||||
|
||||
// Create a deep hierarchy
|
||||
for (var i = 1; i < hierarchyDepth; i++)
|
||||
{
|
||||
_hierarchy.AddChild(objects[i - 1], objects[i]);
|
||||
@@ -374,14 +369,12 @@ public class HierarchyTests
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Verify parent-child relationships
|
||||
for (var i = 1; i < hierarchyDepth; i++)
|
||||
{
|
||||
Assert.That(_hierarchy.GetParent(objects[i]), Is.EqualTo(objects[i - 1]));
|
||||
Assert.That(_hierarchy.IsInHierarchy(objects[0], objects[i]), Is.True);
|
||||
}
|
||||
|
||||
// Verify children
|
||||
for (var i = 0; i < hierarchyDepth - 1; i++)
|
||||
{
|
||||
var children = _hierarchy.GetChildren(objects[i]).ToList();
|
||||
@@ -409,7 +402,6 @@ public class HierarchyTests
|
||||
_hierarchy.AddChild(parent, child2);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
// Remove parent, which will also remove its children
|
||||
_hierarchy.Remove(parent);
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
@@ -431,10 +423,9 @@ public class HierarchyTests
|
||||
.ToList();
|
||||
|
||||
_hierarchy.Add(parent);
|
||||
children.ForEach(child => _hierarchy.Add(child));
|
||||
children.ForEach(parChild => _hierarchy.Add(parChild));
|
||||
|
||||
// Simulate concurrent child additions
|
||||
children.AsParallel().ForAll(child => { _hierarchy.AddChild(parent, child); });
|
||||
children.AsParallel().ForAll(parChild => { _hierarchy.AddChild(parent, parChild); });
|
||||
|
||||
_hierarchy.ProcessChanges();
|
||||
|
||||
@@ -446,13 +437,8 @@ public class HierarchyTests
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Null child
|
||||
Assert.That(_hierarchy.IsInHierarchy(new object(), null), Is.False);
|
||||
|
||||
// Null ancestor
|
||||
Assert.That(_hierarchy.IsInHierarchy(null, new object()), Is.False);
|
||||
|
||||
// Both null
|
||||
Assert.That(_hierarchy.IsInHierarchy(null, null), Is.False);
|
||||
});
|
||||
}
|
||||
@@ -505,12 +491,10 @@ public class HierarchyTests
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Verify deep hierarchy relationships
|
||||
Assert.That(_hierarchy.IsInHierarchy(grandParent, grandChild), Is.True);
|
||||
Assert.That(_hierarchy.IsInHierarchy(parent, grandChild), Is.True);
|
||||
Assert.That(_hierarchy.IsInHierarchy(child, grandChild), Is.True);
|
||||
|
||||
// Verify inverse relationships are false
|
||||
Assert.That(_hierarchy.IsInHierarchy(grandChild, grandParent), Is.False);
|
||||
Assert.That(_hierarchy.IsInHierarchy(grandChild, parent), Is.False);
|
||||
Assert.That(_hierarchy.IsInHierarchy(grandChild, child), Is.False);
|
||||
@@ -540,12 +524,10 @@ public class HierarchyTests
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Verify within same branch
|
||||
Assert.That(_hierarchy.IsInHierarchy(root, branch1Parent), Is.True);
|
||||
Assert.That(_hierarchy.IsInHierarchy(root, branch1Child), Is.True);
|
||||
Assert.That(_hierarchy.IsInHierarchy(branch1Parent, branch1Child), Is.True);
|
||||
|
||||
// Verify between different branches
|
||||
Assert.That(_hierarchy.IsInHierarchy(branch1Parent, branch2Child), Is.False);
|
||||
Assert.That(_hierarchy.IsInHierarchy(branch2Parent, branch1Child), Is.False);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user