예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldExpandOnFirstAccess()
        public virtual void ShouldExpandOnFirstAccess()
        {
            // GIVEN
            TraversalBranch     parent = mock(typeof(TraversalBranch));
            Node                source = mock(typeof(Node));
            TraversalBranchImpl branch = new TraversalBranchImpl(parent, source);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("rawtypes") org.neo4j.graphdb.PathExpander expander = mock(org.neo4j.graphdb.PathExpander.class);
            PathExpander expander = mock(typeof(PathExpander));

            when(expander.expand(eq(branch), any(typeof(BranchState)))).thenReturn(Iterables.emptyResourceIterable());
            TraversalContext context = mock(typeof(TraversalContext));

            when(context.Evaluate(eq(branch), Null)).thenReturn(INCLUDE_AND_CONTINUE);

            // WHEN initializing
            branch.Initialize(expander, context);

            // THEN the branch should not be expanded
            verifyZeroInteractions(source);

            // and WHEN actually traversing from it
            branch.Next(expander, context);

            // THEN we should expand it
            verify(expander).expand(any(typeof(Path)), any(typeof(BranchState)));
        }
예제 #2
0
파일: Dijkstra.cs 프로젝트: Neo4Net/Neo4Net
 public override IEnumerable <Relationship> Expand(Path path, BranchState <double> state)
 {
     if (NoneStrictMath.compare(state.State, ShortestSoFar.doubleValue(), Epsilon) > 0 && StopAfterLowestCost)
     {
         return(Collections.emptyList());
     }
     return(Source.expand(path, state));
 }
예제 #3
0
            public override IEnumerable <Relationship> Expand(Path path, BranchState <double> state)
            {
                double thisState = state.State;

                ThisSideShortest.Value = thisState;
                if (NoneStrictMath.compare(thisState + OtherSideShortest.doubleValue(), ShortestSoFar.doubleValue(), Epsilon) > 0 && StopAfterLowestCost)
                {
                    return(Iterables.emptyResourceIterable());
                }
                return(Source.expand(path, state));
            }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public Iterable<org.neo4j.graphdb.Relationship> expand(org.neo4j.graphdb.Path path, org.neo4j.graphdb.traversal.BranchState<Object> state)
            public override IEnumerable <Relationship> Expand(Path path, BranchState <object> state)
            {
                if (path.StartNode().Equals(path.EndNode()))
                {
                    assertEquals("Path length must be zero", 0, path.Length());
                }
                else
                {
                    assertTrue("Path length must be positive", path.Length() > 0);
                }
                return(Expander.expand(path, state));
            }
예제 #5
0
            private int?count(Node node, PathExpander expander)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator<?> expand = expander.expand(singleNodePath(node), BranchState.NO_STATE).iterator();
                IEnumerator <object> expand = expander.expand(singleNodePath(node), BranchState.NO_STATE).GetEnumerator();
                int count = 0;

                while (expand.MoveNext())
                {
                    count++;
                }
                return(count);
            }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInterpretSomeSpecifiedRelationships()
        public virtual void ShouldInterpretSomeSpecifiedRelationships()
        {
            // GIVEN
            Node         node     = CreateSomeData();
            PathExpander expander = RelationshipExpanderBuilder.DescribeRelationships(map("relationships", map("type", MyRelTypes.TEST.name(), "direction", RelationshipDirection.Out.name())));

            // WHEN
            ISet <Relationship> expanded;

            using (Transaction tx = Db.beginTx())
            {
                expanded = asSet(expander.expand(singleNodePath(node), NO_STATE));
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                // THEN
                assertEquals(asSet(node.GetRelationships(MyRelTypes.TEST)), expanded);
                tx.Success();
            }
        }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInterpretNoSpecifiedRelationshipsAsAll()
        public virtual void ShouldInterpretNoSpecifiedRelationshipsAsAll()
        {
            // GIVEN
            Node         node     = CreateSomeData();
            PathExpander expander = RelationshipExpanderBuilder.DescribeRelationships(map());

            // WHEN
            ISet <Relationship> expanded;

            using (Transaction tx = Db.beginTx())
            {
                expanded = asSet(expander.expand(singleNodePath(node), NO_STATE));
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                // THEN
                assertEquals(asSet(node.Relationships), expanded);
                tx.Success();
            }
        }
예제 #8
0
 protected internal virtual ResourceIterator ExpandRelationshipsWithoutChecks(PathExpander expander)
 {
     return(asResourceIterator(expander.expand(this, BranchState.NO_STATE).GetEnumerator()));
 }
예제 #9
0
 protected internal override ResourceIterator <Relationship> ExpandRelationshipsWithoutChecks(PathExpander expander)
 {
     System.Collections.IEnumerable expandIterable = expander.expand(this, this);
     return(Iterators.asResourceIterator(expandIterable.GetEnumerator()));
 }
예제 #10
0
 public override System.Collections.IEnumerable Expand(Path path, BranchState state)
 {
     NodesVisited.increment();
     return(Delegate.expand(path, state));
 }