Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void AddProperty_PropertyAlreadyExists_ExceptionThrown()
        {
            PropertyTree tree = new PropertyTree();

            tree.properties.Add("label", new Dictionary <int, dynamic>());

            CollectionAssert.Contains(tree.properties.Keys, "label");
            tree.AddProperty("label");
        }
Exemplo n.º 3
0
        public void RemoveProperty_PropertyWithNoValues_PropertyRemoved()
        {
            PropertyTree tree = new PropertyTree();

            tree.AddProperty("label");
            Assert.IsTrue(tree.properties.ContainsKey("label"));

            tree.RemoveProperty("label");
            Assert.IsFalse(tree.properties.ContainsKey("label"));
        }
Exemplo n.º 4
0
        public void RemoveProperty_PropertyExists_PropertyRemoved()
        {
            PropertyTree tree = new PropertyTree();

            tree.AddProperty("label");
            Assert.IsTrue(tree.properties.ContainsKey("label"));

            tree.properties["label"].Add(1, "element");

            tree.RemoveProperty("label");
            Assert.IsFalse(tree.properties.ContainsKey("label"));
        }
Exemplo n.º 5
0
        public void AddProperty_NewProperty_NewKeyAdded()
        {
            PropertyTree tree = new PropertyTree();

            CollectionAssert.DoesNotContain(tree.properties.Keys, "label");

            tree.AddProperty("label");
            CollectionAssert.Contains(tree.properties.Keys, "label");

            Dictionary <int, dynamic> emptyDictionary = new Dictionary <int, dynamic>()
            {
            };

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