private void ChangeRandomNode(GraphDatabaseService db, int nodeCount, RandomValues random)
 {
     try
     {
         using (Transaction tx = Db.beginTx())
         {
             long     nodeId = random.Next(nodeCount);
             Node     node   = Db.getNodeById(nodeId);
             object[] keys   = Iterables.asCollection(node.PropertyKeys).ToArray();
             string   key    = ( string )random.Among(keys);
             if (random.NextFloat() < 0.1)
             {                             // REMOVE
                 node.RemoveProperty(key);
             }
             else
             {                             // CHANGE
                 node.SetProperty(key, random.NextValue().asObject());
             }
             tx.Success();
         }
     }
     catch (NotFoundException)
     {               // It's OK, it happens if some other thread deleted that property in between us reading it and
         // removing or setting it
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideResultInOrderIfCapable() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideResultInOrderIfCapable()
        {
            int label = Token.nodeLabel("Node");
            int prop  = Token.propertyKey("prop");

            RandomValues   randomValues = RandomRule.randomValues();
            IndexReference index        = SchemaRead.index(label, prop);

            for (int i = 0; i < _nIterations; i++)
            {
                ValueType    type  = randomValues.Among(_targetedTypes);
                IndexOrder[] order = index.OrderCapability(type.valueGroup.category());
                foreach (IndexOrder indexOrder in order)
                {
                    if (indexOrder == IndexOrder.NONE)
                    {
                        continue;
                    }
                    NodeValueTuple from = new NodeValueTuple(this, long.MinValue, randomValues.NextValueOfType(type));
                    NodeValueTuple to   = new NodeValueTuple(this, long.MaxValue, randomValues.NextValueOfType(type));
                    if (COMPARATOR.compare(from, to) > 0)
                    {
                        NodeValueTuple tmp = from;
                        from = to;
                        to   = tmp;
                    }
                    bool fromInclusive = randomValues.NextBoolean();
                    bool toInclusive   = randomValues.NextBoolean();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> range = org.neo4j.internal.kernel.api.IndexQuery.range(prop, from.getOnlyValue(), fromInclusive, to.getOnlyValue(), toInclusive);
                    IndexQuery.RangePredicate <object> range = IndexQuery.range(prop, from.OnlyValue, fromInclusive, to.OnlyValue, toInclusive);

                    using (NodeValueIndexCursor node = Cursors.allocateNodeValueIndexCursor())
                    {
                        Read.nodeIndexSeek(index, node, indexOrder, false, range);

                        IList <long> expectedIdsInOrder = expectedIdsInOrder(from, fromInclusive, to, toInclusive, indexOrder);
                        IList <long> actualIdsInOrder   = new List <long>();
                        while (node.Next())
                        {
                            actualIdsInOrder.Add(node.NodeReference());
                        }

                        assertEquals(expectedIdsInOrder, actualIdsInOrder, "actual node ids not in same order as expected");
                    }
                }
            }
        }