public void Changing_An_Elements_Name_That_Exists_In_An_ImmlElement_Means_The_Element_Is_Able_To_Be_Found_With_That_New_Name() { var name = "name1"; var altName = "altName"; var element = new ImmlElement { Name = name }; var parentCollection = new ImmlElement(); var collection = new ImmlElement(); parentCollection.Add(collection); collection.Add(element); Assert.Equal(name, element.Name); //switch out the name element.Name = altName; Assert.Equal(altName, element.Name); Assert.False(parentCollection.ContainsName(name)); Assert.True(parentCollection.ContainsName(altName)); }
public void ContainsName_Returns_True_When_A_Child_Element_With_That_Name_Exists() { var name = "name1"; var element1 = new ImmlElement { Name = name }; var collection = new ImmlElement(); collection.Add(element1); Assert.True(collection.ContainsName(name)); }
public void ContainsName_Returns_False_When_A_Child_Element_With_That_Name_Does_Not_Exist() { var name = "name1"; var collection = new ImmlElement(); Assert.False(collection.ContainsName(name)); }
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)); }
public void Nested_Elements_In_A_Deep_Hierarchy_Then_Added_To_A_Collection_Can_Be_Found_Via_A_Query_To_The_Collection() { var nestDepth = 10; var parentName = "parent"; var childName = "child"; var parent = new ImmlElement { Name = parentName }; var addTo = parent; //nest elements 'nestDepth' deep for (int i = 0; i < nestDepth; i++) { var toAdd = new ImmlElement { Name = childName + i }; addTo.Add(toAdd); //switch the parent to be the just added element addTo = toAdd; } var collection = new ImmlElement(); collection.Add(parent); //at this point, collection should inherit the names of the parent collection for (int i = 0; i < nestDepth; i++) { Assert.True(collection.ContainsName(childName + i)); } }
public void Nested_Elements_In_A_Deep_Hierarchy_Can_Be_Found_Via_A_Query_To_The_Parent_Collection() { var nestDepth = 10; var parentName = "parent"; var childName = "child"; var parent = new ImmlElement { Name = parentName }; var addTo = parent; //nest elements 'nestDepth' deep for (int i = 0; i < nestDepth; i++) { //dynamically nest children inside the previously created element var toAdd = new ImmlElement { Name = childName + i }; addTo.Add(toAdd); //switch the parent to be the just added element addTo = toAdd; } //at this point, the parent should have inherited all of the child names for (int i = 0; i < nestDepth; i++) { Assert.True(parent.ContainsName(childName + i)); } }
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)); }