Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nodeLevelUniqueness()
        public virtual void NodeLevelUniqueness()
        {
            /*
             *         (b)
             *       /  |  \
             *    (e)==(a)--(c)
             *       \  |
             *         (d)
             */

            CreateGraph("a TO b", "a TO c", "a TO d", "a TO e", "a TO e", "b TO e", "d TO e", "c TO b");
            RelationshipType to = withName("TO");

            using (Transaction tx = BeginTx())
            {
                Node   a     = GetNodeWithName("a");
                Node   e     = GetNodeWithName("e");
                Path[] paths = SplitPathsOnePerLevel(GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(NODE_LEVEL).evaluator(includeWhereEndNodeIs(e)).traverse(a));
                NodePathRepresentation pathRepresentation = new NodePathRepresentation(NamePropertyRepresentation);

                assertEquals("a,e", pathRepresentation.Represent(paths[1]));
                string levelTwoPathRepresentation = pathRepresentation.Represent(paths[2]);
                assertTrue(levelTwoPathRepresentation.Equals("a,b,e") || levelTwoPathRepresentation.Equals("a,d,e"));
                assertEquals("a,c,b,e", pathRepresentation.Represent(paths[3]));
                tx.Success();
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nodeGlobalUniqueness()
        public virtual void NodeGlobalUniqueness()
        {
            /*
             * (a)-TO->(b)-TO->(c)
             *   \----TO---->/
             */
            CreateGraph("a TO b", "a TO c", "b TO c");
            RelationshipType to = withName("TO");

            using (Transaction tx = BeginTx())
            {
                Node a = GetNodeWithName("a");
                Node c = GetNodeWithName("c");
                IEnumerator <Path> path = GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(NODE_GLOBAL).evaluator(includeWhereEndNodeIs(c)).traverse(a).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Path thePath = path.next();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse(path.hasNext());
                NodePathRepresentation pathRepresentation = new NodePathRepresentation(NamePropertyRepresentation);

                assertEquals("a,b,c", pathRepresentation.Represent(thePath));
                tx.Success();
            }
        }