Exemple #1
0
        public void AddVertexProperties_ExistingPropertyForId_PropertyChanged()
        {
            PropertyTree tree = new PropertyTree();

            tree.AddChild(tree.root, 1);
            tree.AddProperty("label");
            tree.properties["label"].Add(1, "wrong");

            // Check that the value of the label property is < 1 , "wrong" >
            Assert.IsTrue(tree.properties.ContainsKey("label"));
            Dictionary <int, dynamic> value = new Dictionary <int, dynamic>();

            value.Add(1, "wrong");

            CollectionAssert.AreEqual(tree.properties["label"], value);

            // Add the same property for a vertex with a new value
            Dictionary <string, dynamic> propertyDict = new Dictionary <string, dynamic>();

            propertyDict.Add("label", "leaf");
            propertyDict.Add("length", 12.5);

            tree.AddVertexProperties(1, propertyDict);

            // Check that the value has been changed
            Assert.IsTrue(tree.properties["label"].ContainsKey(1));
            Dictionary <int, dynamic> newValue = new Dictionary <int, dynamic>();

            newValue.Add(1, "leaf");

            CollectionAssert.AreEqual(tree.properties["label"], newValue);
        }
Exemple #2
0
        public void AddVertexProperties_VertexDoesntExist_ExceptionThrown()
        {
            PropertyTree tree = new PropertyTree();
            Dictionary <string, dynamic> propertyDict = new Dictionary <string, dynamic>();

            propertyDict.Add("label", "leaf");
            propertyDict.Add("length", 12.5);
            propertyDict.Add("order", 1);

            tree.AddVertexProperties(1, propertyDict);
        }
Exemple #3
0
        public void RemoveVertexProperties_NormalCase_NoPropertiesForTheVid()
        {
            PropertyTree tree = new PropertyTree();

            tree.AddChild(tree.root, 1);
            tree.AddChild(1, 2);

            Dictionary <string, dynamic> props = new Dictionary <string, dynamic>();

            props.Add("label", "leaf");
            props.Add("height", 12.5);

            tree.AddVertexProperties(1, props);
            tree.AddVertexProperties(2, props);

            CollectionAssert.Contains(tree.properties["label"].Keys, 1);

            tree.RemoveVertexProperties(1);
            CollectionAssert.DoesNotContain(tree.properties["label"].Keys, 1);
            CollectionAssert.DoesNotContain(tree.properties["height"].Keys, 1);
            CollectionAssert.Contains(tree.properties["label"].Keys, 2);
            CollectionAssert.Contains(tree.properties["height"].Keys, 2);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        public void AddVertexProperties_NewProperties_PropertiesAndValueAdded()
        {
            PropertyTree tree = new PropertyTree();

            tree.AddChild(tree.root, 1);

            Dictionary <string, dynamic> propertyDict = new Dictionary <string, dynamic>();

            propertyDict.Add("label", "leaf");
            propertyDict.Add("length", 12.5);
            propertyDict.Add("order", 1);

            tree.AddVertexProperties(1, propertyDict);

            Dictionary <string, Dictionary <int, dynamic> > expectedResult = new Dictionary <string, Dictionary <int, dynamic> >();
            Dictionary <int, dynamic> firstRow = new Dictionary <int, dynamic>()
            {
                { 1, "leaf" }
            };
            Dictionary <int, dynamic> secondRow = new Dictionary <int, dynamic>()
            {
                { 1, 12.5 }
            };
            Dictionary <int, dynamic> thirdRow = new Dictionary <int, dynamic>()
            {
                { 1, 1 }
            };

            expectedResult.Add("label", firstRow);
            expectedResult.Add("length", secondRow);
            expectedResult.Add("order", thirdRow);

            CollectionAssert.AreEqual(expectedResult.Keys, tree.properties.Keys);
            CollectionAssert.AreEqual(expectedResult["label"], tree.properties["label"]);
            CollectionAssert.AreEqual(expectedResult["length"], tree.properties["length"]);
            CollectionAssert.AreEqual(expectedResult["order"], tree.properties["order"]);
        }