public void InsertSibling_AddSiblingToATree_SiblingAndPropertiesAdded() { // PropertyTree: {0 => 1 , 2} and {1 => 3 , 4} PropertyTree tree = new PropertyTree(); int firstChild = tree.AddChild(tree.root); int secondChild = tree.AddChild(tree.root); int thirdChild = tree.AddChild(firstChild); int fourthChild = tree.AddChild(firstChild); // Add siblings so that: {0 => 1,5,2} & {1 => 6,3,4} int firstSibling = tree.InsertSibling(secondChild, namesValues: new Dictionary <string, dynamic>() { { "Edge_Type", "<" } }); int secondSibling = tree.InsertSibling(thirdChild, namesValues: new Dictionary <string, dynamic>() { { "Edge_Type", "+" } }); // Verification of the parents Assert.AreEqual(tree.root, tree.Parent(firstSibling)); Assert.AreEqual(tree.root, tree.Parent(secondChild)); Assert.AreEqual(firstChild, tree.Parent(secondSibling)); Assert.AreEqual(firstChild, tree.Parent(thirdChild)); // Verification of the children (and the correct order) CollectionAssert.AreEqual(new List <int>() { firstChild, firstSibling, secondChild }, tree.Children(tree.root)); CollectionAssert.AreEqual(new List <int>() { secondSibling, thirdChild, fourthChild }, tree.Children(firstChild)); // Verification of the insertion of the properties Assert.IsTrue(tree.properties.ContainsKey("Edge_Type")); Dictionary <string, dynamic> props = new Dictionary <string, dynamic>(); props.Add("Edge_Type", "<"); CollectionAssert.AreEqual(tree.GetVertexProperties(firstSibling), props); props["Edge_Type"] = "+"; CollectionAssert.AreEqual(tree.GetVertexProperties(secondSibling), props); }
public void GetVertexProperties_VertexWithNoProperties_EmptyDict() { PropertyTree tree = new PropertyTree(); CollectionAssert.AreEqual(tree.GetVertexProperties(1), new Dictionary <string, dynamic>() { }); }
public void GetVertexProperties_VertexWithProperties_CorrectDict() { PropertyTree tree = new PropertyTree(); tree.AddChild(tree.root, 1); Dictionary <string, dynamic> props = new Dictionary <string, dynamic>(); props.Add("label", "leaf"); props.Add("height", 12.5); tree.AddVertexProperties(1, props); CollectionAssert.AreEqual(tree.GetVertexProperties(1), props); }