public void RemovePropertyEventTest()
        {

            Nullable<Boolean> check = null;

            var graph = new PropertyGraph(123UL, g => g.SetProperty("key",   "value").
                                                        SetProperty("nokey", "value"));

            graph.OnPropertyRemoval  += (g, key, value, vote) => { if (key.StartsWith("ke")) vote.OK(); else vote.Veto(); };
            graph.OnPropertyRemoved  += (g, key, value)       => check = true;

            graph.Remove("nokey", "value");
            Assert.IsNull(check);
            Assert.IsTrue(graph.ContainsKey("nokey"));

            graph.Remove("key", "value");
            Assert.IsTrue(check.Value);
            Assert.IsFalse(graph.ContainsKey("key"));

        }
 public void RemoveRevIdTest3()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove((k, v) => k == "RevId");
 }
 public void RemoveIdTest2()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove("Id", 123UL);
 }
 public void RemoveRevIdTest2()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove("RevId", 0);
 }
        public void GraphIdAndInitializerConstructor_AGraphElementTest()
        {

            var graph = new PropertyGraph(123UL, g => g.SetProperty("hello",  "world!").
                                                        SetProperty("graphs", "are cool!").
                                                        SetProperty("Keep",   "it simple!"));

            Assert.IsNotNull(graph);
            Assert.IsNotNull(graph.IdKey);
            Assert.AreEqual(123UL, graph.Id);
            Assert.IsNotNull(graph.RevIdKey);

            // - AGraphElement -------------------------------------------------------------
            Assert.IsTrue (graph.ContainsKey("Id"));
            Assert.IsTrue (graph.ContainsKey("RevId"));
            Assert.IsTrue (graph.ContainsKey("hello"));
            Assert.IsFalse(graph.ContainsKey("world!"));
            Assert.IsTrue (graph.ContainsKey("graphs"));
            Assert.IsFalse(graph.ContainsKey("are cool!"));
            Assert.IsTrue (graph.ContainsKey("Keep"));
            Assert.IsFalse(graph.ContainsKey("it simple!"));

            Assert.IsTrue (graph.ContainsValue(123UL));
            Assert.IsFalse(graph.ContainsValue("hello"));
            Assert.IsTrue (graph.ContainsValue("world!"));
            Assert.IsFalse(graph.ContainsValue("graphs"));
            Assert.IsTrue (graph.ContainsValue("are cool!"));
            Assert.IsFalse(graph.ContainsValue("Keep"));
            Assert.IsTrue (graph.ContainsValue("it simple!"));

            Assert.IsTrue(graph.Contains("Id",     123UL));
            Assert.IsTrue(graph.Contains("hello",  "world!"));
            Assert.IsTrue(graph.Contains("graphs", "are cool!"));
            Assert.IsTrue(graph.Contains("Keep",   "it simple!"));

            Assert.IsTrue(graph.Contains(new KeyValuePair<String, Object>("Id",     123UL)));
            Assert.IsTrue(graph.Contains(new KeyValuePair<String, Object>("hello",  "world!")));
            Assert.IsTrue(graph.Contains(new KeyValuePair<String, Object>("graphs", "are cool!")));
            Assert.IsTrue(graph.Contains(new KeyValuePair<String, Object>("Keep",   "it simple!")));

            Assert.AreEqual(123UL,        graph["Id"]);
            Assert.AreEqual("world!",     graph["hello"]);
            Assert.AreEqual("are cool!",  graph["graphs"]);
            Assert.AreEqual("it simple!", graph["Keep"]);

            Object _Value;
            Assert.IsTrue(graph.TryGet("Id", out _Value));
            Assert.AreEqual(123UL, _Value);

            Assert.IsTrue(graph.TryGet("hello", out _Value));
            Assert.AreEqual("world!", _Value);

            Assert.IsTrue(graph.TryGet("graphs", out _Value));
            Assert.AreEqual("are cool!", _Value);

            Assert.IsTrue(graph.TryGet("Keep", out _Value));
            Assert.AreEqual("it simple!", _Value);


            var filtered01 = graph.GetProperties(null).ToList();
            Assert.NotNull(filtered01);
            Assert.AreEqual(5, filtered01.Count);

            var filtered02 = graph.GetProperties((k, v) => true).ToList();
            Assert.NotNull(filtered02);
            Assert.AreEqual(5, filtered02.Count);

            var filtered03 = graph.GetProperties((k, v) => k.StartsWith("he")).ToList();
            Assert.NotNull(filtered03);
            Assert.AreEqual(1, filtered03.Count);

            var filtered04 = graph.GetProperties((k, v) => k.StartsWith("xcvhe")).ToList();
            Assert.NotNull(filtered04);
            Assert.AreEqual(0, filtered04.Count);


            var AllProperties = new Dictionary<String, Object>();
            foreach (var property in graph)
                AllProperties.Add(property.Key, property.Value);

            Assert.AreEqual(5, AllProperties.Count);

            var keys   = graph.Keys.ToList();
            Assert.NotNull(keys);
            Assert.AreEqual(5, keys.Count);

            var values = graph.Values.ToList();
            Assert.NotNull(values);
            Assert.AreEqual(5, values.Count);


            var deleted1 = graph.Remove("hello");
            Assert.AreEqual("world!", deleted1);
            Assert.IsFalse (graph.ContainsKey("hello"));
            Assert.IsFalse (graph.ContainsValue("world!"));

            var deleted2 = graph.Remove("graphs", "are cool!");
            Assert.AreEqual("are cool!", deleted2);
            Assert.IsFalse (graph.ContainsKey("graphs"));
            Assert.IsFalse (graph.ContainsValue("are cool!"));

            var deleted3 = graph.Remove().ToList();
            Assert.IsNotNull(deleted3);
            Assert.AreEqual(0, deleted3.Count);

            var deleted4 = graph.Remove((k, v) => false).ToList();
            Assert.IsNotNull(deleted4);
            Assert.AreEqual(0, deleted4.Count);

            var deleted5 = graph.Remove((k, v) => k.StartsWith("Kee")).ToList();
            Assert.IsNotNull(deleted5);
            Assert.AreEqual(1, deleted5.Count);
            Assert.AreEqual("Keep",       deleted5[0].Key);
            Assert.AreEqual("it simple!", deleted5[0].Value);

        }