Esempio n. 1
0
        public void Removing_A_Parent_Element_Correctly_Removes_Child_Element_Names_From_The_Used_Names()
        {
            var parentName = "parent";
            var childName = "child";
            var childOfChildName = "childOfChild";

            var parent = new ImmlElement { Name = parentName };
            parent.Add(new ImmlElement { Name = childName });

            var collection = new ImmlElement();
            collection.Add(parent);

            collection.Remove(parent);
            Assert.Empty(collection.Elements);

            var child = new ImmlElement { Name = childName };
            collection.Add(child);
            Assert.Equal(childName, child.Name);

            var childOfChild = new ImmlElement { Name = childOfChildName };
            child.Add(childOfChild);

            Assert.True(collection.ContainsName(childName));
        }
Esempio n. 2
0
        public void HasChildren_Should_Be_False_When_One_Child_Is_Added_Then_Removed()
        {
            var parent = new ImmlElement();
            var child = new ImmlElement();

            parent.Add(child);
            parent.Remove(child);

            Assert.Equal(false, parent.HasChildren);
        }
Esempio n. 3
0
        public void Removing_An_Element_From_An_ImmlElement_Frees_Up_That_Name_To_Be_Reused()
        {
            var name = "name1";

            var element1 = new ImmlElement { Name = name };
            var element2 = new ImmlElement { Name = name };

            var collection = new ImmlElement();
            collection.Add(element1);

            Assert.Equal(name, element1.Name);
            collection.Remove(element1);

            collection.Add(element2);
            Assert.Equal(name, element2.Name);
        }
Esempio n. 4
0
        public void Dynamically_Adding_An_Element_With_Hierarchy_To_A_Collection_Then_Removing_The_Parent_Of_The_Hierarchy_Frees_The_Child_Names()
        {
            var name = "theName";

            var collection = new ImmlElement();
            collection.Name = "Context";

            var elementWithHierarchy = new ImmlElement();

            var childOfHierarchy = new ImmlElement();
            childOfHierarchy.Name = name;

            elementWithHierarchy.Add(childOfHierarchy);

            collection.Add(elementWithHierarchy);

            Assert.True(collection.ContainsName(name));

            collection.Remove(elementWithHierarchy);

            Assert.False(collection.ContainsName(name));

            collection.Add(new ImmlElement { Name = name });

            Assert.True(collection.ContainsName(name));
        }