public static PropertyGraph CreateDemoGraph()
        {

            var _Graph = new PropertyGraph();
            _Graph.OnVertexAdding += (graph, vertex, vote) => { Console.WriteLine("OnVertexAdding1() called!"); };
            _Graph.OnVertexAdding += (graph, vertex, vote) => { Console.WriteLine("OnVertexAdding2() called!"); if (vertex.Id < 3) vote.Veto(); };
            _Graph.OnVertexAdding += (graph, vertex, vote) => { Console.WriteLine("OnVertexAdding3() called!"); };


            var _Alice1 = _Graph.AddVertex();
            var _Alice2 = _Graph.AddVertex(v => v.SetProperty("name", "Alice"));

            var _Alice = _Graph.AddVertex(10, v => v.SetProperty("name", "Alice").SetProperty("age", 18));
            var _Bob   = _Graph.AddVertex(20, v => v.SetProperty("name", "Bob").  SetProperty("age", 20));
            var _Carol = _Graph.AddVertex(30, v => v.SetProperty("name", "Carol").SetProperty("age", 22));
            var _Dave  = _Graph.AddVertex(40, v => v.SetProperty("name", "Dave"). SetProperty("age", 23));

            //var e7 = _Graph.AddEdge(marko, vadas, new EdgeId("7"), "knows", e => e.SetProperty("weight", 0.5));
            //var e8 = _Graph.AddEdge(marko, josh, new EdgeId("8"), "knows", e => e.SetProperty("weight", 1.0));
            //var e9 = _Graph.AddEdge(marko, lop, new EdgeId("9"), "created", e => e.SetProperty("weight", 0.4));

            //var e10 = _Graph.AddEdge(josh, ripple, new EdgeId("10"), "created", e => e.SetProperty("weight", 1.0));
            //var e11 = _Graph.AddEdge(josh, lop, new EdgeId("11"), "created", e => e.SetProperty("weight", 0.4));

            //var e12 = _Graph.AddEdge(peter, lop, new EdgeId("12"), "created", e => e.SetProperty("weight", 0.2));

            return _Graph;

        }
        public void AddVertexEmptyAddMethodTest()
        {
            
            var _Graph  = new PropertyGraph();
            Assert.AreEqual(0, _Graph.NumberOfVertices());

            var _Vertex = _Graph.AddVertex();
            Assert.AreEqual(1, _Graph.NumberOfVertices());
            Assert.AreEqual(0, _Vertex.OutEdges().Count());
            Assert.AreEqual(0, _Vertex.InEdges().Count());

            Assert.NotNull(_Vertex.Graph);
            Assert.AreEqual(_Graph, _Vertex.Graph);
            Assert.NotNull(_Vertex.IdKey);
            Assert.NotNull(_Vertex.Id);
            Assert.NotNull(_Vertex.RevIdKey);
            Assert.NotNull(_Vertex.RevisionId);

            Assert.IsTrue(_Vertex.ContainsKey(_Graph.IdKey));
            Assert.IsTrue(_Vertex.ContainsKey(_Graph.RevIdKey));

            var _Properties = _Vertex.ToList();
            Assert.AreEqual(2, _Properties.Count);
            foreach (var _KeyValuePair in _Properties)
                Assert.IsTrue(_KeyValuePair.Key == _Graph.IdKey ||
                              _KeyValuePair.Key == _Graph.RevIdKey);

        }
        public void GraphInitializerConstructorTest()
        {

            var graph = new PropertyGraph(g => g.SetProperty("hello", "world!"));

            Assert.IsNotNull(graph);
            Assert.IsNotNull(graph.IdKey);
            Assert.IsNotNull(graph.RevIdKey);
            Assert.IsNotNull(graph.DescriptionKey);
            Assert.IsNull   (graph.Description);

        }
        public static IPropertyGraph CreateTinkerGraph()
        {

            var _TinkerGraph = new PropertyGraph() as IPropertyGraph;

            _TinkerGraph.OnVertexAdding += (graph, vertex, vote) => {
                Console.WriteLine("I like all vertices!");
            };

            _TinkerGraph.OnVertexAdding += (graph, vertex, vote) =>
            {
                if (vertex.Id == 5) {
                    Console.WriteLine("I'm a Jedi!");
                    vote.Veto();
                }
            };

            var marko  = _TinkerGraph.AddVertex(1, v => v.SetProperty("name", "marko"). SetProperty("age",   29));
            var vadas  = _TinkerGraph.AddVertex(2, v => v.SetProperty("name", "vadas"). SetProperty("age",   27));
            var lop    = _TinkerGraph.AddVertex(3, v => v.SetProperty("name", "lop").   SetProperty("lang", "java"));
            var josh   = _TinkerGraph.AddVertex(4, v => v.SetProperty("name", "josh").  SetProperty("age",   32));
            var vader  = _TinkerGraph.AddVertex(5, v => v.SetProperty("name", "darth vader"));
            var ripple = _TinkerGraph.AddVertex(6, v => v.SetProperty("name", "ripple").SetProperty("lang", "java"));
            var peter  = _TinkerGraph.AddVertex(7, v => v.SetProperty("name", "peter"). SetProperty("age",   35));

            Console.WriteLine("Number of vertices added: " + _TinkerGraph.Vertices().Count());

            marko.OnPropertyChanging += (sender, Key, oldValue, newValue, vote) =>
                Console.WriteLine("'" + Key + "' property changing: '" + oldValue + "' -> '" + newValue + "'");

            marko.OnPropertyChanged  += (sender, Key, oldValue, newValue)       =>
                Console.WriteLine("'" + Key + "' property changed: '"  + oldValue + "' -> '" + newValue + "'");


            var _DynamicMarko = marko.AsDynamic();
            _DynamicMarko.age  += 100;
            _DynamicMarko.doIt  = (Action<String>) ((text) => Console.WriteLine("Some infos: " + text + "!"));
            _DynamicMarko.doIt(_DynamicMarko.name + "/" + marko.GetProperty("age") + "/");


            var e7  = _TinkerGraph.AddEdge(marko, vadas,  7,  "knows",   e => e.SetProperty("weight", 0.5));
            var e8  = _TinkerGraph.AddEdge(marko, josh,   8,  "knows",   e => e.SetProperty("weight", 1.0));
            var e9  = _TinkerGraph.AddEdge(marko, lop,    9,  "created", e => e.SetProperty("weight", 0.4));

            var e10 = _TinkerGraph.AddEdge(josh,  ripple, 10, "created", e => e.SetProperty("weight", 1.0));
            var e11 = _TinkerGraph.AddEdge(josh,  lop,    11, "created", e => e.SetProperty("weight", 0.4));

            var e12 = _TinkerGraph.AddEdge(peter, lop,    12, "created", e => e.SetProperty("weight", 0.2));

            return _TinkerGraph;

        }
        public void GraphIdConstructorTest()
        {

            var graph = new PropertyGraph(123, null);

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

        }
        public void CopyGraphTest()
        {

            var _SourceGraph = TinkerGraphFactory.CreateTinkerGraph() as IPropertyGraph;

            var _NumberOfVertices = _SourceGraph.NumberOfVertices();
            var _NumberOfEdges    = _SourceGraph.NumberOfEdges();

            var _DestinationGraph = new PropertyGraph() as IPropertyGraph;
            _SourceGraph.CopyGraph(_DestinationGraph);

            Assert.AreEqual(_NumberOfVertices, _DestinationGraph.NumberOfVertices());
            Assert.AreEqual(_NumberOfEdges,    _DestinationGraph.NumberOfEdges());

        }
 public void ChangeRevIdTest1()
 {
     var graph = new PropertyGraph(123UL);
     graph.SetProperty("RevId", 256UL);
 }
        public void AddMultipleVertices()
        {

            var _Graph = new PropertyGraph();
            Assert.AreEqual(0, _Graph.NumberOfVertices());

            var _Random = new Random().Next(100);

            for (var i = 1; i <= _Random; i++)
            {
                _Graph.AddVertex((UInt64)i);
                Assert.AreEqual(i, _Graph.NumberOfVertices());
            }

        }
        public void AddTwoVerticesHavingTheSameIdentification()
        {

            var _Graph = new PropertyGraph();
            Assert.AreEqual(0, _Graph.NumberOfVertices());

            var _Vertex1 = _Graph.AddVertex(5);
            Assert.AreEqual(1, _Graph.NumberOfVertices());

            var _Vertex2 = _Graph.AddVertex(5);

        }
        public void TryToChangeTheVertexRevisionIdentification()
        {

            var _Graph = new PropertyGraph();
            Assert.AreEqual(0, _Graph.NumberOfVertices());

            var _Vertex1 = _Graph.AddVertex(5);
            _Vertex1.SetProperty(_Graph.RevIdKey, 23);

        }
        public void AddVertexWithIdAndVertexInitializerTest()
        {

            var _Graph = new PropertyGraph();
            Assert.AreEqual(0, _Graph.NumberOfVertices());

            var _Vertex = _Graph.AddVertex(23, v => v.SetProperty("key1", "value1").
                                                      SetProperty(new KeyValuePair<String, Object>("key2", 42)));
            Assert.AreEqual(1, _Graph.NumberOfVertices());
            Assert.AreEqual(0, _Vertex.OutEdges().Count());
            Assert.AreEqual(0, _Vertex.InEdges().Count());

            Assert.NotNull(_Vertex.Graph);
            Assert.AreEqual(_Graph, _Vertex.Graph);
            Assert.NotNull(_Vertex.IdKey);
            Assert.AreEqual(23, _Vertex.Id);
            Assert.NotNull(_Vertex.RevIdKey);
            Assert.NotNull(_Vertex.RevisionId);

            Assert.IsTrue(_Vertex.ContainsKey(_Graph.IdKey));
            Assert.IsTrue(_Vertex.ContainsKey(_Graph.RevIdKey));
            Assert.IsTrue(_Vertex.ContainsKey("key1"));
            Assert.IsTrue(_Vertex.ContainsKey("key2"));
            Assert.IsTrue(_Vertex.ContainsValue("value1"));
            Assert.IsTrue(_Vertex.ContainsValue(42));

            var _Properties = _Vertex.ToList();
            Assert.NotNull(_Properties);
            Assert.AreEqual(4, _Properties.Count);
            foreach (var _KeyValuePair in _Properties)
                Assert.IsTrue((_KeyValuePair.Key == _Graph.IdKey && ((UInt64)_KeyValuePair.Value == 23))  ||
                               _KeyValuePair.Key == _Graph.RevIdKey                                       ||
                              (_KeyValuePair.Key == "key1" && _KeyValuePair.Value.ToString() == "value1") ||
                              (_KeyValuePair.Key == "key2" && ((Int32) _KeyValuePair.Value   == 42)));

            var _PropertyKeys = _Vertex.Keys;
            Assert.NotNull(_PropertyKeys);
            Assert.AreEqual(4, _PropertyKeys.Count());
            foreach (var _Keys in _PropertyKeys)
                Assert.IsTrue(_Keys == _Graph.IdKey    ||
                              _Keys == _Graph.RevIdKey ||
                              _Keys == "key1"          ||
                              _Keys == "key2");

            var _PropertyValues = _Vertex.Values;
            Assert.NotNull(_PropertyValues);
            Assert.AreEqual(4, _PropertyValues.Count());
            Assert.IsTrue(_PropertyValues.Contains(23UL));
            Assert.IsTrue(_PropertyValues.Contains("value1"));
            Assert.IsTrue(_PropertyValues.Contains(42));

        }
 public void RemoveIdTest2()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove("Id", 123UL);
 }
 public void RemoveRevIdTest3()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove((k, v) => k == "RevId");
 }
        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);

        }
        public void IPropertiesExtensionMethodsTest()
        {

            var graph = new PropertyGraph(123UL, g => g.SetProperty  (new KeyValuePair<String, Object>("hello",  "world!")).
                                                        SetProperties(new List<KeyValuePair<String, Object>>() { new KeyValuePair<String, Object>("graphs", "are cool!"),
                                                                                                                 new KeyValuePair<String, Object>("Keep",   "it simple!")}).
                                                        SetProperties(new Dictionary<String, Object>() { { "a", "b" }, { "c", "d" } }).
                                                        SetProperty  ("e", "f"));


            Assert.AreEqual(123UL,        graph.GetProperty("Id"));
            Assert.AreEqual("world!",     graph.GetProperty("hello"));
            Assert.AreEqual("are cool!",  graph.GetProperty("graphs"));
            Assert.AreEqual("it simple!", graph.GetProperty("Keep"));
            Assert.AreEqual("b",          graph.GetProperty("a"));
            Assert.AreEqual("d",          graph.GetProperty("c"));

            Assert.AreEqual(123UL,        graph.GetProperty("Id",     typeof(UInt64)));
            Assert.AreEqual("world!",     graph.GetProperty("hello",  typeof(String)));
            Assert.AreEqual("are cool!",  graph.GetProperty("graphs", typeof(String)));
            Assert.AreEqual("it simple!", graph.GetProperty("Keep",   typeof(String)));

            Assert.AreNotEqual("world!",  graph.GetProperty("hello",  typeof(UInt64)));


            // --[Action<TValue>]--------------------------------------------------------------

            Nullable<Boolean> check;
            check = null;
            graph.UseProperty("false",  OnSuccess_PropertyValue => check = true);
            Assert.IsNull(check);

            check = null;
            graph.UseProperty("Id",     OnSuccess_PropertyValue => check = true);
            Assert.IsTrue(check.Value);

            check = null;
            graph.UseProperty("hello",  OnSuccess_PropertyValue => check = true);
            Assert.IsTrue(check.Value);

            check = null;
            graph.UseProperty("graphs", OnSuccess_PropertyValue => check = true);
            Assert.IsTrue(check.Value);

            // --[Action<TKey, TValue>]--------------------------------------------------------

            check = null;
            graph.UseProperty("false",  (OnSuccess_PropertyKey, PropertyValue) => check = true);
            Assert.IsNull(check);

            check = null;
            graph.UseProperty("Id",     (OnSuccess_PropertyKey, PropertyValue) => check = true);
            Assert.IsTrue(check.Value);

            check = null;
            graph.UseProperty("hello",  (OnSuccess_PropertyKey, PropertyValue) => check = true);
            Assert.IsTrue(check.Value);

            check = null;
            graph.UseProperty("graphs", (OnSuccess_PropertyKey, PropertyValue) => check = true);
            Assert.IsTrue(check.Value);

            // --[Action<TValue>]--[Error]-----------------------------------------------------

            check = null;
            graph.GetProperty("false",  OnSuccess_PropertyValue => check = true, OnError => check = false);
            Assert.IsFalse(check.Value);

            check = null;
            graph.GetProperty("Id",     OnSuccess_PropertyValue => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);

            check = null;
            graph.GetProperty("hello",  OnSuccess_PropertyValue => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);

            check = null;
            graph.GetProperty("graphs", OnSuccess_PropertyValue => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);

            // --[Action<TKey, TValue>]--[Error]-----------------------------------------------

            check = null;
            graph.GetProperty("false",  (OnSuccess_PropertyKey, PropertyValue) => check = true, OnError => check = false);
            Assert.IsFalse(check.Value);

            check = null;
            graph.GetProperty("Id",     (OnSuccess_PropertyKey, PropertyValue) => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);

            check = null;
            graph.GetProperty("hello",  (OnSuccess_PropertyKey, PropertyValue) => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);

            check = null;
            graph.GetProperty("graphs", (OnSuccess_PropertyKey, PropertyValue) => check = true, OnError => check = false);
            Assert.IsTrue(check.Value);


            // --[Func<TValue, TResult>]-------------------------------------------------------
            Assert.AreEqual("world!?",      graph.PropertyFunc("hello",                 PropertyValue => { return (PropertyValue as String) + "?"; }));
            Assert.AreEqual(124UL,          graph.PropertyFunc("Id",                    PropertyValue => { return ( (UInt64) PropertyValue ) + 1; }));
            Assert.AreEqual(0,              graph.PropertyFunc("XYZ",                   PropertyValue => { return ( (UInt64) PropertyValue ) + 1; }));
            Assert.AreEqual(null,           graph.PropertyFunc("XYZ",                   PropertyValue => { return ( (String) PropertyValue ); }));

            Assert.AreEqual("world!?",      graph.PropertyFunc("hello", typeof(String), PropertyValue => { return (PropertyValue as String) + "?"; }));
            Assert.AreEqual(124UL,          graph.PropertyFunc("Id",    typeof(UInt64), PropertyValue => { return ( (UInt64) PropertyValue ) + 1; }));
            Assert.AreEqual(null,           graph.PropertyFunc("XYZ",   typeof(UInt64), PropertyValue => { return ( (UInt64) PropertyValue ) + 1; }));
            Assert.AreEqual(null,           graph.PropertyFunc("XYZ",   typeof(String), PropertyValue => { return ( (String) PropertyValue ); }));


            // --[Func<TKey, TValue, TResult>]-------------------------------------------------
            Assert.AreEqual("hello world!", graph.PropertyFunc("hello",                 (OnSuccess_PropertyKey, PropertyValue) => { return OnSuccess_PropertyKey + " " + (PropertyValue as String); }));
            Assert.AreEqual("Id124",        graph.PropertyFunc("Id",                    (OnSuccess_PropertyKey, PropertyValue) => { return OnSuccess_PropertyKey + ((UInt64) PropertyValue + 1); }));

            Assert.AreEqual("hello world!", graph.PropertyFunc("hello", typeof(String), (OnSuccess_PropertyKey, PropertyValue) => { return OnSuccess_PropertyKey + " " + (PropertyValue as String); }));
            Assert.AreEqual("Id124",        graph.PropertyFunc("Id",    typeof(UInt64), (OnSuccess_PropertyKey, PropertyValue) => { return OnSuccess_PropertyKey + ((UInt64) PropertyValue + 1); }));


            // Filtered Keys/Values
            var FilteredKeys1   = graph.FilteredKeys  ((k, v) => true).ToList();
            Assert.NotNull(FilteredKeys1);
            Assert.AreEqual(8, FilteredKeys1.Count);

            var FilteredKeys2   = graph.FilteredKeys  ((k, v) => { if ((v as String).IsNotNullAndContains("!")) return true; else return false;}).ToList();
            Assert.NotNull(FilteredKeys2);
            Assert.AreEqual(3, FilteredKeys2.Count);


            var FilteredValues1 = graph.FilteredValues((k, v) => true).ToList();
            Assert.NotNull(FilteredValues1);
            Assert.AreEqual(8, FilteredValues1.Count);

            var FilteredValues2 = graph.FilteredValues((k, v) => { if ((v as String).IsNotNullAndContains("!")) return true; else return false; }).ToList();
            Assert.NotNull(FilteredValues2);
            Assert.AreEqual(3, FilteredValues2.Count);

        }
        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 ChangePropertyEventTest()
        {

            Nullable<Boolean> check = null;

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

            graph.OnPropertyChanging += (g, key, oldvalue, newvalue, vote) => { if (key.StartsWith("ke")) vote.OK(); else vote.Veto(); };
            graph.OnPropertyChanged  += (g, key, oldvalue, newvalue)       => check = true;

            graph.SetProperty("nokey", "value");
            Assert.IsNull(check);

            graph.SetProperty("key", "value");
            Assert.IsTrue(check.Value);

        }
        public void AddPropertyEventTest()
        {

            Nullable<Boolean> check = null;

            var graph = new PropertyGraph(123UL);

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

            graph.SetProperty("nokey", "value");
            Assert.IsNull(check);

            graph.SetProperty("key", "value");
            Assert.IsTrue(check.Value);

        }
        public void GraphIdAndHashCodeTest()
        {

            var graph1 = new PropertyGraph(123, null) { Description = "The first graph." };
            var graph2 = new PropertyGraph(256, null) { Description = "The second graph." };
            var graph3 = new PropertyGraph(123, null) { Description = "The third graph." };

            Assert.IsNotNull(graph1.Id);
            Assert.IsNotNull(graph2.Id);
            Assert.IsNotNull(graph3.Id);

            Assert.IsNotNull(graph1.Description);
            Assert.IsNotNull(graph2.Description);
            Assert.IsNotNull(graph3.Description);

            Assert.IsNotNull(graph1.GetHashCode());
            Assert.IsNotNull(graph2.GetHashCode());
            Assert.IsNotNull(graph3.GetHashCode());

            Assert.AreEqual(graph1.Id, graph1.GetHashCode());
            Assert.AreEqual(graph2.Id, graph2.GetHashCode());
            Assert.AreEqual(graph3.Id, graph3.GetHashCode());

            Assert.AreEqual(graph1.Id, graph3.Id);
            Assert.AreEqual(graph1.GetHashCode(), graph3.GetHashCode());

            Assert.AreNotEqual(graph1.Description, graph2.Description);
            Assert.AreNotEqual(graph2.Description, graph3.Description);
            Assert.AreNotEqual(graph3.Description, graph1.Description);

        }
        public void GraphDescriptionTest()
        {

            var graph = new PropertyGraph(g => g.SetProperty("hello", "world!"));

            Assert.IsNotNull(graph);
            Assert.IsNotNull(graph.IdKey);
            Assert.IsNotNull(graph.RevIdKey);
            Assert.IsNotNull(graph.DescriptionKey);
            Assert.IsNull(graph.Description);

            graph.Description = "This is a property graph!";
            Assert.IsNotNull(graph.Description);
            Assert.AreEqual("This is a property graph!", graph.Description);

        }
 public void RemoveRevIdTest2()
 {
     var graph = new PropertyGraph(123UL);
     graph.Remove("RevId", 0);
 }