Ejemplo n.º 1
0
        public void testPathConstruction()
        {
            var _Graph = TinkerGraphFactory.CreateTinkerGraph();

            var _Marko = _Graph.VertexById(1);

            var _Pipe1 = new OutEdgesPipe<UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object>();

            var _Pipe2 = new InVertexPipe<UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object>();

            var _Pipe3 = new PropertyPipe<String, Object>(Keys: "name");

            _Pipe3.SetSource(_Pipe2);
            _Pipe2.SetSource(_Pipe1);

            var _MarkoList = new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object>>() { _Marko };

            _Pipe1.SetSource(_MarkoList.GetEnumerator());

            foreach (var _Name in _Pipe3)
            {

                var path = _Pipe3.Path;

                Assert.AreEqual(_Marko,                 path[0]);
                Assert.AreEqual(typeof(IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                            UInt64, Int64, String, String, Object,
                                                            UInt64, Int64, String, String, Object,
                                                            UInt64, Int64, String, String, Object>), path[1].GetType());

                Assert.AreEqual(typeof(IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object>), path[2].GetType());

                Assert.AreEqual(typeof(String),         path[3].GetType());

                if (_Name == "vadas")
                {
                    Assert.AreEqual(_Graph.EdgeById(7),     path[1]);
                    Assert.AreEqual(_Graph.VertexById(2), path[2]);
                    Assert.AreEqual("vadas", path[3]);
                }

                else if (_Name == "lop")
                {
                    Assert.AreEqual(_Graph.EdgeById(9),     path[1]);
                    Assert.AreEqual(_Graph.VertexById(3), path[2]);
                    Assert.AreEqual("lop", path[3]);
                }

                else if (_Name == "josh")
                {
                    Assert.AreEqual(_Graph.EdgeById(8),     path[1]);
                    Assert.AreEqual(_Graph.VertexById(4), path[2]);
                    Assert.AreEqual("josh", path[3]);
                }

                else
                    Assert.Fail();

            }
        }
Ejemplo n.º 2
0
        public void testInCommingVertex()
        {
            var _Graph = TinkerGraphFactory.CreateTinkerGraph();

            var _Marko = _Graph.VertexById(1);

            var _EVP   = new InVertexPipe<UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object,
                                          UInt64, Int64, String, String, Object>();

            _EVP.SetSourceCollection(_Marko.OutEdges());

            var _Counter = 0;
            while (_EVP.MoveNext())
            {
                var v = _EVP.Current;
                Assert.IsTrue(v.Id.Equals(2) || v.Id.Equals(3) || v.Id.Equals(4));
                _Counter++;
            }

            Assert.AreEqual(3, _Counter);

            var _Josh = _Graph.VertexById(4);

            _EVP = new InVertexPipe<UInt64, Int64, String, String, Object,
                                    UInt64, Int64, String, String, Object,
                                    UInt64, Int64, String, String, Object,
                                    UInt64, Int64, String, String, Object>();

            _EVP.SetSource(_Josh.OutEdges().GetEnumerator());

            _Counter = 0;
            while (_EVP.MoveNext())
            {
                var v = _EVP.Current;
                Assert.IsTrue(v.Id.Equals(5) || v.Id.Equals(3));
                _Counter++;
            }

            Assert.AreEqual(2, _Counter);

            Assert.IsFalse(_EVP.MoveNext());
        }