Exemplo n.º 1
0
        public void ChangeParent_When_Child_Has_No_Parent()
        {
            Project new_parent = new Project();
            Project child = new Project();

            child.ChangeParent(new_parent);
            Assert.That(child.Parent, Is.EqualTo(new_parent));
            Assert.That(new_parent.Children.Count, Is.EqualTo(1));
            Assert.That(new_parent.Children.Contains(child));
        }
Exemplo n.º 2
0
        public void ChangeParent_When_Parent_And_New_Parent_Is_Null()
        {
            Project project = new Project();

            project.ChangeParent(null);
            Assert.That(project.Parent, Is.EqualTo(null));
        }
Exemplo n.º 3
0
        public void ChangeParent_When_New_Parent_Is_Old_Parent()
        {
            Project parent = new Project();
            Project child_1 = new Project();
            Project child_2 = new Project();
            parent.AddChild(child_1);
            parent.AddChild(child_2);

            child_1.ChangeParent(parent);
            Assert.That(child_1.Parent, Is.EqualTo(parent));
            Assert.That(child_2.Parent, Is.EqualTo(parent));
            Assert.That(parent.Children.Count, Is.EqualTo(2));
            Assert.That(parent.Children.Contains(child_1));
            Assert.That(parent.Children.Contains(child_2));
        }
Exemplo n.º 4
0
        public void ChangeParent_When_New_Parent_Is_Null()
        {
            Project parent = new Project();
            Project child_1 = new Project();
            parent.AddChild(child_1);

            child_1.ChangeParent(null);
            Assert.That(child_1.Parent, Is.EqualTo(null));
            Assert.That(parent.Children.Count, Is.EqualTo(0));
        }
Exemplo n.º 5
0
        public void ChangeParent()
        {
            Project parent_1 = new Project();
            Project parent_2 = new Project();
            Project child = new Project();

            parent_1.AddChild(child);
            Assert.That(child.Parent, Is.EqualTo(parent_1));
            Assert.That(parent_1.Children.Count, Is.EqualTo(1));
            Assert.That(parent_1.Children.Contains(child));

            child.ChangeParent(parent_2);
            Assert.That(child.Parent, Is.EqualTo(parent_2));
            Assert.That(parent_1.Children.IsNullOrEmpty(), Is.True);
            Assert.That(parent_2.Children.Count, Is.EqualTo(1));
            Assert.That(parent_2.Children.Contains(child));
        }