示例#1
0
 private bool NodeExists(long id)
 {
     using (StorageNodeCursor node = StorageReader.allocateNodeCursor())
     {
         node.Single(id);
         return(node.Next());
     }
 }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private org.neo4j.storageengine.api.StorageNodeCursor newCursor(long nodeId)
        private StorageNodeCursor NewCursor(long nodeId)
        {
            StorageNodeCursor nodeCursor = StorageReader.allocateNodeCursor();

            nodeCursor.Single(nodeId);
            assertTrue(nodeCursor.Next());
            return(nodeCursor);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetAllNodeProperties()
        public virtual void ShouldGetAllNodeProperties()
        {
            // GIVEN
            string longString = "AlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalong";

            object[] properties = new object[] { longString, CreateNew(typeof(string)), CreateNew(typeof(long)), CreateNew(typeof(int)), CreateNew(typeof(sbyte)), CreateNew(typeof(short)), CreateNew(typeof(bool)), CreateNew(typeof(char)), CreateNew(typeof(float)), CreateNew(typeof(double)), Array(0, typeof(string)), Array(0, typeof(long)), Array(0, typeof(int)), Array(0, typeof(sbyte)), Array(0, typeof(short)), Array(0, typeof(bool)), Array(0, typeof(char)), Array(0, typeof(float)), Array(0, typeof(double)), Array(1, typeof(string)), Array(1, typeof(long)), Array(1, typeof(int)), Array(1, typeof(sbyte)), Array(1, typeof(short)), Array(1, typeof(bool)), Array(1, typeof(char)), Array(1, typeof(float)), Array(1, typeof(double)), Array(256, typeof(string)), Array(256, typeof(long)), Array(256, typeof(int)), Array(256, typeof(sbyte)), Array(256, typeof(short)), Array(256, typeof(bool)), Array(256, typeof(char)), Array(256, typeof(float)), Array(256, typeof(double)) };

            foreach (object value in properties)
            {
                // given
                long nodeId = CreateLabeledNode(Db, singletonMap("prop", value), Label1).Id;

                // when
                using (StorageNodeCursor node = StorageReader.allocateNodeCursor())
                {
                    node.Single(nodeId);
                    assertTrue(node.Next());

                    using (StoragePropertyCursor props = StorageReader.allocatePropertyCursor())
                    {
                        props.Init(node.PropertiesReference());
                        if (props.Next())
                        {
                            Value propVal = props.PropertyValue();

                            //then
                            assertTrue(propVal + ".equals(" + value + ")", propVal.Equals(Values.of(value)));
                        }
                        else
                        {
                            fail();
                        }
                    }
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToListLabelsForNode()
        public virtual void ShouldBeAbleToListLabelsForNode()
        {
            // GIVEN
            long nodeId;
            int  labelId1;
            int  labelId2;

            using (Transaction tx = Db.beginTx())
            {
                nodeId = Db.createNode(Label1, Label2).Id;
                string labelName1 = Label1.name();
                string labelName2 = Label2.name();
                labelId1 = LabelId(Label.label(labelName1));
                labelId2 = LabelId(Label.label(labelName2));
                tx.Success();
            }

            // THEN
            StorageNodeCursor nodeCursor = StorageReader.allocateNodeCursor();

            nodeCursor.Single(nodeId);
            assertTrue(nodeCursor.Next());
            assertEquals(newSetWith(labelId1, labelId2), newSetWith(nodeCursor.Labels()));
        }