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 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 static PropertyGraph CreateTinkerGraph()
        {

            var _TinkerGraph = new PropertyGraph();
            _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.NumberOfVertices());

            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 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));

        }