//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveNonExistingRelationshipFromExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRemoveNonExistingRelationshipFromExplicitIndex()
        {
            // Given
            long relId = AddRelationshipToExplicitIndex();

            // When
            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.RelationshipRemoveFromExplicitIndex(INDEX_NAME, relId + 1);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Relationship> hits = graphDb.index().forRelationships(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(relId));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse(hits.hasNext());
                hits.Close();
                ctx.Success();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleRemoveNodeFromExplicitIndexTwice() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleRemoveNodeFromExplicitIndexTwice()
        {
            // Given
            long nodeId = AddNodeToExplicitIndex();

            // When
            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeRemoveFromExplicitIndex(INDEX_NAME, nodeId);
                tx.Success();
            }

            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeRemoveFromExplicitIndex(INDEX_NAME, nodeId);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Node> hits = graphDb.index().forNodes(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse(hits.hasNext());
                hits.Close();
                ctx.Success();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddRelationshipToExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddRelationshipToExplicitIndex()
        {
            long relId;

            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                relId = graphDb.createNode().createRelationshipTo(graphDb.createNode(), RelationshipType.withName("R")).Id;
                ctx.Success();
            }

            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.RelationshipAddToExplicitIndex(INDEX_NAME, relId, KEY, VALUE);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Relationship> hits = graphDb.index().forRelationships(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(relId));
                hits.Close();
                ctx.Success();
            }
        }
        private IndexHits <Node> QueryIndex(Index <Node> index)
        {
            GraphDatabaseService graphDatabaseService = DbRule.GraphDatabaseAPI;

            using (Transaction ignored = graphDatabaseService.BeginTx())
            {
                IndexHits <Node> hits = index.get("foo", 42);
                hits.Close();
                return(hits);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddNodeToExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddNodeToExplicitIndex()
        {
            long nodeId;

            using (Transaction tx = beginTransaction())
            {
                nodeId = tx.DataWrite().nodeCreate();
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeAddToExplicitIndex(INDEX_NAME, nodeId, KEY, VALUE);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Node> hits = graphDb.index().forNodes(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(nodeId));
                hits.Close();
                ctx.Success();
            }
        }